C++ main module for gpm Package  1.0
MATH_Environment.h
Go to the documentation of this file.
1 #ifndef MATH_Environment_H
2 #define MATH_Environment_H
3 
4 #include "MATH_Variable.h"
5 
14 class MATH_Environment : public CORE_Object {
15  SP_OBJECT(MATH_Environment);
16 
17  // ATTRIBUTES
18 private:
19  static const tString COORD;
20 
21 private:
22 
23  // variables -> variables
24  map<tString,SP::MATH_Variable> mVariables;
25 
26 
27 protected:
28  // METHODS
29 
30  // CONSTRUCTORS
31 
34  MATH_Environment(void);
35 
36 
37 
38  // DESTRUCTORS
39 
40 
43  virtual ~MATH_Environment(void);
44 
45 private:
46 
47 public:
50  static inline SP::MATH_Environment New() {
51  SP::MATH_Environment p(new MATH_Environment(),MATH_Environment::Delete());
52  p->setThis(p);
53  return p;
54  }
55 
56 
57 
58 
59  // SET methods
60 
63  virtual void copy(const MATH_Environment& env);
64 
65 
68  inline void clear() {
69  mVariables.clear();
70  }
73  void setVariable(const tString& name,const tString& value);
76  void setVariable(const tString& name,const double& value);
79  void setVariable(const tString& name,const int& index,const double& value);
80 
83  void setVariable(const tString& name,const int& value);
86  void setVariable(const tString& name,const tBoolean& value);
89  void setVariable(const tString& name,const double* value,const int& n);
92  void setVariable(const tString& name,const long double* value,const int& n);
93 
96  void setVariable(const tString& name,const int* value,const int& n);
97 
98 
99 
102  inline SP::MATH_Variable addVariable(const tString& name) {
103  SP::MATH_Variable v=MATH_Variable::New();
104  mVariables[name]=v;
105  return v;
106  }
107 
110  inline void setCurrentPoint(const double p[3]) {
111  setVariable(COORD,p,3);
112  }
115  inline void setCurrentPoint(const tReal p[3]) {
116  setCurrentPoint((double)p[0],(double)p[1],(double)p[2]);
117  }
120  inline void setCurrentPoint(const double &x,const double& y,const double& z) {
121  setVariable(COORD,0,x);
122  setVariable(COORD,1,y);
123  setVariable(COORD,2,z);
124 
125  }
126 
127  // GET methods
128 
131  const MATH_Variable* getVariable(const tString& name) const {
132  map<tString,SP::MATH_Variable>::const_iterator iter=mVariables.find(name);
133  if (iter==mVariables.end()) return null;
134  return iter->second.get();
135 
136  }
140  map<tString,SP::MATH_Variable>::iterator iter=mVariables.find(name);
141  if (iter==mVariables.end()) return null;
142  return iter->second.get();
143 
144  }
147  int getVariable(const tString& name,MATH_Variable& var) const;
148 
151  void getVariable(const tString& name,double& value) const;
154  void getVariable(const tString& name,double* value,int& n) const;
157  void getVariable(const tString& name,tString& value) const;
158 
161  tFlag getVariableType(const tString& name) const {
162  map<tString,SP::MATH_Variable>::const_iterator iter=mVariables.find(name);
163  if (iter==mVariables.end()) return MATH_Variable::UNDEFINED;
164  return iter->second->getType();
165  }
168  inline void getCurrentPoint(double p[3]) const {
169  int n=3;
170  getVariable(COORD,p,n);
171  }
172 
175  void getVariables(vector<tString>& variables) const {
176  map<tString,SP::MATH_Variable>::const_iterator iter=mVariables.begin();
177  variables.clear();
178  while (iter!=mVariables.end()) {
179  variables.push_back(iter->first);
180  iter++;
181  }
182  }
183 
186  virtual tString toString() const;
187 
188 
189 };
190 
191 #endif
tFlag getVariableType(const tString &name) const
get variable type
Definition: MATH_Environment.h:161
This class decribes a variable class for evaluation.
Definition: MATH_Variable.h:16
static SP::MATH_Variable New()
create a node expression
Definition: MATH_Variable.h:65
MATH_Environment(void)
create
Definition: MATH_Environment.cpp:9
void clear()
clear
Definition: MATH_Environment.h:68
void getCurrentPoint(double p[3]) const
get current point
Definition: MATH_Environment.h:168
void getVariables(vector< tString > &variables) const
get all the variables
Definition: MATH_Environment.h:175
const MATH_Variable * getVariable(const tString &name) const
get variable
Definition: MATH_Environment.h:131
#define tBoolean
Definition: types.h:35
void setCurrentPoint(const tReal p[3])
get current point
Definition: MATH_Environment.h:115
#define null
Definition: types.h:13
virtual ~MATH_Environment(void)
destroy
Definition: MATH_Environment.cpp:12
void setVariable(const tString &name, const tString &value)
set variable
Definition: MATH_Environment.cpp:29
MATH_Variable * getVariable(const tString &name)
get variable
Definition: MATH_Environment.h:139
SP::MATH_Variable addVariable(const tString &name)
add variablewith no type
Definition: MATH_Environment.h:102
abstract base class for most classes.
Definition: CORE_Object.h:30
static SP::MATH_Environment New()
create a node expression
Definition: MATH_Environment.h:50
#define tString
Definition: types.h:36
This class decribes an environment class.
Definition: MATH_Environment.h:14
DEFINE_SPTR(MATH_Environment)
virtual void copy(const MATH_Environment &env)
copy
Definition: MATH_Environment.cpp:14
virtual tString toString() const
print the environment class in a string
Definition: MATH_Environment.cpp:239
void setCurrentPoint(const double p[3])
get current point
Definition: MATH_Environment.h:110
#define tReal
Definition: types.h:18
void setCurrentPoint(const double &x, const double &y, const double &z)
get current point
Definition: MATH_Environment.h:120
static const tFlag UNDEFINED
Definition: MATH_Variable.h:25
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106
#define tFlag
Definition: types.h:14