hio_attributes.h

Go to the documentation of this file.
00001 /** @file hio_attributes.h Event and state attributes for hierarchical I/O systems */
00002 
00003 /* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006-2009  Sebastian Perk, Thomas Moor, Klaus Schmidt
00006 
00007 */
00008 
00009 
00010 #ifndef FAUDES_HIO_ATTRIBUTES_H
00011 #define FAUDES_HIO_ATTRIBUTES_H
00012 
00013 #include "corefaudes.h"
00014 
00015 
00016 namespace faudes {
00017 
00018 /******************************************************************
00019 ******************* hio Event Attribute ***************************
00020 ******************************************************************/
00021     
00022 /** 
00023  * Event attributes for hierarchical discrete event systems with inputs and outputs.
00024  * These Attributes are:
00025  *    - the input/output flag U and Y.
00026  *    - the flags C, P, E and L that designate membership in one
00027  *      or the union of more alphabets.
00028  *
00029  * @ingroup hiosysplugin  
00030  */
00031 
00032 class HioEventFlags : public AttributeFlags {
00033 
00034 FAUDES_TYPE_DECLARATION(Void,HioEventFlags,AttributeFlags)
00035 
00036  public:
00037      
00038   /** Default constructor */
00039   HioEventFlags(void) : AttributeFlags() {mFlags=mDefHioEventFlags;}
00040 
00041   /** Copy constructor */ 
00042   HioEventFlags(const HioEventFlags& rSrc) : AttributeFlags() {mFlags=rSrc.mFlags;};
00043 
00044   /* Destructor */
00045   virtual ~HioEventFlags(void) {};
00046 
00047   /**
00048    * Set Y-flag 
00049    */
00050   
00051   void SetY(void) { mFlags |= mYFlag; };
00052 
00053   /**
00054    * Clear Y-flag 
00055    */
00056 
00057   void ClrY(void) { mFlags &= ~mYFlag; };
00058 
00059   /**
00060    * Set U-flag 
00061    */
00062 
00063   void SetU(void) { mFlags |= mUFlag; };
00064   
00065   /**
00066    * Clear U-flag 
00067    */
00068 
00069   void ClrU(void) { mFlags &= ~mUFlag; };
00070      
00071   /**
00072    * Query Y-flag 
00073    */
00074 
00075   bool IsY(void) const {return ( (mFlags & mYFlag) != 0 ); }
00076      
00077   /**
00078    * Query U-flag 
00079    */
00080 
00081   bool IsU(void) const {return ( (mFlags & mUFlag) != 0 ); }
00082 
00083   /**
00084    * Set P-flag 
00085    */
00086 
00087   void SetP(void) { mFlags |= mPFlag; }
00088 
00089   /**
00090    * Clear P-flag 
00091    */
00092 
00093   void ClrP(void) { mFlags &= ~mPFlag; };
00094      
00095   /**
00096    * Query P-flag 
00097    */
00098 
00099   bool IsP(void) const {return ( (mFlags & mPFlag) != 0 ); }
00100   
00101   /**
00102    * Set E-flag 
00103    */
00104   
00105   void SetE(void) { mFlags |= mEFlag; }
00106 
00107   /**
00108    * Clear E-flag 
00109    */
00110 
00111   void ClrE(void) { mFlags &= ~mEFlag; };
00112      
00113   /**
00114    * Query E-flag 
00115    */
00116 
00117   bool IsE(void) const {return ( (mFlags & mEFlag) != 0 ); }
00118   
00119   /**
00120    * Set C-flag 
00121    */
00122   void SetC(void) { mFlags |= mCFlag; }
00123 
00124   /**
00125    * Clear C-flag 
00126    */
00127 
00128   void ClrC(void) { mFlags &= ~mCFlag; };
00129      
00130   /**
00131    * Query C-flag 
00132    */
00133 
00134   bool IsC(void) const {return ( (mFlags & mCFlag) != 0 ); }
00135   
00136 
00137   /**
00138    * Set L-flag 
00139    */
00140 
00141   void SetL(void) { mFlags |= mLFlag; }
00142 
00143   /**
00144    * Clear L-flag 
00145    */
00146 
00147   void ClrL(void) { mFlags &= ~mLFlag; };
00148      
00149   /**
00150    * Query L-flag 
00151    */
00152 
00153   bool IsL(void) const {return ( (mFlags & mLFlag) != 0 ); }
00154    
00155   /** 
00156    * Test for default value (ie input and membership in neither P-,E-,C-, nor L-alphabet)
00157    */
00158   bool  IsDefault(void) const {return mFlags==mDefHioEventFlags;};
00159 
00160   // flag masks for the event properties
00161   
00162   const static fType mUFlag              =0x04;  //0000 0100
00163   const static fType mYFlag              =0x08;  //0000 1000
00164   const static fType mPFlag              =0x10;  //0001 0000
00165   const static fType mEFlag              =0x20;  //0010 0000
00166   const static fType mCFlag              =0x40;  //0100 0000
00167   const static fType mLFlag              =0x80;  //1000 0000
00168   
00169  private:
00170   // overall default value
00171   const static fType mDefHioEventFlags        =0x00 ; // 0000 0000
00172 
00173   // all flags
00174   const static fType mAllHioEventFlags        =0xFC;   // 1111 1100
00175 
00176  protected:
00177 
00178   /**
00179    * Assignment method. 
00180    *
00181    * @param rSrcAttr
00182    *    Source to assign from
00183    */
00184   void DoAssign(const HioEventFlags& rSrcAttr);
00185 
00186   /**
00187    * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
00188    * Reads a single token if it can be interpreted as HioEventFlag, that is, if
00189    * it is a respective option string or hex number. Label and Context
00190    * argument are ignored. No token mismatch exceptions are thrown on error.
00191    *
00192    * @param rTr
00193    *   TokenReader to read from
00194    * @param rLabel
00195    *   Section to read
00196    * @param pContext
00197    *   Read context to provide contextual information
00198    * @exception Exception
00199    *   - IO error (id 1)
00200    */
00201   virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
00202  
00203   /**
00204    * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
00205    * Label and Context argument are ignored.  
00206    *
00207    * @param rTw
00208    *   TokenWriter to write to
00209    * @param rLabel
00210    *   Section to write
00211    * @param pContext
00212    *   Write context to provide contextual information
00213    *
00214    * @exception Exception
00215    *   - IO error (id 2)
00216    */
00217   virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
00218 
00219 }; // class HioEventFlags
00220 
00221 /******************************************************************
00222 ******************* hio State Attribute ***************************
00223 ******************************************************************/
00224 
00225 /** 
00226  * State attributes for hierarchical discrete event systems with inputs and outputs.
00227  *    The flags are used by eg assertion functions to describe membership
00228  *    of the active events of a given state in a certain alphabet:
00229  *    - QY: only output (Y-) events are active.
00230  *    - QU: only input (U-) events are active.
00231  *    - additional flags QC,QP,QE,QL can be set/cleared to designate
00232  *      membership of the active events in the C-,P-,E-,L-alphabet,
00233  *      respectively. Membership in the union of several alphabets is
00234  *      possible by setting more than one of these flags.
00235  *    - states with active input- as well as active output-events are
00236  *      provided with the exclusive flags QYcUp, meaning that only
00237  *      events of the alphabet YC or UP are active, and QYlUe, meaning
00238  *      that only events of the alphabet YL or UE are active.
00239  *      QY,QU,QYcUp and QYlUe are exclusive by construction of  the
00240  *      Set() operations.
00241  *    - Err: with public read/write access in all hiogenerators, this
00242  *      flag enables to specify so-called "Error behaviour" that is
00243  *      typically entered after unexpected input events, for example
00244  *      malfunction of a HioPlant after faulty operator input. The flag can
00245  *      be used by the model designer; also the hio function FreeInput() uses
00246  *      this flag when extending a hio generator by error behaviour in order
00247  *      to make an input free in this generator.  Err is not bound to any formal
00248  *      definition  and does  not effect / can be combined with any of the remaining
00249  *      flags.  Hence, Err remains untouched by the functions IsIoPlant(),
00250  *      IsIoController(), IsIoEnvironment(), IsIoConstraint() and
00251  *      UpdateStateAttributes().
00252  *
00253  * @ingroup hiosysplugin 
00254  */
00255 
00256 class HioStateFlags : public AttributeFlags {
00257 
00258 FAUDES_TYPE_DECLARATION(Void,HioStateFlags,AttributeFlags)
00259 
00260  public:
00261      
00262   /**
00263    * Default constructor 
00264    */
00265   HioStateFlags(void) : AttributeFlags() {mFlags=mDefHioStateFlags;}
00266 
00267   /** Copy constructor */ 
00268   HioStateFlags(const HioStateFlags& rSrc) : AttributeFlags() {mFlags=rSrc.mFlags;};
00269 
00270   /* Destructor */
00271   virtual ~HioStateFlags(void) {};
00272 
00273   /**
00274    * Write attribute to string
00275    *
00276    * @return
00277    *  string representation of attributes
00278    *
00279    */
00280   virtual std::string ToString(void) const;
00281 
00282 
00283   /**
00284    * Set QY-state flag 
00285    */
00286   
00287   void SetQY(void) {
00288       mFlags |= mQYFlag;
00289       mFlags &= ~mQUFlag;
00290       mFlags &= ~mQYcUpFlag;
00291       mFlags &= ~mQYlUeFlag;
00292       }
00293 
00294   /**
00295    * Clear QY-state flag 
00296    */
00297 
00298   void ClrQY(void) { mFlags &= ~mQYFlag; };
00299      
00300   /**
00301    * Query QY-state flag 
00302    */
00303 
00304   bool IsQY(void) const {return ( (mFlags & mQYFlag) != 0 ); }
00305 
00306   /**
00307    * Set QU-state flag 
00308    */
00309   
00310   void SetQU(void) {
00311       mFlags |= mQUFlag;
00312       mFlags &= ~mQYFlag;
00313       mFlags &= ~mQYcUpFlag;
00314       mFlags &= ~mQYlUeFlag;
00315       }
00316 
00317   /**
00318    * Clear QU-state flag 
00319    */
00320 
00321   void ClrQU(void) { mFlags &= ~mQUFlag; };
00322      
00323   /**
00324    * Query QU-state flag 
00325    */
00326 
00327   bool IsQU(void) const {return ( (mFlags & mQUFlag) != 0 ); }
00328 
00329   /**
00330    * Set QC-state flag 
00331    */
00332   
00333   void SetQC(void) { mFlags |= mQCFlag; }
00334 
00335   /**
00336    * Clear QC-state flag 
00337    */
00338 
00339   void ClrQC(void) { mFlags &= ~mQCFlag; };
00340      
00341   /**
00342    * Query QC-state flag 
00343    */
00344 
00345   bool IsQC(void) const {return ( (mFlags & mQCFlag) != 0 ); }
00346 
00347   /**
00348    * Set QP-state flag 
00349    */
00350   
00351   void SetQP(void) { mFlags |= mQPFlag; }
00352 
00353   /**
00354    * Clear QP-state flag 
00355    */
00356 
00357   void ClrQP(void) { mFlags &= ~mQPFlag; };
00358      
00359   /**
00360    * Query QP-state flag 
00361    */
00362 
00363   bool IsQP(void) const {return ( (mFlags & mQPFlag) != 0 ); }
00364 
00365   /**
00366    * Set QE-state flag 
00367    */
00368   
00369   void SetQE(void) { mFlags |= mQEFlag; }
00370 
00371   /**
00372    * Clear QE-state flag 
00373    */
00374 
00375   void ClrQE(void) { mFlags &= ~mQEFlag; };
00376      
00377   /**
00378    * Query QE-state flag 
00379    */
00380 
00381   bool IsQE(void) const {return ( (mFlags & mQEFlag) != 0 ); }
00382   
00383   /**
00384    * Set QL-state flag 
00385    */
00386   
00387   void SetQL(void) { mFlags |= mQLFlag; }
00388 
00389   /**
00390    * Clear QL-state flag 
00391    */
00392 
00393   void ClrQL(void) { mFlags &= ~mQLFlag; };
00394      
00395   /**
00396    * Query QL-state flag 
00397    */
00398 
00399   bool IsQL(void) const {return ( (mFlags & mQLFlag) != 0 ); }
00400 
00401   /**
00402    * Set QYcUp-state flag 
00403    */
00404   
00405   void SetQYcUp(void) {
00406       mFlags |= mQYcUpFlag;
00407       mFlags &= ~mQYFlag;
00408       mFlags &= ~mQUFlag;
00409       mFlags &= ~mQYlUeFlag;
00410       }
00411 
00412   /**
00413    * Clear QYcUp-state flag 
00414    */
00415 
00416   void ClrQYcUp(void) { mFlags &= ~mQYcUpFlag; };
00417      
00418   /**
00419    * Query QYcUp-state flag 
00420    */
00421 
00422   bool IsQYcUp(void) const {return ( (mFlags & mQYcUpFlag) != 0 ); }
00423 
00424   /**
00425    * Set QYlUe-state flag 
00426    */
00427   
00428   void SetQYlUe(void) {
00429       mFlags |= mQYlUeFlag;
00430       mFlags &= ~mQYFlag;
00431       mFlags &= ~mQUFlag;
00432       mFlags &= ~mQYcUpFlag;
00433       }
00434 
00435   /**
00436    * Clear QYlUe-state flag 
00437    */
00438 
00439   void ClrQYlUe(void) { mFlags &= ~mQYlUeFlag; };
00440      
00441   /**
00442    * Query QYlUe-state flag 
00443    */
00444 
00445   bool IsQYlUe(void) const {return ( (mFlags & mQYlUeFlag) != 0 ); }
00446 
00447   /**
00448    * Set Err-state flag 
00449    */
00450   
00451   void SetErr(void) { mFlags |= mErrFlag; }
00452 
00453   /**
00454    * Clear Err-state flag 
00455    */
00456 
00457   void ClrErr(void) { mFlags &= ~mErrFlag; };
00458      
00459   /**
00460    * Query Err-state flag 
00461    */
00462 
00463   bool IsErr(void) const {return ( (mFlags & mErrFlag) != 0 ); }
00464   
00465   /** 
00466    * Test for default value
00467    */
00468   bool  IsDefault(void) const {return mFlags==mDefHioStateFlags;};
00469 
00470   // Flag masks for the 10 properties
00471   
00472   const static fType mQYFlag     =0x01;  //0000 0000 0001
00473   const static fType mQUFlag     =0x02;  //0000 0000 0010
00474   const static fType mQCFlag     =0x04;  //0000 0000 0100
00475   const static fType mQPFlag     =0x08;  //0000 0000 1000
00476   const static fType mQEFlag     =0x10;  //0000 0001 0000
00477   const static fType mQLFlag     =0x20;  //0000 0010 0000
00478   const static fType mQYcUpFlag  =0x40;  //0000 0100 0000
00479   const static fType mQYlUeFlag  =0x80;  //0000 1000 0000
00480   const static fType mErrFlag   =0x100;  //0001 0000 0000
00481 
00482  private:
00483   // Overall default value
00484   const static fType mDefHioStateFlags      =0x000 ; //0000 0000
00485 
00486   // All flags
00487   const static fType mAllHioStateFlags      =0x1FF;  //1 1111 1111
00488 
00489  protected:
00490 
00491   /**
00492    * Assignment method. 
00493    *
00494    * @param rSrcAttr
00495    *    Source to assign from
00496    */
00497   void DoAssign(const HioStateFlags& rSrcAttr);
00498 
00499   /**
00500    * Reads attribute from TokenReader, see AttributeVoid for public wrappers.
00501    * Reads a single token if it can be interpreted as HioStateFlag, that is, if
00502    * it is a respective option string or hex number. Label and Context
00503    * argument are ignored. No token mismatch exceptions are thrown on error.
00504    *
00505    * @param rTr
00506    *   TokenReader to read from
00507    * @param rLabel
00508    *   Section to read
00509    * @param pContext
00510    *   Read context to provide contextual information
00511    *
00512    * @exception Exception
00513    *   - IO error (id 1)
00514    */
00515   virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
00516  
00517   /**
00518    * Writes attribute to TokenWriter, see AttributeVoid for public wrappers.
00519    * Label and Context argument are ignored.  
00520    *
00521    * @param rTw
00522    *   TokenWriter to write to
00523    * @param rLabel
00524    *   Section to write
00525    * @param pContext
00526    *   Write context to provide contextual information
00527    *
00528    * @exception Exception
00529    *   - IO error (id 2)
00530    */
00531   virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const;
00532 }; // class HioStateFlags
00533 
00534 
00535 } // end of namespace faudes
00536 
00537 #endif

libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen