hio_attributes.h
Go to the documentation of this file.
1 /** @file hio_attributes.h Event and state attributes for hierarchical I/O systems */
2 
3 /* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes)
4 
5  Copyright (C) 2006-2009 Sebastian Perk, Thomas Moor, Klaus Schmidt
6 
7 */
8 
9 
10 #ifndef FAUDES_HIO_ATTRIBUTES_H
11 #define FAUDES_HIO_ATTRIBUTES_H
12 
13 #include "corefaudes.h"
14 
15 
16 namespace faudes {
17 
18 /******************************************************************
19 ******************* hio Event Attribute ***************************
20 ******************************************************************/
21 
22 /**
23  * Event attributes for hierarchical discrete event systems with inputs and outputs.
24  * These Attributes are:
25  * - the input/output flag U and Y.
26  * - the flags C, P, E and L that designate membership in one
27  * or the union of more alphabets.
28  *
29  * @ingroup hiosysplugin
30  */
31 
33 
35 
36  public:
37 
38  /** Default constructor */
39  HioEventFlags(void) : AttributeFlags() {mFlags=mDefHioEventFlags;}
40 
41  /** Copy constructor */
42  HioEventFlags(const HioEventFlags& rSrc) : AttributeFlags() {mFlags=rSrc.mFlags;};
43 
44  /* Destructor */
45  virtual ~HioEventFlags(void) {};
46 
47  /**
48  * Set Y-flag
49  */
50 
51  void SetY(void) { mFlags |= mYFlag; };
52 
53  /**
54  * Clear Y-flag
55  */
56 
57  void ClrY(void) { mFlags &= ~mYFlag; };
58 
59  /**
60  * Set U-flag
61  */
62 
63  void SetU(void) { mFlags |= mUFlag; };
64 
65  /**
66  * Clear U-flag
67  */
68 
69  void ClrU(void) { mFlags &= ~mUFlag; };
70 
71  /**
72  * Query Y-flag
73  */
74 
75  bool IsY(void) const {return ( (mFlags & mYFlag) != 0 ); }
76 
77  /**
78  * Query U-flag
79  */
80 
81  bool IsU(void) const {return ( (mFlags & mUFlag) != 0 ); }
82 
83  /**
84  * Set P-flag
85  */
86 
87  void SetP(void) { mFlags |= mPFlag; }
88 
89  /**
90  * Clear P-flag
91  */
92 
93  void ClrP(void) { mFlags &= ~mPFlag; };
94 
95  /**
96  * Query P-flag
97  */
98 
99  bool IsP(void) const {return ( (mFlags & mPFlag) != 0 ); }
100 
101  /**
102  * Set E-flag
103  */
104 
105  void SetE(void) { mFlags |= mEFlag; }
106 
107  /**
108  * Clear E-flag
109  */
110 
111  void ClrE(void) { mFlags &= ~mEFlag; };
112 
113  /**
114  * Query E-flag
115  */
116 
117  bool IsE(void) const {return ( (mFlags & mEFlag) != 0 ); }
118 
119  /**
120  * Set C-flag
121  */
122  void SetC(void) { mFlags |= mCFlag; }
123 
124  /**
125  * Clear C-flag
126  */
127 
128  void ClrC(void) { mFlags &= ~mCFlag; };
129 
130  /**
131  * Query C-flag
132  */
133 
134  bool IsC(void) const {return ( (mFlags & mCFlag) != 0 ); }
135 
136 
137  /**
138  * Set L-flag
139  */
140 
141  void SetL(void) { mFlags |= mLFlag; }
142 
143  /**
144  * Clear L-flag
145  */
146 
147  void ClrL(void) { mFlags &= ~mLFlag; };
148 
149  /**
150  * Query L-flag
151  */
152 
153  bool IsL(void) const {return ( (mFlags & mLFlag) != 0 ); }
154 
155  /**
156  * Test for default value (ie input and membership in neither P-,E-,C-, nor L-alphabet)
157  */
158  bool IsDefault(void) const {return mFlags==mDefHioEventFlags;};
159 
160  // flag masks for the event properties
161 
162  const static fType mUFlag =0x04; //0000 0100
163  const static fType mYFlag =0x08; //0000 1000
164  const static fType mPFlag =0x10; //0001 0000
165  const static fType mEFlag =0x20; //0010 0000
166  const static fType mCFlag =0x40; //0100 0000
167  const static fType mLFlag =0x80; //1000 0000
168 
169  private:
170  // overall default value
171  const static fType mDefHioEventFlags =0x00 ; // 0000 0000
172 
173  // all flags
174  const static fType mAllHioEventFlags =0xFC; // 1111 1100
175 
176  protected:
177 
178  /**
179  * Assignment method.
180  *
181  * @param rSrcAttr
182  * Source to assign from
183  */
184  void DoAssign(const HioEventFlags& rSrcAttr);
185 
186  /**
187  * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
188  * Reads a single token if it can be interpreted as HioEventFlag, that is, if
189  * it is a respective option string or hex number. Label and Context
190  * argument are ignored. No token mismatch exceptions are thrown on error.
191  *
192  * @param rTr
193  * TokenReader to read from
194  * @param rLabel
195  * Section to read
196  * @param pContext
197  * Read context to provide contextual information
198  * @exception Exception
199  * - IO error (id 1)
200  */
201  virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
202 
203  /**
204  * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
205  * Label and Context argument are ignored.
206  *
207  * @param rTw
208  * TokenWriter to write to
209  * @param rLabel
210  * Section to write
211  * @param pContext
212  * Write context to provide contextual information
213  *
214  * @exception Exception
215  * - IO error (id 2)
216  */
217  virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
218 
219 }; // class HioEventFlags
220 
221 /******************************************************************
222 ******************* hio State Attribute ***************************
223 ******************************************************************/
224 
225 /**
226  * State attributes for hierarchical discrete event systems with inputs and outputs.
227  * The flags are used by eg assertion functions to describe membership
228  * of the active events of a given state in a certain alphabet:
229  * - QY: only output (Y-) events are active.
230  * - QU: only input (U-) events are active.
231  * - additional flags QC,QP,QE,QL can be set/cleared to designate
232  * membership of the active events in the C-,P-,E-,L-alphabet,
233  * respectively. Membership in the union of several alphabets is
234  * possible by setting more than one of these flags.
235  * - states with active input- as well as active output-events are
236  * provided with the exclusive flags QYcUp, meaning that only
237  * events of the alphabet YC or UP are active, and QYlUe, meaning
238  * that only events of the alphabet YL or UE are active.
239  * QY,QU,QYcUp and QYlUe are exclusive by construction of the
240  * Set() operations.
241  * - Err: with public read/write access in all hiogenerators, this
242  * flag enables to specify so-called "Error behaviour" that is
243  * typically entered after unexpected input events, for example
244  * malfunction of a HioPlant after faulty operator input. The flag can
245  * be used by the model designer; also the hio function FreeInput() uses
246  * this flag when extending a hio generator by error behaviour in order
247  * to make an input free in this generator. Err is not bound to any formal
248  * definition and does not effect / can be combined with any of the remaining
249  * flags. Hence, Err remains untouched by the functions IsIoPlant(),
250  * IsIoController(), IsIoEnvironment(), IsIoConstraint() and
251  * UpdateStateAttributes().
252  *
253  * @ingroup hiosysplugin
254  */
255 
257 
259 
260  public:
261 
262  /**
263  * Default constructor
264  */
265  HioStateFlags(void) : AttributeFlags() {mFlags=mDefHioStateFlags;}
266 
267  /** Copy constructor */
268  HioStateFlags(const HioStateFlags& rSrc) : AttributeFlags() {mFlags=rSrc.mFlags;};
269 
270  /* Destructor */
271  virtual ~HioStateFlags(void) {};
272 
273  /**
274  * Write attribute to string
275  *
276  * @return
277  * string representation of attributes
278  *
279  */
280  virtual std::string ToString(void) const;
281 
282 
283  /**
284  * Set QY-state flag
285  */
286 
287  void SetQY(void) {
288  mFlags |= mQYFlag;
289  mFlags &= ~mQUFlag;
290  mFlags &= ~mQYcUpFlag;
291  mFlags &= ~mQYlUeFlag;
292  }
293 
294  /**
295  * Clear QY-state flag
296  */
297 
298  void ClrQY(void) { mFlags &= ~mQYFlag; };
299 
300  /**
301  * Query QY-state flag
302  */
303 
304  bool IsQY(void) const {return ( (mFlags & mQYFlag) != 0 ); }
305 
306  /**
307  * Set QU-state flag
308  */
309 
310  void SetQU(void) {
311  mFlags |= mQUFlag;
312  mFlags &= ~mQYFlag;
313  mFlags &= ~mQYcUpFlag;
314  mFlags &= ~mQYlUeFlag;
315  }
316 
317  /**
318  * Clear QU-state flag
319  */
320 
321  void ClrQU(void) { mFlags &= ~mQUFlag; };
322 
323  /**
324  * Query QU-state flag
325  */
326 
327  bool IsQU(void) const {return ( (mFlags & mQUFlag) != 0 ); }
328 
329  /**
330  * Set QC-state flag
331  */
332 
333  void SetQC(void) { mFlags |= mQCFlag; }
334 
335  /**
336  * Clear QC-state flag
337  */
338 
339  void ClrQC(void) { mFlags &= ~mQCFlag; };
340 
341  /**
342  * Query QC-state flag
343  */
344 
345  bool IsQC(void) const {return ( (mFlags & mQCFlag) != 0 ); }
346 
347  /**
348  * Set QP-state flag
349  */
350 
351  void SetQP(void) { mFlags |= mQPFlag; }
352 
353  /**
354  * Clear QP-state flag
355  */
356 
357  void ClrQP(void) { mFlags &= ~mQPFlag; };
358 
359  /**
360  * Query QP-state flag
361  */
362 
363  bool IsQP(void) const {return ( (mFlags & mQPFlag) != 0 ); }
364 
365  /**
366  * Set QE-state flag
367  */
368 
369  void SetQE(void) { mFlags |= mQEFlag; }
370 
371  /**
372  * Clear QE-state flag
373  */
374 
375  void ClrQE(void) { mFlags &= ~mQEFlag; };
376 
377  /**
378  * Query QE-state flag
379  */
380 
381  bool IsQE(void) const {return ( (mFlags & mQEFlag) != 0 ); }
382 
383  /**
384  * Set QL-state flag
385  */
386 
387  void SetQL(void) { mFlags |= mQLFlag; }
388 
389  /**
390  * Clear QL-state flag
391  */
392 
393  void ClrQL(void) { mFlags &= ~mQLFlag; };
394 
395  /**
396  * Query QL-state flag
397  */
398 
399  bool IsQL(void) const {return ( (mFlags & mQLFlag) != 0 ); }
400 
401  /**
402  * Set QYcUp-state flag
403  */
404 
405  void SetQYcUp(void) {
406  mFlags |= mQYcUpFlag;
407  mFlags &= ~mQYFlag;
408  mFlags &= ~mQUFlag;
409  mFlags &= ~mQYlUeFlag;
410  }
411 
412  /**
413  * Clear QYcUp-state flag
414  */
415 
416  void ClrQYcUp(void) { mFlags &= ~mQYcUpFlag; };
417 
418  /**
419  * Query QYcUp-state flag
420  */
421 
422  bool IsQYcUp(void) const {return ( (mFlags & mQYcUpFlag) != 0 ); }
423 
424  /**
425  * Set QYlUe-state flag
426  */
427 
428  void SetQYlUe(void) {
429  mFlags |= mQYlUeFlag;
430  mFlags &= ~mQYFlag;
431  mFlags &= ~mQUFlag;
432  mFlags &= ~mQYcUpFlag;
433  }
434 
435  /**
436  * Clear QYlUe-state flag
437  */
438 
439  void ClrQYlUe(void) { mFlags &= ~mQYlUeFlag; };
440 
441  /**
442  * Query QYlUe-state flag
443  */
444 
445  bool IsQYlUe(void) const {return ( (mFlags & mQYlUeFlag) != 0 ); }
446 
447  /**
448  * Set Err-state flag
449  */
450 
451  void SetErr(void) { mFlags |= mErrFlag; }
452 
453  /**
454  * Clear Err-state flag
455  */
456 
457  void ClrErr(void) { mFlags &= ~mErrFlag; };
458 
459  /**
460  * Query Err-state flag
461  */
462 
463  bool IsErr(void) const {return ( (mFlags & mErrFlag) != 0 ); }
464 
465  /**
466  * Test for default value
467  */
468  bool IsDefault(void) const {return mFlags==mDefHioStateFlags;};
469 
470  // Flag masks for the 10 properties
471 
472  const static fType mQYFlag =0x01; //0000 0000 0001
473  const static fType mQUFlag =0x02; //0000 0000 0010
474  const static fType mQCFlag =0x04; //0000 0000 0100
475  const static fType mQPFlag =0x08; //0000 0000 1000
476  const static fType mQEFlag =0x10; //0000 0001 0000
477  const static fType mQLFlag =0x20; //0000 0010 0000
478  const static fType mQYcUpFlag =0x40; //0000 0100 0000
479  const static fType mQYlUeFlag =0x80; //0000 1000 0000
480  const static fType mErrFlag =0x100; //0001 0000 0000
481 
482  private:
483  // Overall default value
484  const static fType mDefHioStateFlags =0x000 ; //0000 0000
485 
486  // All flags
487  const static fType mAllHioStateFlags =0x1FF; //1 1111 1111
488 
489  protected:
490 
491  /**
492  * Assignment method.
493  *
494  * @param rSrcAttr
495  * Source to assign from
496  */
497  void DoAssign(const HioStateFlags& rSrcAttr);
498 
499  /**
500  * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
501  * Reads a single token if it can be interpreted as HioStateFlag, that is, if
502  * it is a respective option string or hex number. Label and Context
503  * argument are ignored. No token mismatch exceptions are thrown on error.
504  *
505  * @param rTr
506  * TokenReader to read from
507  * @param rLabel
508  * Section to read
509  * @param pContext
510  * Read context to provide contextual information
511  *
512  * @exception Exception
513  * - IO error (id 1)
514  */
515  virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
516 
517  /**
518  * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
519  * Label and Context argument are ignored.
520  *
521  * @param rTw
522  * TokenWriter to write to
523  * @param rLabel
524  * Section to write
525  * @param pContext
526  * Write context to provide contextual information
527  *
528  * @exception Exception
529  * - IO error (id 2)
530  */
531  virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
532 }; // class HioStateFlags
533 
534 
535 } // end of namespace faudes
536 
537 #endif
#define FAUDES_API
Interface export/import symbols: windows.
Definition: cfl_platform.h:81
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
faudes type declaration macro
Definition: cfl_types.h:867
Boolean flags Attribute.
fType mFlags
Flags (public access for convenience)
Event attributes for hierarchical discrete event systems with inputs and outputs.
virtual ~HioEventFlags(void)
void SetU(void)
Set U-flag.
void ClrE(void)
Clear E-flag.
void ClrL(void)
Clear L-flag.
void SetP(void)
Set P-flag.
HioEventFlags(void)
Default constructor.
void ClrC(void)
Clear C-flag.
bool IsL(void) const
Query L-flag.
void SetC(void)
Set C-flag.
void ClrU(void)
Clear U-flag.
void SetE(void)
Set E-flag.
HioEventFlags(const HioEventFlags &rSrc)
Copy constructor.
void SetY(void)
Set Y-flag.
bool IsC(void) const
Query C-flag.
bool IsY(void) const
Query Y-flag.
bool IsP(void) const
Query P-flag.
bool IsU(void) const
Query U-flag.
void SetL(void)
Set L-flag.
bool IsDefault(void) const
Test for default value (ie input and membership in neither P-,E-,C-, nor L-alphabet)
bool IsE(void) const
Query E-flag.
void ClrP(void)
Clear P-flag.
void ClrY(void)
Clear Y-flag.
State attributes for hierarchical discrete event systems with inputs and outputs.
HioStateFlags(const HioStateFlags &rSrc)
Copy constructor.
bool IsQE(void) const
Query QE-state flag.
void ClrQL(void)
Clear QL-state flag.
void ClrQP(void)
Clear QP-state flag.
void SetQU(void)
Set QU-state flag.
void ClrQC(void)
Clear QC-state flag.
void SetQYlUe(void)
Set QYlUe-state flag.
void ClrQE(void)
Clear QE-state flag.
HioStateFlags(void)
Default constructor.
bool IsQC(void) const
Query QC-state flag.
virtual ~HioStateFlags(void)
bool IsQP(void) const
Query QP-state flag.
void SetQE(void)
Set QE-state flag.
bool IsQU(void) const
Query QU-state flag.
void SetQYcUp(void)
Set QYcUp-state flag.
bool IsQY(void) const
Query QY-state flag.
void SetErr(void)
Set Err-state flag.
bool IsQYlUe(void) const
Query QYlUe-state flag.
void SetQY(void)
Set QY-state flag.
void ClrErr(void)
Clear Err-state flag.
void ClrQU(void)
Clear QU-state flag.
void ClrQYcUp(void)
Clear QYcUp-state flag.
void SetQL(void)
Set QL-state flag.
bool IsDefault(void) const
Test for default value.
bool IsQL(void) const
Query QL-state flag.
void ClrQYlUe(void)
Clear QYlUe-state flag.
void SetQC(void)
Set QC-state flag.
void ClrQY(void)
Clear QY-state flag.
void SetQP(void)
Set QP-state flag.
bool IsErr(void) const
Query Err-state flag.
bool IsQYcUp(void) const
Query QYcUp-state flag.
A TokenReader reads sequential tokens from a file or string.
A TokenWriter writes sequential tokens to a file, a string or stdout.
Base class of all libFAUDES objects that participate in the run-time interface.
Definition: cfl_types.h:239
Includes all libFAUDES headers, no plugins.
libFAUDES resides within the namespace faudes.
unsigned long int fType
Convenience typdef flag data.

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen