25 #ifndef CPN_NODEBASE_H
26 #define CPN_NODEBASE_H
42 namespace NodeBasePrivate {
45 static T
Coerce(
const std::string& key,
const std::string ¶m) {
46 std::istringstream iss(param);
51 throw std::invalid_argument(
"Unable to convert parameter \"" + key +
"\": \"" + param +
"\"");
56 static bool Coerce(
const std::string &,
const std::string ¶m) {
84 std::string GetParam(
const std::string &key)
const;
86 bool HasParam(
const std::string &key)
const;
94 T
GetParam(
const std::string &key, T def)
const {
96 return GetParam<T>(key);
115 virtual void Process() = 0;
123 std::map<std::string, std::string>
params;
128 #define CPN_DECLARE_NODE_FACTORY(type, klass) class type ## Factory : public CPN::NodeFactory {\
129 public: type ## Factory() : CPN::NodeFactory(#type) {}\
130 CPN::shared_ptr<CPN::NodeBase> Create(CPN::Kernel &ker, const CPN::NodeAttr &attr) { return CPN::shared_ptr<CPN::NodeBase>(new klass(ker, attr)); }};\
131 extern "C" CPN::shared_ptr<CPN::NodeFactory> cpninit ## type (void);\
132 CPN::shared_ptr<CPN::NodeFactory> cpninit ## type (void) { return CPN::shared_ptr<CPN::NodeFactory>(new type ## Factory); }
134 #define CPN_DECLARE_NODE_AND_FACTORY(type,klass) class klass : public CPN::NodeBase { \
135 public : klass(CPN::Kernel &kern, const CPN::NodeAttr& attr) : CPN::NodeBase(kern,attr) {} \
136 private: void Process(); }; \
137 CPN_DECLARE_NODE_FACTORY(type,klass)
Kernel * GetKernel()
Return a pointer to the kernel that his node is running under.
bool ParseBool(const std::string &str)
Parses string for a boolean value.
The definition common to all nodes in the process network.
T GetParam(const std::string &key) const
Definition for node attributes.
const std::string & GetTypeName() const
static bool Coerce(const std::string &, const std::string ¶m)
T GetParam(const std::string &key, T def) const
std::map< std::string, std::string > params
static T Coerce(const std::string &key, const std::string ¶m)
auto_ptr< Pthread > thread
Definition of the NodeFactory.