pd_attributes.h
Go to the documentation of this file.
1 /** @file pd_attributes.h Attributes for pushdown automata */
2 
3 
4 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2013 Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
7 
8 */
9 
10 
11 #ifndef FAUDES_PD_ATTRIBUTES_H
12 #define FAUDES_PD_ATTRIBUTES_H
13 
14 #include "corefaudes.h"
15 #include "pd_basics.h"
16 #include "pd_merge.h"
17 #include <utility>
18 
19 namespace faudes {
20 
21 /**
22  *
23  * State attribute with substates. Merged substates should only needed to be accessed for debugging.
24  *
25  * @ingroup PushdownPlugin
26  *
27  */
28 
30 
32 
33  public:
34 
35  /** Constructor */
37 
38  /** Destructor
39  *
40  * deletes mpMerge
41  */
43 
44  /**
45  * Test for default value (ie default flags)
46  *
47  * @return
48  * True for default value
49  */
50  virtual bool IsDefault(void) const {return AttributeFlags::IsDefault() && mpMerge == NULL;};
51 
52  /**
53  * Sets the mpMerge parameter. Allocates memory for the pointer.
54  * The reference given in the parameter will be copied into the new memory.
55  * Current mpMerge will be deleted.
56  *
57  * @param rMerge
58  * the merge parameter
59  */
60  void SetMerge(const MergeAbstract& rMerge);
61 
62  /**
63  * Getter for Merge
64  *
65  * @return
66  * mpMerge
67  */
68  const MergeAbstract* Merge() const { return mpMerge;}
69 
70  /**
71  * Setter for DfaState
72  *
73  * @return
74  * mDfaState
75  */
76  void DfaState(const Idx dfaState) { mDfaState = dfaState;}
77 
78  /**
79  * Getter for DfaState
80  *
81  * @return
82  * mDfaState
83  */
84  const Idx DfaState() const { return mDfaState;}
85 
86  private:
87 
88  /** Substates */
90  /** Associated DFA state */
92 
93  protected:
94 
95 
96  /**
97  * Assignment method.
98  *
99  * @param rSrcAttr
100  * Source to assign from
101  */
102  void DoAssign(const AttributePushdownState& rSrcAttr);
103 
104 
105  /**
106  * Test equality.
107  *
108  * @param rOther
109  * Other attribute to compare with.
110  */
111  bool DoEqual(const AttributePushdownState& rOther) const;
112 
113  /**
114  * Reads the attribute from TokenReader, see AttributeVoid for public wrappers.
115  *
116  * If the current token indicates a invariant section, the method reads the invariant
117  * from that section. Else, it does nothing. Exceptions may only be thrown
118  * on invalid data within the timing section. The context argument is ignored, the
119  * label argument can be used to override the default section name Invariant.
120  *
121  * @param rTr
122  * TokenReader to read from
123  * @param rLabel
124  * Section to read
125  * @param pContext
126  * Read context to provide contextual information
127  *
128  * @exception Exception
129  * - IO error (id 1)
130  */
131  virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
132 
133  /**
134  * Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.
135  *
136  * Writes am Invariant section to include data on the invariant. The label argument
137  * can be used to set a section label different the the default Invariant.
138  * Th context argument is ignored.
139  *
140  * @param rTw
141  * TokenWriter to write to
142  * @param rLabel
143  * Section to write
144  * @param pContext
145  * Write context to provide contextual information
146  *
147  * @exception Exception
148  * - IO error (id 2)
149  */
150  virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
151 
152  virtual void DoXWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const {DoWrite(rTw,rLabel,pContext); };
153 
154 }; // class AttributePushdownState
155 
156 
157 /**
158  *
159  * Transition attribute with pop and push.
160  *
161  * @ingroup PushdownPlugin
162  *
163  */
164 typedef std::set<std::pair<std::vector<Idx>,std::vector<Idx> > > PopPushSet;
165 
167 
169 
170  public:
171 
172  /** Constructor */
174 
175  /**
176  * Test for default value (ie default flags)
177  *
178  * @return
179  * True for default value
180  */
181  virtual bool IsDefault(void) const {
182  return mPopPush.empty();
183  };
184 
185  /** Pop and Push. To allow transitions with the same start state, event and event state, but with different pop and push, pop and push are stored in a vector of pop/push pairs. */
187 
188  /**
189  * Getter for PopPush
190  *
191  * @return
192  * mPopPush
193  */
194  const PopPushSet& PopPush() const { return mPopPush;}
195 
196  /**
197  * Delete a pop push pair from the the transitions
198  *
199  * @param rPop
200  * the pop part of the pair to delete
201  * * @param rPush
202  * the push part of the pair to delete
203  * @return
204  * true if pair did exist and deletion was successful, else false
205  */
206  bool ClrPopPush(const std::vector<Idx>& rPop, const std::vector<Idx>& rPush);
207 
208  protected:
209 
210  /**
211  * Assignment method.
212  *
213  * @param rSrcAttr
214  * Source to assign from
215  */
216  void DoAssign(const AttributePushdownTransition& rSrcAttr);
217 
218  /**
219  * Test equality.
220  *
221  * @param rOther
222  * Other attribute to compare with.
223  */
224  bool DoEqual(const AttributePushdownTransition& rOther) const;
225 
226  /**
227  * Reads the attribute from TokenReader, see AttributeVoid for public wrappers.
228  *
229  * If the current token indicates a timing section, the method reads the guard and reset
230  * timing data from that section. Else it does nothing. Exceptions may only be thrown
231  * on invalid data within the timing section. The context argument is ignored, the
232  * label argument can be used to override the default section name Timing.
233  *
234  * @param rTr
235  * TokenReader to read from
236  * @param rLabel
237  * Section to read
238  * @param pContext
239  * Read context to provide contextual information
240  *
241  * @exception Exception
242  * - IO error (id 1)
243  */
244  virtual void DoRead(TokenReader& rTr,const std::string& rLabel="", const Type* pContext=0);
245 
246  /**
247  * Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.
248  *
249  * Writes a Timing section to include data on the guard and resets. The label argument
250  * can be used to set a section label different the the default Timing.
251  * Th context argument is ignored.
252  *
253  * @param rTw
254  * TokenWriter to write to
255  * @param rLabel
256  * Section to write
257  * @param pContext
258  * Write context to provide contextual information
259  *
260  * @exception Exception
261  * - IO error (id 2)
262  */
263  virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
264 
265  virtual void DoXWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const {DoWrite(rTw,rLabel,pContext); };
266 
267 
268 
269 }; // class AttributePushdownTransition
270 
271 /**
272  *
273  * Global attribute with stack alphabet and stack bottom.
274  *
275  * @ingroup PushdownPlugin
276  *
277  */
278 
280 
282 
283  public:
284 
285  /** Constructor */
288 
289  /**
290  * Test for default value (no stack symbols)
291  *
292  * @return
293  * True for default value
294  */
295  virtual bool IsDefault(void) const {return mStackSymbols.Empty(); };
296 
297  /** Stack Symbols */
300 
301  /** Pointer to stack symbol table */
303 
304  protected:
305 
306  /**
307  * Assignment method.
308  *
309  * @param rSrcAttr
310  * Source to assign from
311  */
312  void DoAssign(const AttributePushdownGlobal& rSrcAttr);
313 
314  /**
315  * Test equality.
316  *
317  * @param rOther
318  * Other attribute to compare with.
319  */
320  bool DoEqual(const AttributePushdownGlobal& rOther) const;
321 
322  /**
323  * Reads the attribute from TokenReader, see AttributeVoid for public wrappers.
324  *
325  * If the current token indicates a Clocks section, the method reads the global
326  * timing data from that section. Else, it does nothing. Exceptions may only be thrown
327  * on invalid data within the timing section. The context argument is ignored, the
328  * label argument can be used to override the default section name Clocks.
329  *
330  * @param rTr
331  * TokenReader to read from
332  * @param rLabel
333  * Section to read
334  * @param pContext
335  * Read context to provide contextual information
336  *
337  * @exception Exception
338  * - IO error (id 1)
339  */
340  virtual void DoRead(TokenReader& rTr,const std::string& rLabel="", const Type* pContext=0);
341 
342  /**
343  * Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.
344  *
345  * Writes a Clocks section to include global timing data. The label argument
346  * can be used to set a section label different the the default Clocks.
347  * Th context argument is ignored.
348  *
349  * @param rTw
350  * TokenWriter to write to
351  * @param rLabel
352  * Section to write
353  * @param pContext
354  * Write context to provide contextual information
355  *
356  * @exception Exception
357  * - IO error (id 2)
358  */
359  virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
360 
361  virtual void DoXWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const {DoWrite(rTw,rLabel,pContext); };
362 
363 };
364 
365 
366 
367 
368 
369 } // namespace faudes
370 
371 #endif

libFAUDES 2.24g --- 2014.09.15 --- c++ api documentaion by doxygen