tp_timeconstraint.h

Go to the documentation of this file.
00001 
00005 /* Timeplugin for FAU Discrete Event Systems Library (libfaudes)
00006 
00007    Copyright (C) 2006  B Schlein
00008    Copyright (C) 2007  Thomas Moor
00009    Exclusive copyright is granted to Klaus Schmidt
00010 
00011 */
00012 
00013 #ifndef FAUDES_TP_TIMECONSTRAINT_H
00014 #define FAUDES_TP_TIMECONSTRAINT_H
00015 
00016 #include "tp_timeinterval.h"
00017 #include "nameset.h"
00018 #include <list>
00019 
00020 
00021 namespace faudes {
00022 
00023 
00024 
00038 class ClockSet : public NameSet {
00039 
00040   public:
00041 
00045     ClockSet(void) { 
00046       mpSymbolTable= &msSymbolTable; NameSet::Name("Clocks"); 
00047       FD_DC("ClockSet("<<this<<")::ClockSet() with csymtab "<< SymbolTablep()); 
00048     };
00049 
00060     ClockSet(const std::string& rFilename, const std::string& rLabel = "Clocks")
00061       { mpSymbolTable= &msSymbolTable; NameSet::Read(rFilename,rLabel);};
00062 
00069     static SymbolTable* StaticSymbolTablep(void);
00070 
00071   private:
00072 
00074     static SymbolTable msSymbolTable;
00075 
00076   }; // end class ClockSet
00077 
00078 
00079 
00102 class ElemConstraint {
00103 
00104   public:
00105 
00110     typedef enum {GreaterEqual, GreaterThan, LessThan, LessEqual} Operator;
00111 
00115     static std::string OperatorName(Operator op);
00116 
00121     ElemConstraint(void);
00122 
00133     ElemConstraint(Idx clockindex, Operator op, tpTime::Type timeconst);
00134 
00145     void Set(Idx clockindex, Operator op, tpTime::Type timeconst);
00146 
00150     Idx Clock(Idx newClock);
00151 
00157     Idx Clock(void) const;
00158 
00165     void CompOperator(Operator newOp);
00166 
00171     Operator CompOperator(void) const;
00172 
00179     void TimeConstant(tpTime::Type newTimeConst);
00180 
00185     tpTime::Type TimeConstant(void) const;
00186 
00192     std::string Str(void) const;
00193 
00202     bool operator == (const ElemConstraint & otherElemConstraint) const;
00203 
00213     bool operator < (const ElemConstraint& otherElemConstraint) const;
00214 
00215 
00216   protected:
00217 
00219     Idx mClockIndex;
00220 
00222     Operator mCompOperator;
00223 
00225     tpTime::Type mTimeConstant;
00226 
00227 }; // ElemConstraint
00228 
00229 
00230 
00243 class TimeConstraint {
00244 
00245   public:
00246 
00248     typedef std::set<ElemConstraint>::const_iterator Iterator;
00249 
00251     typedef std::set<ElemConstraint>::const_reverse_iterator RIterator;
00252 
00254     typedef ElemConstraint::Operator Operator;
00255 
00259     TimeConstraint(void);
00260 
00267     TimeConstraint(const TimeConstraint& rOtherTimeConstraint);
00268 
00279     TimeConstraint(const std::string& rFilename, const std::string& rLabel = "TimeConstraint");
00280 
00284     ~TimeConstraint(void);
00285 
00286 
00293     SymbolTable* ClockSymbolTablep(void) const;
00294 
00295 
00300     void ClockSymbolTablep(SymbolTable* pSymTab);
00301 
00305     void Write(void) const;
00306 
00321     void Write(const std::string& rFileName, const std::string& rLabel = "TimeConstraint",
00322          std::ios::openmode openmode = std::ios::out|std::ios::trunc) const;
00323 
00324 
00335     void Write(TokenWriter& tw) const;
00336         
00348     void Write(TokenWriter& tw, const std::string& rLabel) const;
00349         
00356     std::string ToString(void) const;
00357 
00361     void DWrite(void) const;
00362 
00371     void DWrite(TokenWriter& tw) const;
00372 
00385     void Read(const std::string& rFileName, const std::string& rLabel = "TimeConstraint");
00386     
00387     
00400     void Read(TokenReader& tr, const std::string& rLabel = "TimeConstraint");
00401 
00402 
00409     std::string Name(void) const { return mName;};
00410         
00417     void Name(const std::string& rName) { mName=rName; };
00418 
00419 
00426     bool Empty(void) const;
00427 
00433     Idx Size(void) const;
00434 
00443     Iterator Insert(const ElemConstraint& rElemConstr);
00444 
00457     Iterator Insert(const std::string clockname, Operator op, const tpTime::Type timeconst);
00458 
00471     Iterator Insert(Idx clockindex, Operator op, const tpTime::Type timeconst);
00472 
00479     void Insert(const std::list<ElemConstraint>& rNewConstraints);
00480 
00487     void Insert(const TimeConstraint& rOtherTimeConstraint);
00488 
00497     TimeConstraint& operator << (const TimeConstraint& rOtherTimeConstraint) {
00498       this->Insert(rOtherTimeConstraint); return *this; };
00499 
00508     TimeConstraint& operator << (const ElemConstraint& rElemConstr) {
00509       this->Insert(rElemConstr); return *this; };
00510 
00514     std::set<ElemConstraint> ClockConstraints(void) const;
00515 
00525     Idx InsClock(const std::string& rClockName) const;
00526 
00536     std::string ClockName(Idx clockindex) const;
00537 
00547     Idx ClockIndex(const std::string& rClockName) const;
00548 
00558     std::string EStr(const ElemConstraint& rElemConstr) const;
00559 
00568     bool EraseByClock(Idx clock);
00569 
00579     Iterator Erase(Iterator it);
00580 
00589     bool Erase(const ElemConstraint& rElemConstr);
00590 
00603     bool Erase(const std::string& rClockName, Operator op, const tpTime::Type timeconst);
00604 
00617     bool Erase(Idx clockindex, Operator op, const tpTime::Type timeconst);
00618 
00622     void Clear(void);
00623 
00624 
00631     bool Exists(const ElemConstraint& rElemConstr) const;
00632 
00639     Iterator Begin(void) const;
00640     
00647     Iterator End(void) const;  
00648     
00657     RIterator RBegin(void) const;
00658     
00667     RIterator REnd(void) const;
00668 
00675     Iterator Begin(Idx clock) const;
00676     
00683     Iterator End(Idx clock) const;
00684 
00691     ClockSet ActiveClocks(void) const;
00692 
00699     TimeInterval Interval(Idx clockindex) const;
00700 
00707     TimeInterval Interval(const std::string& clockname) const;
00708 
00718     void Interval(Idx clockindex, const TimeInterval& rInterval);
00719 
00720 
00730     void Interval(const std::string& rClockName, const TimeInterval& rInterval);
00731 
00737     void Minimize(void);
00738 
00739 
00740   protected:
00741 
00743     std::string mName;
00744 
00746     std::set<ElemConstraint> mClockConstraints;
00747 
00749     SymbolTable* mpClockSymbolTable;
00750 
00752     typedef std::set<ElemConstraint>::iterator iterator;
00753 
00754 }; //TimeConstraint
00755 
00756 
00757 } // namespace faudes
00758 
00759 
00760 #endif 
00761 

Generated on Mon Nov 10 08:13:15 2008 for libFAUDES 2.11v by  doxygen 1.4.4