tp_attributes.h

Go to the documentation of this file.
00001 /** @file tp_attributes.h  Attributes for timed automata */
00002 
00003 
00004 /* Timeplugin for FAU Discrete Event Systems Library (libfaudes)
00005 
00006 Copyright (C) 2006  Berno Schlein
00007 Copyright (C) 2007  Thomas Moor
00008 Exclusive copyright is granted to Klaus Schmidt
00009 
00010 */
00011 
00012 
00013 #ifndef FAUDES_TP_ATTRIBUTES_H
00014 #define FAUDES_TP_ATTRIBUTES_H
00015 
00016 #include "corefaudes.h"
00017 #include "tp_timeconstraint.h"
00018 
00019 namespace faudes {
00020 
00021 
00022 /** 
00023  * Transition Attribute with guard and resets. 
00024  *
00025  * @ingroup TimedPlugin  
00026  */
00027 
00028 class AttributeTimedTrans : public AttributeFlags {
00029 
00030 FAUDES_TYPE_DECLARATION(Void,AttributeTimedTrans,AttributeFlags)
00031 
00032  public:
00033 
00034   /** Constructor */
00035   AttributeTimedTrans(void) : AttributeFlags() { mGuard.Name("Guard"); mResets.Name("Resets"); };
00036 
00037   /** 
00038    * Test for default value (ie empty constraint and default flags)
00039    *
00040    * @return
00041    *  True for default value
00042    */
00043   virtual bool  IsDefault(void) const {return mGuard.Empty() && mResets.Empty() && AttributeFlags::IsDefault(); };
00044 
00045   /** Guard  */
00046   TimeConstraint mGuard;
00047 
00048   /** Resets */
00049   ClockSet mResets;
00050 
00051  protected:
00052 
00053   /**
00054    * Assignment method. 
00055    *
00056    * @param rSrcAttr
00057    *    Source to assign from
00058    */
00059   void DoAssign(const AttributeTimedTrans& rSrcAttr);
00060 
00061   /**
00062    * Test eaulity. 
00063    *
00064    * @param rOther
00065    *    Other attribute to compare with.
00066    */
00067   bool DoEqual(const AttributeTimedTrans& rOther) const;
00068 
00069   /**
00070    * Reads the attribute from TokenReader, see AttributeVoid for public wrappers.
00071    * 
00072    * If the current token indicates a timing section, the method reads the guard and reset 
00073    * timing data from that section. Else it does nothing. Exceptions may only be thrown
00074    * on invalid data within the timing section. The context argument is ignored, the
00075    * label argument can be used to override the default section name Timing.
00076    *
00077    * @param rTr
00078    *   TokenReader to read from
00079    * @param rLabel
00080    *   Section to read
00081    * @param pContext
00082    *   Read context to provide contextual information
00083    *
00084    * @exception Exception
00085    *   - IO error (id 1)
00086    */
00087   virtual void DoRead(TokenReader& rTr,const std::string& rLabel="", const Type* pContext=0);
00088  
00089   /**
00090    * Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.
00091    *
00092    * Writes a Timing section to include data on the guard and resets. The label argument
00093    * can be used to set a section label different the the default Timing. 
00094    * Th context argument is ignored.  
00095    *
00096    * @param rTw
00097    *   TokenWriter to write to
00098    * @param rLabel
00099    *   Section to write
00100    * @param pContext
00101    *   Write context to provide contextual information
00102    *
00103    * @exception Exception
00104    *   - IO error (id 2)
00105    */
00106   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
00107 
00108 
00109 
00110 }; // class AttributeTimedTrans
00111 
00112 
00113 /**
00114  * 
00115  * State attribute with invariant.
00116  *
00117  * @ingroup TimedPlugin  
00118  *
00119  */
00120 
00121 class AttributeTimedState : public AttributeFlags {
00122 
00123 FAUDES_TYPE_DECLARATION(Void,AttributeTimedState,AttributeFlags)
00124 
00125  public:
00126 
00127   /** Constructor */
00128   AttributeTimedState(void) : AttributeFlags() { mInvariant.Name("Invariant"); };
00129 
00130   /** 
00131    * Test for default value (ie empty invariant and default flags)
00132    *
00133    * @return
00134    *  True for default value
00135    */
00136   virtual bool IsDefault(void) const {return mInvariant.Empty() && AttributeFlags::IsDefault(); };
00137 
00138   /** Invariant  */
00139   TimeConstraint mInvariant;
00140  
00141  protected:
00142 
00143 
00144   /**
00145    * Assignment method. 
00146    *
00147    * @param rSrcAttr
00148    *    Source to assign from
00149    */
00150   void DoAssign(const AttributeTimedState& rSrcAttr);
00151 
00152 
00153   /**
00154    * Test eaulity. 
00155    *
00156    * @param rOther
00157    *    Other attribute to compare with.
00158    */
00159   bool DoEqual(const AttributeTimedState& rOther) const;
00160 
00161   /**
00162    * Reads the attribute from TokenReader, see AttributeVoid for public wrappers.
00163    * 
00164    * If the current token indicates a invariant section, the method reads the invariant
00165    * from that section. Else, it does nothing. Exceptions may only be thrown
00166    * on invalid data within the timing section. The context argument is ignored, the
00167    * label argument can be used to override the default section name Invariant.
00168    *
00169    * @param rTr
00170    *   TokenReader to read from
00171    * @param rLabel
00172    *   Section to read
00173    * @param pContext
00174    *   Read context to provide contextual information
00175    *
00176    * @exception Exception
00177    *   - IO error (id 1)
00178    */
00179   virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0);
00180  
00181   /**
00182    * Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.
00183    *
00184    * Writes am Invariant section to include data on the invariant. The label argument
00185    * can be used to set a section label different the the default Invariant. 
00186    * Th context argument is ignored.  
00187    *
00188    * @param rTw
00189    *   TokenWriter to write to
00190    * @param rLabel
00191    *   Section to write
00192    * @param pContext
00193    *   Write context to provide contextual information
00194    *
00195    * @exception Exception
00196    *   - IO error (id 2)
00197    */
00198   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
00199 
00200 
00201 }; // class AttributeTimedState
00202 
00203 
00204 /**
00205  *
00206  * Globat attribute with clockset.
00207  *
00208  * @ingroup TimedPlugin  
00209  *
00210  */
00211 
00212 class AttributeTimedGlobal : public AttributeVoid {
00213 
00214 FAUDES_TYPE_DECLARATION(Void,AttributeTimedGlobal,AttributeVoid)
00215 
00216  public:
00217 
00218   /** Constructor */
00219   AttributeTimedGlobal(void) {
00220     mpClockSymbolTable=mClocks.SymbolTablep(); };
00221 
00222   /** 
00223    * Test for default value (ie empty clockset)
00224    *
00225    * @return
00226    *  True for default value
00227    */
00228   virtual bool IsDefault(void) const {return mClocks.Empty(); };
00229 
00230   /** Clocks */
00231   ClockSet mClocks;
00232 
00233   /** Pointer to clock symboltable */
00234   SymbolTable* mpClockSymbolTable;
00235 
00236  protected:
00237 
00238   /**
00239    * Assignment method. 
00240    *
00241    * @param rSrcAttr
00242    *    Source to assign from
00243    */
00244   void DoAssign(const AttributeTimedGlobal& rSrcAttr);
00245 
00246   /**
00247    * Test eaulity. 
00248    *
00249    * @param rOther
00250    *    Other attribute to compare with.
00251    */
00252   bool DoEqual(const AttributeTimedGlobal& rOther) const;
00253 
00254   /**
00255    * Reads the attribute from TokenReader, see AttributeVoid for public wrappers.
00256    * 
00257    * If the current token indicates a Clocks section, the method reads the global
00258    * timing data from that section. Else, it does nothing. Exceptions may only be thrown
00259    * on invalid data within the timing section. The context argument is ignored, the
00260    * label argument can be used to override the default section name Clocks.
00261    *
00262    * @param rTr
00263    *   TokenReader to read from
00264    * @param rLabel
00265    *   Section to read
00266    * @param pContext
00267    *   Read context to provide contextual information
00268    *
00269    * @exception Exception
00270    *   - IO error (id 1)
00271    */
00272   virtual void DoRead(TokenReader& rTr,const std::string& rLabel="", const Type* pContext=0);
00273  
00274   /**
00275    * Writes the attribute to TokenWriter, see AttributeVoid for public wrappers.
00276    *
00277    * Writes a Clocks section to include global timing data. The label argument
00278    * can be used to set a section label different the the default Clocks. 
00279    * Th context argument is ignored.  
00280    *
00281    * @param rTw
00282    *   TokenWriter to write to
00283    * @param rLabel
00284    *   Section to write
00285    * @param pContext
00286    *   Write context to provide contextual information
00287    *
00288    * @exception Exception
00289    *   - IO error (id 2)
00290    */
00291   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="", const Type* pContext=0) const;
00292 
00293 
00294 
00295 
00296 }; // class AttributeTimedGlobal
00297 
00298 
00299 } // namespace faudes
00300 
00301 #endif

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