DiaDes  0.1
DIAgnosisofDiscrete-EventSystem
Function.hh
Go to the documentation of this file.
1 #ifndef __DIADES__ALTARICA__FUNCTION__HH
2 #define __DIADES__ALTARICA__FUNCTION__HH
3 
4 
5 #include"Variable2.hh"
6 
7 
8 namespace Altarica
9 {
10  class Function
11  {
12  private:
13  vector<Variable> _param;
14  Expression * _expression;
15  public:
16  bool eval(const vector<Value> & values,Value & result)
17  {
18  bool isOk = _param.size() == values.size();
19  if(isOk)
20  {
21  vector<Variable>::size_type index = 0;
22  while((index < _param.size())
23  &&
24  (isOk))
25  {
26  isOk = _param[index].setValue(values[index]);
27  ++index;
28  }
29  if(isOk)
30  {
31  isOk = _expression->eval(result);
32  if(!isOk)
33  {
34  result = Value();
35  }
36  }
37  else
38  {
39  result = Value();
40  }
41  }
42  else
43  {
44  result = Value();
45  }
46  return isOk;
47  }
48  }
49 };
50 
51 
52 #endif
vector< Variable > _param
Definition: Function.hh:13
bool eval(const vector< Value > &values, Value &result)
Definition: Function.hh:16
Expression * _expression
Definition: Function.hh:14