About
User Reference
C++ API
luafaudes
Developer
Links
libFAUDES online
libFAUDES

Sections

Index

ios_attributes.h

Go to the documentation of this file.
00001 /** @file ios_attributes.h I/O-system attributes */
00002 
00003 /* 
00004    IO Systems Plug-In 
00005    for FAU Discrete Event Systems Library (libFAUDES)
00006 
00007    Copyright (C) 2010, Thomas Wittmann, Thomas Moor
00008 
00009 */
00010 
00011 #ifndef FAUDES_IOS_ATTRIBUTES_H
00012 #define FAUDES_IOS_ATTRIBUTES_H
00013 
00014 // debugging: 
00015 #ifdef FAUDES_DEBUG_IOSYS
00016 #define FD_DIO(message) FAUDES_WRITE_CONSOLE("FAUDES_IOSYS: " << message)
00017 #else
00018 #define FD_DIO(message)
00019 #endif
00020 
00021 #include "corefaudes.h"
00022 
00023 namespace faudes {
00024 
00025     
00026 /** 
00027  * Attributes for events in DES with in- and outputs
00028  * 
00029  * The class AttributeIosEvent holds a bitarray to handle an event's io-properties 
00030  *
00031  * In order to envolve the event's io-properties during file-io 
00032  * the DoRead/DoWrite methods were overwritten. Use Attributes
00033  * +I+ and +O+ in .gen file to make sure an event will be inserted in
00034  * Iput or OTput event set.
00035  *
00036  * @ingroup iosysplugin  
00037  */
00038 
00039 class AttributeIosEvent : public AttributeFlags {
00040 
00041 FAUDES_TYPE_DECLARATION(Void,AttributeIosEvent,AttributeFlags )
00042 
00043   public:
00044   
00045    
00046   /** 
00047    *  Default constructor 
00048    */
00049   AttributeIosEvent(void) : AttributeFlags() {
00050       mFlags=mDefAttributeIosEvent;
00051   }
00052 
00053   /** 
00054    *  Copy constructor 
00055    */ 
00056   AttributeIosEvent(const AttributeIosEvent& rSrc) : AttributeFlags()  {
00057       mFlags=rSrc.mFlags;
00058   };
00059 
00060   /** 
00061    *  Destructor 
00062    */
00063   virtual ~AttributeIosEvent(void) {
00064   };
00065 
00066   /**
00067    * Set output flag
00068    *
00069    * Note: this will clear the input flag.
00070    *
00071    */  
00072   void SetOutput(void) {
00073     mFlags |= mOutputFlag;
00074   }
00075 
00076   /**
00077    * Clear output flag
00078    *
00079    * Note: this will clear the input flag.
00080    *
00081    */  
00082   void ClrOutput(void) {
00083     mFlags &= ~mOutputFlag; 
00084   };
00085 
00086   /**
00087    * Set input flag
00088    *
00089    * Note: this will clear the output flag.
00090    *
00091    */  
00092   void SetInput(void) {
00093     mFlags |= mInputFlag;
00094   }
00095 
00096 
00097   /**
00098    * Clear input flag
00099    *
00100    * Note: this will clear the input flag.
00101    *
00102    */  
00103   void ClrInput(void) {
00104     mFlags &= ~mInputFlag; 
00105   };
00106 
00107   /**
00108    * Test output flag
00109    *
00110    * @return
00111    *   true:  state is an output state
00112    *   false: state is not an output state
00113    */
00114   bool Output(void) const {
00115     return (mFlags & mOutputFlag) != 0 ; 
00116   }
00117 
00118      
00119   /**
00120    * Test input flag
00121    *
00122    * @return
00123    *   true:  state is an input state
00124    *   false: state is not an input state
00125    */
00126   bool Input(void) const {
00127     return (mFlags & mInputFlag) != 0; 
00128   }
00129 
00130  
00131      
00132   /** 
00133    * Check an event's io-properties for default value.
00134    *
00135    * If an event has default properties, it's wether an input
00136    * nor to output event.
00137    * 
00138    * @return
00139    *   true:  event has default properties
00140    *   false: event has non-default properties
00141    */
00142   bool  IsDefault(void) const {
00143         return mFlags==mDefAttributeIosEvent;
00144   }
00145 
00146  protected:
00147 
00148   // flag masks for the event properties
00149   const static fType mInputFlag =0x010;  
00150   const static fType mOutputFlag =0x020; 
00151    
00152   // overall default value
00153   const static fType mDefAttributeIosEvent        =0x000 ; 
00154 
00155   // all flags
00156   const static fType mAllAttributeIosEvent        =0x030; 
00157 
00158 
00159   /**
00160    * Assignment method. 
00161    *
00162    * @param rSrcAttr
00163    *    Source to assign from
00164    */
00165   void DoAssign(const AttributeIosEvent& rSrcAttr);
00166 
00167 
00168   /**
00169    * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
00170    * Reads a single token if it can be interpreted as IosEventFlag, that is, if
00171    * it is a respective option string or hex number. Label and Context
00172    * argument are ignored. No token mismatch exceptions are thrown on error.
00173    *
00174    * @param rTr
00175    *   TokenReader to read from
00176    * @param rLabel
00177    *   Section to read
00178    * @param pContext
00179    *   Read context to provide contextual information
00180    * @exception Exception
00181    *   - IO error (id 1)
00182    */
00183   virtual void DoRead(TokenReader& rTr, 
00184           const std::string& rLabel="", 
00185           const Type* pContext=0);
00186  
00187   /**
00188    * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
00189    * Label and Context argument are ignored.  
00190    *
00191    * @param rTw
00192    *   TokenWriter to write to
00193    * @param rLabel
00194    *   Section to write
00195    * @param pContext
00196    *   Write context to provide contextual information
00197    *
00198    * @exception Exception
00199    *   - IO error (id 2)
00200    */
00201   virtual void DoWrite(TokenWriter& rTw,
00202            const std::string& rLabel="", 
00203            const Type* pContext=0) const;
00204 
00205 }; // class AttributeIosEvent
00206 
00207 
00208 // Convenience typedef
00209 typedef TaNameSet<AttributeIosEvent> IosEventSet;
00210 
00211 
00212 
00213 /** 
00214  * Attributes for states in DESs with in- and outputs 
00215  *
00216  * The class AttributeIosState holds a bitarray to handle a state's io-properties.
00217  * A state is said to be an in- or output state if the set of active events
00218  * contains only in- or output events.
00219  *
00220  * In order to envolve the state's io-properties during file-io
00221  * the DoRead/DoWrite methods were overwritten. Use +I+ for input, +O+ for 
00222  * output states. 
00223  *
00224  * @ingroup iosysplugin 
00225  */
00226 
00227 class AttributeIosState : public AttributeFlags 
00228 {
00229 
00230   FAUDES_TYPE_DECLARATION(Void,AttributeIosState,AttributeFlags)
00231 
00232   public:
00233 
00234   /**
00235    * Default constructor 
00236    */
00237   AttributeIosState(void) : AttributeFlags() {
00238     mFlags=mDefIosFlags;
00239   };
00240 
00241   /** 
00242    * Copy constructor 
00243    */ 
00244   AttributeIosState(const AttributeIosState& rSrc) : AttributeFlags() { 
00245     mFlags=rSrc.mFlags;
00246   };
00247 
00248   /** 
00249    * Destructor 
00250    */
00251   virtual ~AttributeIosState(void) {};
00252 
00253   /**
00254    * Set output flag
00255    *
00256    * Note: this will clear the input flag.
00257    *
00258    */  
00259   void SetOutput(void) {
00260     mFlags |= mOutputFlag;
00261   };
00262 
00263   /**
00264    * Clear output flag
00265    *
00266    * Note: this will clear the input flag.
00267    *
00268    */  
00269   void ClrOutput(void) {
00270     mFlags &= ~mOutputFlag; 
00271   };
00272 
00273   /**
00274    * Set input flag
00275    *
00276    * Note: this will clear the output flag.
00277    *
00278    */  
00279   void SetInput(void) {
00280     mFlags |= mInputFlag;
00281   };
00282 
00283 
00284   /**
00285    * Clear input flag
00286    *
00287    * Note: this will clear the input flag.
00288    *
00289    */  
00290   void ClrInput(void) {
00291     mFlags &= ~mInputFlag; 
00292   };
00293 
00294 
00295   /**
00296    * Set error flag
00297    *
00298    */  
00299   void SetError(void) {
00300     mFlags |= mErrorFlag;
00301   };
00302 
00303 
00304   /**
00305    * Clear error flag
00306    *
00307    */  
00308   void ClrError(void) {
00309     mFlags &= ~mErrorFlag; 
00310   };
00311 
00312   /**
00313    * Test output flag
00314    *
00315    * @return
00316    *   true:  state is an output state
00317    *   false: state is not an output state
00318    */
00319   bool Output(void) const {
00320     return (mFlags & mOutputFlag) != 0 ; 
00321   };
00322 
00323      
00324   /**
00325    * Test input flag
00326    *
00327    * @return
00328    *   true:  state is an input state
00329    *   false: state is not an input state
00330    */
00331   bool Input(void) const {
00332     return (mFlags & mInputFlag) != 0; 
00333   };
00334 
00335  
00336      
00337   /**
00338    * Check error flag
00339    *
00340    * @return
00341    *   true:  state is an error state
00342    *   false: state is not an error state
00343    */
00344   bool Error(void) const {
00345     return (mFlags & mErrorFlag) != 0; 
00346   };
00347 
00348   /** 
00349    * Check a state's io-properties for default value.
00350    *
00351    * If a state has default properties, it's neither an input
00352    * nor to output state.
00353    * 
00354    * @return
00355    *   true:  event has default properties
00356    *   false: event has non-default properties
00357    */
00358   bool  IsDefault(void) const {
00359     return mFlags==mDefIosFlags;
00360   };
00361 
00362   // Flag masks for the 10 properties 
00363   const static fType mInputFlag   = 0x10;  
00364   const static fType mOutputFlag  = 0x20;  
00365   const static fType mErrorFlag   = 0x40;  
00366 
00367   /**
00368    * Write attribute to string
00369    *
00370    * @return
00371    *  string representation of attributes
00372    *
00373    */
00374   virtual std::string ToString(void) const;
00375 
00376 
00377  protected:
00378 
00379   // Overall default value
00380   const static fType mDefIosFlags = 0x00; 
00381   // All flags
00382   const static fType mAllIosFlags = 0x70;  
00383 
00384 
00385   /**
00386    * Assignment method. 
00387    *
00388    * @param rSrcAttr
00389    *    Source to assign from
00390    */
00391   void DoAssign(const AttributeIosState& rSrcAttr);
00392 
00393   /**
00394    * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
00395    * Reads a single token if it can be interpreted as IosStateFlag, that is, if
00396    * it is a respective option string or hex number. Label and Context
00397    * argument are ignored. No token mismatch exceptions are thrown on error.
00398    *
00399    * @param rTr
00400    *   TokenReader to read from
00401    * @param rLabel
00402    *   Section to read
00403    * @param pContext
00404    *   Read context to provide contextual information
00405    *
00406    * @exception Exception
00407    *   - IO error (id 1)
00408    */
00409 
00410   virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
00411  
00412   /**
00413    * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
00414    * Label and Context argument are ignored.  
00415    *
00416    * @param rTw
00417    *   TokenWriter to write to
00418    * @param rLabel
00419    *   Section to write
00420    * @param pContext
00421    *   Write context to provide contextual information
00422    *
00423    * @exception Exception
00424    *   - IO error (id 2)
00425    */
00426   virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
00427 
00428 };
00429 
00430 
00431 // convenience typedef
00432 typedef TaIndexSet<AttributeIosState> IosStateSet;
00433 
00434 
00435 
00436 
00437 
00438 }// end namespace faudes
00439 #endif

libFAUDES 2.20d --- 2011.04.26 --- c++ source docu by doxygen