DiaDes  0.1
DIAgnosis of Discrete-Event System
StatePropertyManager.hh
Go to the documentation of this file.
1 /*
2  * @file StatePropertyManager.hh
3  * @author Yannick PencolĂ©, ypencole@laas.fr, LAAS-CNRS,Univ. Toulouse
4  *
5  * Created on November, 2nd 2017, 18:22
6  */
7 
8 #ifndef __DIADES_AUTOMATA_EXPERIMENTAL_STATEPROPERTYMANAGER_HH
9 #define __DIADES_AUTOMATA_EXPERIMENTAL_STATEPROPERTYMANAGER_HH
10 #include <limits>
11 #include <cstddef>
12 #include<unordered_map>
13 #include<vector>
14 #include <numeric>
15 
16 #include <diades/utils/Iterator.hh>
19 #include <diades/utils/Verbose.hh>
22 
23 namespace Diades
24 {
25  namespace Automata
26  {
27  namespace Experimental
28  {
29  using Diades::Utils::Msg;
30 
37  using StatePropertyAsStringLabel = std::string;
38 
45  using StatePropertyAsUnsigned = unsigned;
46 
65  template<typename _StateProperty, typename charT, charT sep, typename BinaryDisjunction, typename Delimiter>
67  {
68  public:
69  using StateProperty = _StateProperty;
70 
71  template<typename StatePropertyIterator>
72  StateProperty operator()(StateProperty source, StatePropertyIterator begin, StatePropertyIterator end)
73  {
74  StateProperty disj;
75  if(begin != end)
76  {
77  disj = std::accumulate(++begin, end, *begin, BinaryDisjunction());
78  }
79  return Delimiter()(source + sep + disj);
80  }
81  };
82 
85 
93  template<typename _StateProperty,
94  typename _StatePropertyId,
95  typename NullStProperty = NullValue<_StateProperty>,
96  typename NullStPropertyId = NullValue<_StatePropertyId>,
97  typename Hash = std::hash<_StateProperty> >
99  public InfoManager<_StateProperty,
100  _StatePropertyId,
101  NullStProperty,
102  NullStPropertyId,
103  Hash>
104  {
105  public:
106  using IM = InfoManager<_StateProperty,
107  _StatePropertyId,
108  NullStProperty,
109  NullStPropertyId,
110  Hash>;
111  using StateProperty = typename IM::Info;
112  using StatePropertyId = typename IM::InfoId;
113 
114  static string
116  {
117  return "Diades::Automata::Experimental::StatePropertyManager";
118  }
120 
121 
122 
123 
124 
125  private:
126 
131 
132 
133 
134 
135 
136 
137  public:
138 
139 
140 
141 
145  StatePropertyManager() = default;
146 
147 
152  StatePropertyManager(StatePropertyManager const& other) = default;
153 
159  StatePropertyManager& operator=(StatePropertyManager const& other) = default;
160 
161 
162 
163 
168  StatePropertyManager(StatePropertyManager&& other) = default;
174  StatePropertyManager& operator=(StatePropertyManager&& other) = default;
175 
179  virtual ~StatePropertyManager() = default;
180 
186  bool
187  hasStateProperty(const StateProperty & stateProperty) const
188  {
189  return IM::hasInfo(stateProperty);
190  }
191 
199  bool
201  {
202  return IM::hasInfoId(id);
203  }
204 
214  bool
215  setStateProperty(const StateProperty & stateProperty, StatePropertyId id)
216  {
217 
218  return IM::setInfo(stateProperty,id);
219  }
220 
228  statePropertyId(const StateProperty & stateProperty)
229  {
230  return IM::infoId(stateProperty);
231  }
232 
240  const StateProperty &
242  {
243  return IM::getInfo(id);
244  }
245 
246 // /**
247 // *
248 // * @param iterator a StateInfoIdIterator (whatever iterator which refers to a StateInfoId)
249 // * @return an iterator on the StateInfo from the StateInfoId range
250 // * @p here is how to use this. Suppose you have a range of StateInfoId begin,end
251 // * from the current manager, then stateInfoIdRangeStateInfoIterator(begin),
252 // * stateInfoIdRangeStateInfoIterator(end) is the corresponding StateInfo Range.
253 // */
254 // template<typename StatePropertyIdIterator>
255 // typename IM::InfoIdRangeInfoIterator
256 // statePropertyIdRangeStatePropertyIterator(StatePropertyIdIterator iterator) const
257 // {
258 // return IM::infoIdRangeInfoIterator(iterator);
259 // }
260 
265  size_t
267  {
268  return IM::numberOfInfos();
269  }
270  };
271  }
272  }
273 }
274 
275 
276 
277 
278 
279 #endif /* __DIADES_AUTOMATA_EXPERIMENTAL_STATEINFOMANAGER_HH */
280 
bool hasStateProperty(const StateProperty &stateProperty) const
StatePropertyId statePropertyId(const StateProperty &stateProperty)
bool setStateProperty(const StateProperty &stateProperty, StatePropertyId id)
Namespace of the Diades project.
StateProperty operator()(StateProperty source, StatePropertyIterator begin, StatePropertyIterator end)
boost::format Msg
Definition: Verbose.hh:42
const StateProperty & getStateProperty(StatePropertyId id) const