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. Additionally the attribute-token can be extended to +E<IO>+ 
00223  * in oder to characterize a state as error state. 
00224  *
00225  * @ingroup iosysplugin 
00226  */
00227 
00228 class AttributeIosState : public AttributeFlags 
00229 {
00230 
00231   FAUDES_TYPE_DECLARATION(Void,AttributeIosState,AttributeFlags)
00232 
00233   public:
00234 
00235   /**
00236    * Default constructor 
00237    */
00238   AttributeIosState(void) : AttributeFlags() {
00239     mFlags=mDefIosFlags;
00240   };
00241 
00242   /** 
00243    * Copy constructor 
00244    */ 
00245   AttributeIosState(const AttributeIosState& rSrc) : AttributeFlags() { 
00246     mFlags=rSrc.mFlags;
00247   };
00248 
00249   /** 
00250    * Destructor 
00251    */
00252   virtual ~AttributeIosState(void) {};
00253 
00254   /**
00255    * Set output flag
00256    *
00257    * Note: this will clear the input flag.
00258    *
00259    */  
00260   void SetOutput(void) {
00261     mFlags |= mOutputFlag;
00262   };
00263 
00264   /**
00265    * Clear output flag
00266    *
00267    * Note: this will clear the input flag.
00268    *
00269    */  
00270   void ClrOutput(void) {
00271     mFlags &= ~mOutputFlag; 
00272   };
00273 
00274   /**
00275    * Set input flag
00276    *
00277    * Note: this will clear the output flag.
00278    *
00279    */  
00280   void SetInput(void) {
00281     mFlags |= mInputFlag;
00282   };
00283 
00284 
00285   /**
00286    * Clear input flag
00287    *
00288    * Note: this will clear the input flag.
00289    *
00290    */  
00291   void ClrInput(void) {
00292     mFlags &= ~mInputFlag; 
00293   };
00294 
00295 
00296   /**
00297    * Set error flag
00298    *
00299    */  
00300   void SetError(void) {
00301     mFlags |= mErrorFlag;
00302   };
00303 
00304 
00305   /**
00306    * Clear error flag
00307    *
00308    */  
00309   void ClrError(void) {
00310     mFlags &= ~mErrorFlag; 
00311   };
00312 
00313   /**
00314    * Test output flag
00315    *
00316    * @return
00317    *   true:  state is an output state
00318    *   false: state is not an output state
00319    */
00320   bool Output(void) const {
00321     return (mFlags & mOutputFlag) != 0 ; 
00322   };
00323 
00324      
00325   /**
00326    * Test input flag
00327    *
00328    * @return
00329    *   true:  state is an input state
00330    *   false: state is not an input state
00331    */
00332   bool Input(void) const {
00333     return (mFlags & mInputFlag) != 0; 
00334   };
00335 
00336  
00337      
00338   /**
00339    * Check error flag
00340    *
00341    * @return
00342    *   true:  state is an error state
00343    *   false: state is not an error state
00344    */
00345   bool Error(void) const {
00346     return (mFlags & mErrorFlag) != 0; 
00347   };
00348 
00349   /** 
00350    * Check a state's io-properties for default value.
00351    *
00352    * If a state has default properties, it's neither an input
00353    * nor to output state.
00354    * 
00355    * @return
00356    *   true:  event has default properties
00357    *   false: event has non-default properties
00358    */
00359   bool  IsDefault(void) const {
00360     return mFlags==mDefIosFlags;
00361   };
00362 
00363   // Flag masks for the 10 properties 
00364   const static fType mInputFlag   = 0x10;  
00365   const static fType mOutputFlag  = 0x20;  
00366   const static fType mErrorFlag   = 0x40;  
00367 
00368   /**
00369    * Write attribute to string
00370    *
00371    * @return
00372    *  string representation of attributes
00373    *
00374    */
00375   virtual std::string ToString(void) const;
00376 
00377 
00378  protected:
00379 
00380   // Overall default value
00381   const static fType mDefIosFlags = 0x00; 
00382   // All flags
00383   const static fType mAllIosFlags = 0x70;  
00384 
00385 
00386   /**
00387    * Assignment method. 
00388    *
00389    * @param rSrcAttr
00390    *    Source to assign from
00391    */
00392   void DoAssign(const AttributeIosState& rSrcAttr);
00393 
00394   /**
00395    * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
00396    * Reads a single token if it can be interpreted as IosStateFlag, that is, if
00397    * it is a respective option string or hex number. Label and Context
00398    * argument are ignored. No token mismatch exceptions are thrown on error.
00399    *
00400    * @param rTr
00401    *   TokenReader to read from
00402    * @param rLabel
00403    *   Section to read
00404    * @param pContext
00405    *   Read context to provide contextual information
00406    *
00407    * @exception Exception
00408    *   - IO error (id 1)
00409    */
00410 
00411   virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
00412  
00413   /**
00414    * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
00415    * Label and Context argument are ignored.  
00416    *
00417    * @param rTw
00418    *   TokenWriter to write to
00419    * @param rLabel
00420    *   Section to write
00421    * @param pContext
00422    *   Write context to provide contextual information
00423    *
00424    * @exception Exception
00425    *   - IO error (id 2)
00426    */
00427   virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
00428 
00429 };
00430 
00431 
00432 // convenience typedef
00433 typedef TaIndexSet<AttributeIosState> IosStateSet;
00434 
00435 
00436 
00437 
00438 
00439 }// end namespace faudes
00440 #endif

libFAUDES 2.18b --- 2010-12-17 --- c++ source docu by doxygen 1.6.3