C++ main module for gpm Package  1.0
GPM_Rule.h
Go to the documentation of this file.
1 #ifndef GPM_Rule_H
2 #define GPM_Rule_H
3 
4 
5 #include "GPM_Object.h"
6 #include "GPM_PortGraph.h"
7 #include "GPM_GraphElement.h"
9 
10 #include "CORE_IO.h"
11 
12 
23 class GPM_Rule : public GPM_Object {
24 
25  SP_OBJECT(GPM_Rule);
26  // ATTRIBUTES
27 
28 public:
29 
30 
31 
32 private:
33 
34 
35  //action
36  tFlag mAction;
37  tString mName;
38 
39 protected:
40  // METHODS
41 
42  // CONSTRUCTORS
43 
46  GPM_Rule(void);
47 
48 
49 
50  // DESTRUCTORS
51 
52 
55  virtual ~GPM_Rule(void);
56 
57 
58 public:
59 
60  // NEW Method
61  //===========
62 
65  virtual SP::GPM_Rule NewInstance() const =0;
68  virtual SP::GPM_Rule NewInstance(const tFlag& action,const tString& expr) const {
69  SP::GPM_Rule rule=NewInstance();
70  rule->setAction(action);
71  rule->setExpression(expr);
72  return rule;
73  }
74 
75 
76 
77 
78  // SET Methods
79  // ===========
80 
83  virtual void copy(const GPM_Rule& rule) {
84  setAction(rule.getAction());
86  setName(rule.getName());
87  }
88 
91  inline void setName(const tString& name) {
92  mName=name;
93  }
96  inline tString getName() const {
97  return mName;
98  }
101  inline void setAction(const tFlag& action) {
102  mAction=action;
103  }
104 
107  virtual void clearEnvironment()=0;
108 
111  virtual void setExpression(const tString& expr)=0;
114  tBoolean isDependentOn(const tString& varName) const;
115 
116 
117  // GET Methods
118  // ===========
119 
120 
123  inline tFlag getAction() const {
124  return mAction;
125 
126  }
127 
131  virtual const double* getValue(int& n) const =0;
134  virtual double* getValue(int& n)=0;
135 
138  virtual tString getExpression() const=0;
139 
140  // BUILDER method
141 
144  virtual void buildEnvironment(const GPM_Graph& largeGraph,
145  const GPM_Graph& patternGraph,
146  const vector<tVertexIID>& mappingP2L,
147  CORE_Out& io);
150  virtual void buildEnvironment(const GPM_Graph& largeGraph,
151  const GPM_PortGraph& transformerGraph,
152  const map<tVertexIID,tVertexIID>& mappingT2L,
153  CORE_Out& io);
154 
157  virtual void buildEnvironment(const GPM_Graph& graph,
158  const tString& graphLetter,
159  CORE_Out& io);
160 
163  virtual void buildEnvironment(const GPM_GraphElement& element,
164  const tString& elementLetter,
165  CORE_Out& io);
166 
167 
170  virtual void buildEnvironment(const map<tString,SP::GPM_Variable>& gVariables,
171  CORE_Out& io);
174  virtual void buildEnvironment(const SV::GPM_CompositorFunction& functions,
175  CORE_Out& io);
176 
179  virtual void setVariable(const tString& name,const tFlag& type,
180  const double* values,const int& n,const tBoolean& isGlobal)=0;
183  virtual void setVariable(const tString& name,const tFlag& type,
184  const double& values)=0;
185 
188  inline void setVariable(const tString& name,const double* values,const int& n) {
189  setVariable(name,GPM_Variable::REAL,values,n,false);
190  }
193  inline void addVariable(const tString& name,const tFlag& type,
194  const double* values,const int& n,const tBoolean& isGlobal) {
195  setVariable(name,type,values,n,isGlobal);
196  }
199  inline void addVariable(const tString& name,
200  const double* values,const int& n) {
201  setVariable(name,GPM_Variable::REAL,values,n,false);
202  }
205  virtual void clearFunctions()=0;
208  virtual void addFunction(SP::GPM_CompositorFunction f)=0;
209 
210 
211  // compute the method
212  virtual void compute(SP::GPM_Rule commonRuleEnv)=0;
213  // compute the method
214  inline void compute() {
215  compute(getThis());
216  }
217 
218 
221  virtual tString toString() const=0;
222 
223 
224 
225 };
226 
227 #endif
void setName(const tString &name)
set the name
Definition: GPM_Rule.h:91
void compute()
Definition: GPM_Rule.h:214
DEFINE_SVPTR(GPM_Rule)
tFlag getAction() const
get action
Definition: GPM_Rule.h:123
virtual void setVariable(const tString &name, const tFlag &type, const double *values, const int &n, const tBoolean &isGlobal)=0
set variable in environement
void setAction(const tFlag &action)
set teh action of the rule
Definition: GPM_Rule.h:101
virtual tString getExpression() const =0
get the expression
#define tBoolean
Definition: types.h:35
DEFINE_SPTR(GPM_Rule)
tString getName() const
get the name
Definition: GPM_Rule.h:96
void addVariable(const tString &name, const tFlag &type, const double *values, const int &n, const tBoolean &isGlobal)
set variable in environement
Definition: GPM_Rule.h:193
This class describes a rule.
Definition: GPM_Rule.h:23
virtual tString toString() const =0
reture th rule to string
static const tFlag REAL
Definition: GPM_Variable.h:23
tBoolean isDependentOn(const tString &varName) const
return true if the rule depend on the variable with name
Definition: GPM_Rule.cpp:14
virtual void buildEnvironment(const GPM_Graph &largeGraph, const GPM_Graph &patternGraph, const vector< tVertexIID > &mappingP2L, CORE_Out &io)
build the environement thanks to the pattern graph
Definition: GPM_Rule.cpp:135
GPM_Rule(void)
create
Definition: GPM_Rule.cpp:7
void setVariable(const tString &name, const double *values, const int &n)
set variable in environement
Definition: GPM_Rule.h:188
virtual SP::GPM_Rule NewInstance(const tFlag &action, const tString &expr) const
create a calculator
Definition: GPM_Rule.h:68
virtual void clearEnvironment()=0
clear the envirnment
virtual void clearFunctions()=0
clear generic function of environement
virtual void setExpression(const tString &expr)=0
set the expression
void addVariable(const tString &name, const double *values, const int &n)
set variable in environement
Definition: GPM_Rule.h:199
#define tString
Definition: types.h:36
This class describes a graph which is a list of vertices, ports & edges.
Definition: GPM_PortGraph.h:22
virtual const double * getValue(int &n) const =0
get the value
this class describes the output by default write on standart output
Definition: CORE_Out.h:21
This class is the base class of all graph classes.
Definition: GPM_Object.h:17
This class describes a graph which is a list of nodes & ports.
Definition: GPM_Graph.h:19
virtual void addFunction(SP::GPM_CompositorFunction f)=0
add generic function in environement
virtual SP::GPM_Rule NewInstance() const =0
create a calculator
This class describes an element of a graph.
Definition: GPM_GraphElement.h:17
virtual void copy(const GPM_Rule &rule)
copy
Definition: GPM_Rule.h:83
virtual ~GPM_Rule(void)
destroy
Definition: GPM_Rule.cpp:11
#define tFlag
Definition: types.h:14