CPN
Computational Process Networks
KernelAttr.h
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
25 #ifndef CPN_KERNELATTR_H
26 #define CPN_KERNELATTR_H
27 #pragma once
28 
29 #include <cpn/common.h>
30 #include <string>
31 #include <vector>
32 
33 namespace CPN {
41  public:
46  KernelAttr(const std::string &name_)
47  : name(name_),
48  hostname("localhost"),
49  servname(""),
50  remote_enabled(false),
51  useD4R(true), swallowbrokenqueue(false),
52  growmaxthresh(true)
53  {}
54 
55  KernelAttr(const char* name_)
56  : name(name_),
57  hostname("localhost"),
58  servname(""),
59  remote_enabled(false),
60  useD4R(true), swallowbrokenqueue(false),
61  growmaxthresh(true)
62  {}
63 
64  KernelAttr &SetName(const std::string &n) {
65  name = n;
66  return *this;
67  }
68 
69  KernelAttr &SetHostName(const std::string &hn) {
70  hostname = hn;
71  return *this;
72  }
73 
74  KernelAttr &SetServName(const std::string &sn) {
75  servname = sn;
76  return *this;
77  }
78 
79  KernelAttr &SetContext(shared_ptr<Context> ctx) {
80  context = ctx;
81  return *this;
82  }
83 
85  remote_enabled = en;
86  return *this;
87  }
88 
89  KernelAttr &UseD4R(bool enable) {
90  useD4R = enable;
91  return *this;
92  }
93 
95  swallowbrokenqueue = enable;
96  return *this;
97  }
98 
100  growmaxthresh = enable;
101  return *this;
102  }
103 
104  KernelAttr &AddSharedLib(const std::string &lib) {
105  sharedlibs.push_back(lib);
106  return *this;
107  }
108 
109  KernelAttr &AddNodeList(const std::string &list) {
110  nodelists.push_back(list);
111  return *this;
112  }
113 
114  KernelAttr &AddNodeSearchPath(const std::string &p) {
115  searchpaths.push_back(p);
116  return *this;
117  }
118 
119  const std::string &GetName() const { return name; }
120 
121  const std::string &GetHostName() const { return hostname; }
122 
123  const std::string &GetServName() const { return servname; }
124 
125  shared_ptr<Context> GetContext() const { return context; }
126 
127  bool GetRemoteEnabled() const { return remote_enabled; }
128 
129  bool UseD4R() const { return useD4R; }
130 
131  bool SwallowBrokenQueueExceptions() const { return swallowbrokenqueue; }
132 
133  bool GrowQueueMaxThreshold() const { return growmaxthresh; }
134 
135  const std::vector<std::string> &GetSharedLibs() const { return sharedlibs; }
136 
137  const std::vector<std::string> &GetNodeLists() const { return nodelists; }
138 
139  const std::vector<std::string> &GetNodeSearchPaths() const { return searchpaths; }
140  private:
141  std::string name;
142  std::string hostname;
143  std::string servname;
144  shared_ptr<Context> context;
146  bool useD4R;
149  std::vector<std::string> sharedlibs;
150  std::vector<std::string> nodelists;
151  std::vector<std::string> searchpaths;
152  };
153 }
154 #endif
KernelAttr & SetRemoteEnabled(bool en)
Definition: KernelAttr.h:84
KernelAttr & SwallowBrokenQueueExceptions(bool enable)
Definition: KernelAttr.h:94
bool SwallowBrokenQueueExceptions() const
Definition: KernelAttr.h:131
KernelAttr(const char *name_)
Definition: KernelAttr.h:55
const std::vector< std::string > & GetNodeLists() const
Definition: KernelAttr.h:137
The attribute for the Kernel.
Definition: KernelAttr.h:40
std::vector< std::string > sharedlibs
Definition: KernelAttr.h:149
std::string hostname
Definition: KernelAttr.h:142
std::vector< std::string > nodelists
Definition: KernelAttr.h:150
bool GrowQueueMaxThreshold() const
Definition: KernelAttr.h:133
shared_ptr< Context > context
Definition: KernelAttr.h:144
KernelAttr & GrowQueueMaxThreshold(bool enable)
Definition: KernelAttr.h:99
KernelAttr & AddSharedLib(const std::string &lib)
Definition: KernelAttr.h:104
const std::vector< std::string > & GetNodeSearchPaths() const
Definition: KernelAttr.h:139
std::string name
Definition: KernelAttr.h:141
KernelAttr & SetName(const std::string &n)
Definition: KernelAttr.h:64
shared_ptr< Context > GetContext() const
Definition: KernelAttr.h:125
KernelAttr & UseD4R(bool enable)
Definition: KernelAttr.h:89
const std::string & GetServName() const
Definition: KernelAttr.h:123
std::string servname
Definition: KernelAttr.h:143
std::vector< std::string > searchpaths
Definition: KernelAttr.h:151
bool UseD4R() const
Definition: KernelAttr.h:129
KernelAttr & AddNodeList(const std::string &list)
Definition: KernelAttr.h:109
const std::vector< std::string > & GetSharedLibs() const
Definition: KernelAttr.h:135
KernelAttr & SetHostName(const std::string &hn)
Definition: KernelAttr.h:69
KernelAttr & AddNodeSearchPath(const std::string &p)
Definition: KernelAttr.h:114
const std::string & GetName() const
Definition: KernelAttr.h:119
KernelAttr & SetServName(const std::string &sn)
Definition: KernelAttr.h:74
bool GetRemoteEnabled() const
Definition: KernelAttr.h:127
#define CPN_API
Definition: common.h:36
bool swallowbrokenqueue
Definition: KernelAttr.h:147
const std::string & GetHostName() const
Definition: KernelAttr.h:121
KernelAttr(const std::string &name_)
Create a new KernelAttr. There is only one required attributed and that is to give the Kernel a name...
Definition: KernelAttr.h:46
KernelAttr & SetContext(shared_ptr< Context > ctx)
Definition: KernelAttr.h:79