CPN
Computational Process Networks
NodeAttr.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 //=============================================================================
24 #ifndef CPN_NODEATTR_H
25 #define CPN_NODEATTR_H
26 #pragma once
27 
28 #include <cpn/common.h>
29 #include <string>
30 #include <map>
31 #include <sstream>
32 
33 namespace CPN {
34 
58  class CPN_API NodeAttr {
59  public:
60  NodeAttr(const std::string &name_,
61  const std::string &nodetype_)
62  : kernelname(),
63  kernelkey(0),
64  name(name_),
65  nodetype(nodetype_),
66  key(0)
67  {}
68 
69  NodeAttr &SetName(const std::string &name_) {
70  name = name_;
71  return *this;
72  }
73 
74  NodeAttr &SetTypeName(const std::string &nodetype_) {
75  nodetype = nodetype_;
76  return *this;
77  }
78 
79  NodeAttr &SetKernel(const std::string &kname) {
80  kernelname = kname;
81  return *this;
82  }
83 
85  kernelkey = k;
86  return *this;
87  }
88 
89  NodeAttr &SetParam(const std::string &key, const std::string value) {
90  params[key] = value;
91  return *this;
92  }
93 
94  template<typename T>
95  NodeAttr &SetParam(const std::string &key, T value) {
96  std::ostringstream oss;
97  oss << value;
98  params[key] = oss.str();
99  return *this;
100  }
101 
103  key = key_;
104  return *this;
105  }
106 
107  const std::string &GetKernel() const { return kernelname; }
108  Key_t GetKernelKey() const { return kernelkey; }
109 
110  const std::string &GetName() const { return name; }
111 
112  const std::string &GetTypeName() const { return nodetype; }
113 
114  const std::map<std::string, std::string> &GetParams() const { return params; }
115 
116  Key_t GetKey() const { return key; }
117 
118  private:
119  std::string kernelname;
121  std::string name;
122  std::string nodetype;
123  std::map<std::string, std::string> params;
125  };
126 }
127 #endif
Key_t GetKey() const
Definition: NodeAttr.h:116
NodeAttr & SetTypeName(const std::string &nodetype_)
Definition: NodeAttr.h:74
Attributes for a node.
Definition: NodeAttr.h:58
NodeAttr & SetKernel(const std::string &kname)
Definition: NodeAttr.h:79
NodeAttr & SetKernelKey(Key_t k)
Definition: NodeAttr.h:84
std::string kernelname
Definition: NodeAttr.h:119
NodeAttr & SetKey(Key_t key_)
Definition: NodeAttr.h:102
std::string name
Definition: NodeAttr.h:121
uint64_t Key_t
Definition: common.h:79
const std::map< std::string, std::string > & GetParams() const
Definition: NodeAttr.h:114
NodeAttr & SetParam(const std::string &key, const std::string value)
Definition: NodeAttr.h:89
NodeAttr & SetParam(const std::string &key, T value)
Definition: NodeAttr.h:95
std::map< std::string, std::string > params
Definition: NodeAttr.h:123
Key_t kernelkey
Definition: NodeAttr.h:120
const std::string & GetName() const
Definition: NodeAttr.h:110
const std::string & GetTypeName() const
Definition: NodeAttr.h:112
#define CPN_API
Definition: common.h:36
const std::string & GetKernel() const
Definition: NodeAttr.h:107
Key_t GetKernelKey() const
Definition: NodeAttr.h:108
NodeAttr(const std::string &name_, const std::string &nodetype_)
Definition: NodeAttr.h:60
std::string nodetype
Definition: NodeAttr.h:122
NodeAttr & SetName(const std::string &name_)
Definition: NodeAttr.h:69