ios_attributes.h
Go to the documentation of this file.
1 /** @file ios_attributes.h I/O-system attributes */
2 
3 /*
4  IO Systems Plug-In
5  for FAU Discrete Event Systems Library (libFAUDES)
6 
7  Copyright (C) 2010, Thomas Wittmann, Thomas Moor
8 
9 */
10 
11 #ifndef FAUDES_IOS_ATTRIBUTES_H
12 #define FAUDES_IOS_ATTRIBUTES_H
13 
14 // debugging:
15 #ifdef FAUDES_DEBUG_IOSYS
16 #define FD_DIO(message) FAUDES_WRITE_CONSOLE("FAUDES_IOSYS: " << message)
17 #else
18 #define FD_DIO(message)
19 #endif
20 
21 #include "corefaudes.h"
22 
23 namespace faudes {
24 
25 
26 /**
27  * Attributes for events in DES with in- and outputs
28  *
29  * The class AttributeIosEvent holds a bitarray to handle an event's io-properties
30  *
31  * In order to envolve the event's io-properties during file-io
32  * the DoRead/DoWrite methods were overwritten. Use Attributes
33  * +I+ and +O+ in .gen file to make sure an event will be inserted in
34  * Iput or OTput event set.
35  *
36  * @ingroup iosysplugin
37  */
38 
40 
42 
43  public:
44 
45 
46  /**
47  * Default constructor
48  */
50  mFlags=mDefIosFlags;
51  }
52 
53  /**
54  * Copy constructor
55  */
57  mFlags=rSrc.mFlags;
58  };
59 
60  /**
61  * Destructor
62  */
63  virtual ~AttributeIosEvent(void) {
64  };
65 
66  /**
67  * Set output flag
68  *
69  * Note: this will clear the input flag.
70  *
71  */
72  void SetOutput(void) {
73  mFlags |= mOutputFlag;
74  }
75 
76  /**
77  * Clear output flag
78  *
79  * Note: this will clear the input flag.
80  *
81  */
82  void ClrOutput(void) {
83  mFlags &= ~mOutputFlag;
84  };
85 
86  /**
87  * Set input flag
88  *
89  * Note: this will clear the output flag.
90  *
91  */
92  void SetInput(void) {
93  mFlags |= mInputFlag;
94  }
95 
96 
97  /**
98  * Clear input flag
99  *
100  * Note: this will clear the input flag.
101  *
102  */
103  void ClrInput(void) {
104  mFlags &= ~mInputFlag;
105  };
106 
107  /**
108  * Test output flag
109  *
110  * @return
111  * true: state is an output state
112  * false: state is not an output state
113  */
114  bool Output(void) const {
115  return (mFlags & mOutputFlag) != 0 ;
116  }
117 
118 
119  /**
120  * Test input flag
121  *
122  * @return
123  * true: state is an input state
124  * false: state is not an input state
125  */
126  bool Input(void) const {
127  return (mFlags & mInputFlag) != 0;
128  }
129 
130 
131 
132  /**
133  * Check an event's io-properties for default value.
134  *
135  * If an event has default properties, it's wether an input
136  * nor to output event.
137  *
138  * @return
139  * true: event has default properties
140  * false: event has non-default properties
141  */
142  bool IsDefault(void) const {
143  return mFlags==mDefIosFlags;
144  }
145 
146  protected:
147 
148  // flag masks for the event properties
149  const static fType mInputFlag =0x010;
150  const static fType mOutputFlag =0x020;
151 
152  // overall default value
153  const static fType mDefIosFlags =0x000 ;
154 
155  // all flags
156  const static fType mAllIosFlags =0x030;
157 
158 
159  /**
160  * Assignment method.
161  *
162  * @param rSrcAttr
163  * Source to assign from
164  */
165  void DoAssign(const AttributeIosEvent& rSrcAttr);
166 
167 
168  /**
169  * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
170  * Reads a single token if it can be interpreted as IosEventFlag, that is, if
171  * it is a respective option string or hex number. Label and Context
172  * argument are ignored. No token mismatch exceptions are thrown on error.
173  *
174  * @param rTr
175  * TokenReader to read from
176  * @param rLabel
177  * Section to read
178  * @param pContext
179  * Read context to provide contextual information
180  * @exception Exception
181  * - IO error (id 1)
182  */
183  virtual void DoRead(TokenReader& rTr,
184  const std::string& rLabel="",
185  const Type* pContext=0);
186 
187  /**
188  * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
189  * Label and Context argument are ignored.
190  *
191  * @param rTw
192  * TokenWriter to write to
193  * @param rLabel
194  * Section to write
195  * @param pContext
196  * Write context to provide contextual information
197  *
198  * @exception Exception
199  * - IO error (id 2)
200  */
201  virtual void DoWrite(TokenWriter& rTw,
202  const std::string& rLabel="",
203  const Type* pContext=0) const;
204 
205  /**
206  * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
207  * Label and Context argument are ignored.
208  *
209  * @param rTw
210  * TokenWriter to write to
211  * @param rLabel
212  * Section to write
213  * @param pContext
214  * Write context to provide contextual information
215  *
216  * @exception Exception
217  * - IO error (id 2)
218  */
219  virtual void DoXWrite(TokenWriter& rTw,
220  const std::string& rLabel="",
221  const Type* pContext=0) const;
222 
223 }; // class AttributeIosEvent
224 
225 
226 // Convenience typedef
228 
229 
230 
231 /**
232  * Attributes for states in DESs with in- and outputs
233  *
234  * The class AttributeIosState holds a bitarray to handle a state's io-properties.
235  * A state is said to be an in- or output state if the set of active events
236  * contains only in- or output events.
237  *
238  * In order to envolve the state's io-properties during file-io
239  * the DoRead/DoWrite methods were overwritten. Use +I+ for input, +O+ for
240  * output states.
241  *
242  * @ingroup iosysplugin
243  */
244 
246 {
247 
249 
250  public:
251 
252  /**
253  * Default constructor
254  */
256  mFlags=mDefIosFlags;
257  };
258 
259  /**
260  * Copy constructor
261  */
263  mFlags=rSrc.mFlags;
264  };
265 
266  /**
267  * Destructor
268  */
269  virtual ~AttributeIosState(void) {};
270 
271  /**
272  * Set output flag
273  *
274  * Note: this will clear the input flag.
275  *
276  */
277  void SetOutput(void) {
278  mFlags |= mOutputFlag;
279  };
280 
281  /**
282  * Clear output flag
283  *
284  * Note: this will clear the input flag.
285  *
286  */
287  void ClrOutput(void) {
288  mFlags &= ~mOutputFlag;
289  };
290 
291  /**
292  * Set input flag
293  *
294  * Note: this will clear the output flag.
295  *
296  */
297  void SetInput(void) {
298  mFlags |= mInputFlag;
299  };
300 
301 
302  /**
303  * Clear input flag
304  *
305  * Note: this will clear the input flag.
306  *
307  */
308  void ClrInput(void) {
309  mFlags &= ~mInputFlag;
310  };
311 
312 
313  /**
314  * Set error flag
315  *
316  */
317  void SetError(void) {
318  mFlags |= mErrorFlag;
319  };
320 
321 
322  /**
323  * Clear error flag
324  *
325  */
326  void ClrError(void) {
327  mFlags &= ~mErrorFlag;
328  };
329 
330  /**
331  * Test output flag
332  *
333  * @return
334  * true: state is an output state
335  * false: state is not an output state
336  */
337  bool Output(void) const {
338  return (mFlags & mOutputFlag) != 0 ;
339  };
340 
341 
342  /**
343  * Test input flag
344  *
345  * @return
346  * true: state is an input state
347  * false: state is not an input state
348  */
349  bool Input(void) const {
350  return (mFlags & mInputFlag) != 0;
351  };
352 
353 
354 
355  /**
356  * Check error flag
357  *
358  * @return
359  * true: state is an error state
360  * false: state is not an error state
361  */
362  bool Error(void) const {
363  return (mFlags & mErrorFlag) != 0;
364  };
365 
366  /**
367  * Check a state's io-properties for default value.
368  *
369  * If a state has default properties, it's neither an input
370  * nor to output state.
371  *
372  * @return
373  * true: event has default properties
374  * false: event has non-default properties
375  */
376  bool IsDefault(void) const {
377  return mFlags==mDefIosFlags;
378  };
379 
380  // Flag masks for the 10 properties
381  const static fType mInputFlag = 0x10;
382  const static fType mOutputFlag = 0x20;
383  const static fType mErrorFlag = 0x40;
384 
385  /**
386  * Write attribute to string
387  *
388  * @return
389  * string representation of attributes
390  *
391  */
392  virtual std::string ToString(void) const;
393 
394 
395  protected:
396 
397  // Overall default value
398  const static fType mDefIosFlags = 0x00;
399  // All flags
400  const static fType mAllIosFlags = 0x70;
401 
402 
403  /**
404  * Assignment method.
405  *
406  * @param rSrcAttr
407  * Source to assign from
408  */
409  void DoAssign(const AttributeIosState& rSrcAttr);
410 
411  /**
412  * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
413  * Reads a single token if it can be interpreted as IosStateFlag, that is, if
414  * it is a respective option string or hex number. Label and Context
415  * argument are ignored. No token mismatch exceptions are thrown on error.
416  *
417  * @param rTr
418  * TokenReader to read from
419  * @param rLabel
420  * Section to read
421  * @param pContext
422  * Read context to provide contextual information
423  *
424  * @exception Exception
425  * - IO error (id 1)
426  */
427 
428  virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
429 
430  /**
431  * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
432  * Label and Context argument are ignored.
433  *
434  * @param rTw
435  * TokenWriter to write to
436  * @param rLabel
437  * Section to write
438  * @param pContext
439  * Write context to provide contextual information
440  *
441  * @exception Exception
442  * - IO error (id 2)
443  */
444  virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
445 
446  /**
447  * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
448  * Label and Context argument are ignored.
449  *
450  * @param rTw
451  * TokenWriter to write to
452  * @param rLabel
453  * Section to write
454  * @param pContext
455  * Write context to provide contextual information
456  *
457  * @exception Exception
458  * - IO error (id 2)
459  */
460  virtual void DoXWrite(TokenWriter& rTw,
461  const std::string& rLabel="",
462  const Type* pContext=0) const;
463 
464 };
465 
466 
467 // convenience typedef
469 
470 
471 
472 
473 
474 }// end namespace faudes
475 #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)
Attributes for events in DES with in- and outputs.
void ClrInput(void)
Clear input flag.
bool IsDefault(void) const
Check an event's io-properties for default value.
void ClrOutput(void)
Clear output flag.
virtual ~AttributeIosEvent(void)
Destructor.
AttributeIosEvent(void)
Default constructor.
bool Output(void) const
Test output flag.
void SetOutput(void)
Set output flag.
void SetInput(void)
Set input flag.
bool Input(void) const
Test input flag.
AttributeIosEvent(const AttributeIosEvent &rSrc)
Copy constructor.
Attributes for states in DESs with in- and outputs.
void ClrInput(void)
Clear input flag.
AttributeIosState(void)
Default constructor.
void SetOutput(void)
Set output flag.
void SetError(void)
Set error flag.
bool IsDefault(void) const
Check a state's io-properties for default value.
AttributeIosState(const AttributeIosState &rSrc)
Copy constructor.
bool Input(void) const
Test input flag.
bool Output(void) const
Test output flag.
bool Error(void) const
Check error flag.
virtual ~AttributeIosState(void)
Destructor.
void SetInput(void)
Set input flag.
void ClrOutput(void)
Clear output flag.
void ClrError(void)
Clear error flag.
Set of indices with attributes.
Definition: cfl_indexset.h:316
Set of indices with symbolic names and attributes.
Definition: cfl_nameset.h:564
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.
TaIndexSet< AttributeIosState > IosStateSet
unsigned long int fType
Convenience typdef flag data.
TaNameSet< AttributeIosEvent > IosEventSet

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