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

libFAUDES 2.28c --- 2016.09.30 --- c++ api documentaion by doxygen