DiaDes  0.1
DIAgnosis of Discrete-Event System
EventEncoder.hh
Go to the documentation of this file.
1 
9 #ifndef __DIADES__SDMDL_EXPERIMENTAL__EVENTENCODER__HH__
10 #define __DIADES__SDMDL_EXPERIMENTAL__EVENTENCODER__HH__
11 
12 #include<vector>
15 
16 namespace Diades
17 {
18  namespace Sdmdl
19  {
20  namespace Experimental
21  {
22 
23 
34  {
35  public:
40  using VariableEncoderId = VariableVector::size_type;
45  using Event = size_t;
46 
47 
48  private:
55 
61 
67  std::vector<std::vector<Event> > _domains;
68 
69  public:
70 
76  _variables(varFactory),
77  _encodedVariables(),
78  _domains()
79  {}
80 
81  private:
89  {
90  stringstream stream;
91  stream << evt;
92  _domains[varId].push_back(evt);
93  return _encodedVariables[varId].get().addValue(stream.str());
94  }
95 
96 
97  public:
105  template<typename EventIterator>
107  encodeEventRange(EventIterator first,
108  EventIterator last)
109  {
110  std::stringstream stream;
111  stream << "var_"
112  << this
113  << "_"
114  << _variables.numberOfAllocatedVariables();
115  VariableEncoderId result = _encodedVariables.size();
116  _encodedVariables.push_back(_variables.newVariable(stream.str()));
117  _domains.push_back(std::vector<Event>());
118  while (first != last)
119  {
120  encodeEventInVariable(result,*first);
121  ++first;
122  }
123  return result;
124 
125  }
126 
127 
134  {
135  return _encodedVariables[id].get();
136  }
137 
143  std::vector<Event> & getDomain(VariableEncoderId id)
144  {
145  return _domains[id];
146  }
147 
148  };
149  }
150  }
151 }
152 
153 
154 
155 
156 #endif
157 
EventEncoder(VariableFactory &varFactory)
Definition: EventEncoder.hh:75
VariableEncoderId encodeEventRange(EventIterator first, EventIterator last)
std::vector< std::vector< Event > > _domains
Definition: EventEncoder.hh:67
Variable & getVariable(VariableEncoderId id)
std::vector< Event > & getDomain(VariableEncoderId id)
VariableVector::size_type VariableEncoderId
Definition: EventEncoder.hh:40
Variable::VariableVector VariableVector
Definition: Variable.hh:403
Namespace of the Diades project.
Variable & newVariable(const std::string &label)
const Value & encodeEventInVariable(VariableEncoderId varId, Event evt)
Definition: EventEncoder.hh:88
size_t numberOfAllocatedVariables() const
Definition: Variable.hh:481