C++ main module for gpm Package  1.0
GPM_ModelGraphElement.h
Go to the documentation of this file.
1 #ifndef GPM_ModelGraphElement_H
2 #define GPM_ModelGraphElement_H
3 
4 
5 #include "GPM_Object.h"
6 
7 #include "GPM_GraphElement.h"
8 #include "GPM_Rule.h"
9 
11 
22 
23  SP_OBJECT(GPM_ModelGraphElement);
24  // ATTRIBUTES
25 
26 public:
27 
28 
29 
30 private:
31 
32  // rules of variable
33  SV::GPM_Rule mRules;
34 
35 protected:
36  // METHODS
37 
38  // CONSTRUCTORS
39 
43 
44 
45 
46  // DESTRUCTORS
47 
48 
51  virtual ~GPM_ModelGraphElement(void);
52 
53 
54 
55 public:
56 
57  // SET Methods
58  // ===========
59 
62  virtual void copy(const GPM_ModelGraphElement& vertex);
63 
66  inline void clearRules() {
67  mRules.clear();
68  }
71  void updateRules(const GPM_ModelClassFactory& cf);
72 
78  void addRule(const tString& varName,SP::GPM_Rule r);
79 
80 
84  void removeRule(const tString& varName);
85 
91  tBoolean setRuleAction(const tString& varName,const tFlag& action);
92 
97  void setRuleAction(const int& index,const tFlag& action) {
98  mRules[index]->setAction(action);
99  }
100 
103  void swap(const unsigned int& i,const unsigned int& j);
104 
105  // GET Methods
106  // =============
107 
111  inline int getRulesNumber() const {
112  return mRules.getSize();
113  }
114 
115 
120  inline int getRuleIndex(const tString &name) const {
121  int n=mRules.getSize();
122  for (int i=0;i<n;i++)
123  if (mRules[i]->getName().compare(name)==0) return i;
124  return -1;
125  }
130  inline tString getRuleName(const int& index) const {
131  if ((index<0) || (index>=((int)mRules.getSize()))) return "";
132  return mRules[index]->getName();
133 
134  }
140  inline const GPM_Rule* getRule(const int& index) const {
141  if ((index<0) || (index>=((int)mRules.getSize()))) return null;
142  return mRules[index].get();
143 
144  }
150  inline GPM_Rule* getRule(const int& index) {
151  if ((index<0) || (index>=((int)mRules.size()))) return null;
152  return mRules[index].get();
153 
154  }
157  virtual void updateEnvironment(const map<tString,SP::GPM_Variable>& env);
158 
159 
163 
164 
165 };
166 
167 #endif
void removeRule(const tString &varName)
remove rule corresponding to varName
Definition: GPM_ModelGraphElement.cpp:63
This class describes a model GraphElement interface.
Definition: GPM_ModelGraphElement.h:21
tBoolean setRuleAction(const tString &varName, const tFlag &action)
set rule action
Definition: GPM_ModelGraphElement.cpp:71
void addRule(const tString &varName, SP::GPM_Rule r)
add rule corresponding to varName
Definition: GPM_ModelGraphElement.cpp:53
int getRulesNumber() const
get the rules number
Definition: GPM_ModelGraphElement.h:111
tBoolean orderTriggerRules()
Definition: GPM_ModelGraphElement.cpp:89
virtual ~GPM_ModelGraphElement(void)
destroy
Definition: GPM_ModelGraphElement.cpp:10
#define tBoolean
Definition: types.h:35
GPM_ModelGraphElement(void)
create
Definition: GPM_ModelGraphElement.cpp:7
virtual void updateEnvironment(const map< tString, SP::GPM_Variable > &env)
update the environment
Definition: GPM_ModelGraphElement.cpp:29
#define null
Definition: types.h:13
void setRuleAction(const int &index, const tFlag &action)
set rule action
Definition: GPM_ModelGraphElement.h:97
void updateRules(const GPM_ModelClassFactory &cf)
update rules
Definition: GPM_ModelGraphElement.cpp:40
This class describes a rule.
Definition: GPM_Rule.h:23
int getRuleIndex(const tString &name) const
Definition: GPM_ModelGraphElement.h:120
This class is the class to save GPM classes.
Definition: GPM_ModelClassFactory.h:16
void swap(const unsigned int &i, const unsigned int &j)
swap 2 elements
Definition: GPM_ModelGraphElement.cpp:81
const GPM_Rule * getRule(const int &index) const
get the rule at index
Definition: GPM_ModelGraphElement.h:140
#define tString
Definition: types.h:36
void clearRules()
clear rules
Definition: GPM_ModelGraphElement.h:66
GPM_Rule * getRule(const int &index)
get the rule at index
Definition: GPM_ModelGraphElement.h:150
tString getRuleName(const int &index) const
get the rule corresponding to variable name
Definition: GPM_ModelGraphElement.h:130
This class is the base class of all graph classes.
Definition: GPM_Object.h:17
virtual void copy(const GPM_ModelGraphElement &vertex)
copy
Definition: GPM_ModelGraphElement.cpp:13
DEFINE_SPTR(GPM_ModelGraphElement)
#define tFlag
Definition: types.h:14