libFAUDES

Sections

Index

diag_attrlabelset.h

Go to the documentation of this file.
00001 /** @file diag_attrlabelset.h
00002     Label representation for state estimates.
00003 */
00004 
00005 #ifndef DIAG_LABELSET_H
00006 #define DIAG_LABELSET_H
00007 
00008 #include "corefaudes.h"
00009 #include "diag_debug.h"
00010 
00011 namespace faudes {
00012 
00013 /** 
00014  * Implements the label representation for state estimates. 
00015  * This class has its own static SymbolTable and label names are stored in mDiagLabels.
00016  *
00017  *   @ingroup DiagnosisPlugIn
00018  */
00019 class DiagLabelSet : public AttributeFlags {
00020 
00021 FAUDES_TYPE_DECLARATION(Void,DiagLabelSet,AttributeFlags)
00022 
00023  private:
00024   /** Static global symbol table for possible labels of the diagnoser attribute, e.g.,
00025       N, A, and specific failure labels. */
00026   static SymbolTable msLabelSymbolTable;
00027   /** Static index of label "normal". */
00028   static Idx msLabelN;
00029   /** Static index of label "ambiguous". */
00030   static Idx msLabelA;
00031   /** Static index of label "relatively normal" (only for diagnoser building purpose).  */
00032   static Idx msLabelRelN;
00033   /** Static index of label "specification violated". */
00034   static Idx msLabelSpecViolated;
00035 
00036  public:
00037   /** Set of diagnoser label names. */
00038   NameSet mDiagLabels;
00039   
00040  public:
00041 
00042   /** Convenience definition of NameSet::Iterator. */
00043   typedef NameSet::Iterator Iterator;
00044 
00045   /** Constructor for DiagLabelSet with static LabelSymbolTable. */
00046   DiagLabelSet(void) { 
00047     mDiagLabels.SymbolTablep(&msLabelSymbolTable);
00048     mDiagLabels.Name("DiagLabels");
00049     FD_DC("DiagLabelSet("<<this<<")::DiagLabelSet() with LabelSymbolTable "<< mDiagLabels.SymbolTablep()); 
00050   };
00051 
00052   /** Constructor for DiagLabelSet with specified SymbolTable. */
00053   DiagLabelSet(SymbolTable *pSymTab) {
00054     mDiagLabels.SymbolTablep(pSymTab);
00055     mDiagLabels.Name("DiagLabels"); 
00056     FD_DC("DiagLabelSet("<<this<<")::DiagLabelSet() with LabelSymbolTable "<< mDiagLabels.SymbolTablep()); 
00057   };
00058 
00059   /**
00060      Constructor for DiagLabelSet with static LabelSymbolTable.
00061      This version reads a file with given label to find the labels
00062      inside the file.
00063      @param rFilename
00064      Filename
00065      @param rLabel
00066      Token label for the labels in the file; default value "DiagLabels"
00067   */
00068   DiagLabelSet(const std::string& rFilename, const std::string& rLabel = "DiagLabels") {
00069     mDiagLabels.SymbolTablep(&msLabelSymbolTable);
00070     mDiagLabels.Read(rFilename,rLabel);
00071   };
00072 
00073   /**
00074    *  Test for default value
00075    *
00076    *  @return
00077    *    True for default value
00078    */
00079   bool IsDefault(void) const;
00080   
00081   /**
00082      Get pointer to static LabelSymbolTable
00083      @return
00084      Pointer to static LabelSymbolTable
00085   */
00086   static SymbolTable* StaticLabelSymbolTablep(void);
00087 
00088   /**
00089      Reset pointer mpSymbolTable
00090      @param pSymTab
00091      Pointer to new symbol table
00092   */
00093   void LabelSymbolTablep(SymbolTable* pSymTab);
00094 
00095   /**
00096      Check if mDiagLabels is empty.
00097      @return
00098      true if empty
00099   */
00100   bool Empty(void) const;
00101 
00102   /**
00103      Get size of mDiagLabels.
00104      @return
00105      Number of indices in mDiagLabels.
00106   */
00107   Idx Size(void) const;
00108   
00109   /**
00110      Test existence of index.
00111      @param index
00112      Index to test
00113      @return
00114      True if index is in this set
00115   */  
00116   bool Exists(Idx index) const;
00117 
00118   /**
00119      Add an element by index. 
00120      Index must be already known to the global SymbolTable. 
00121      @param index
00122      Index to add
00123      @return 
00124      True, if element was new to set
00125   */
00126   bool Insert(Idx index);
00127   
00128   /**
00129      Insert elements of rSet
00130      @param rSet
00131      Indices of elements to add
00132   */
00133   void InsertSet(const DiagLabelSet& rSet);
00134   
00135   /**
00136      Delete element by index. The symbolic name is not removed from the SymbolTable.
00137      @param index
00138      Index to delete.
00139      @return 
00140      True if element did exist.
00141   */  
00142   bool Erase(Idx index);
00143 
00144   /**
00145      Clear mDiagLabels.
00146   */  
00147   void Clear(void);
00148   
00149   /**
00150      Return index label "normal".
00151      @return
00152      Index of static msLabelN.
00153   */
00154   static Idx IndexOfLabelN(void);
00155   
00156   /**
00157      Return index label "ambiguous".
00158      @return
00159      Index of static msLabelA.
00160   */  static Idx IndexOfLabelA(void);
00161   
00162   /**
00163      Return index label "relatively normal".
00164      @return
00165      Index of static msLabelRelN.
00166   */
00167   static Idx IndexOfLabelRelN(void);
00168   
00169   /**
00170      Return index label "specification violated".
00171      @return
00172      Index of static msLabelSpecViolated.
00173   */
00174   static Idx IndexOfLabelSpecViolated(void);
00175   
00176   /**
00177      Symbolic name lookup of element in SymbolTable.
00178      @param index
00179      Index to look up.
00180      @return
00181      Symbolic name of index, or empty string "" for non-existent index.
00182   */
00183   static std::string Symbol(Idx index);
00184   
00185   /**
00186      Prints mDiagLabels to a string.
00187      @return
00188      String representation of mDiagLabels.
00189   */  
00190   std::string Str(void) const;
00191   
00192   /**
00193      Set intersection operator.
00194      @return
00195      Intersection DiagLabelSet
00196   */
00197   DiagLabelSet operator * (const DiagLabelSet& rOtherSet) const;
00198 
00199   /**
00200      Set union operator.
00201      @return 
00202      Union DiagLabelSet
00203   */
00204   DiagLabelSet operator + (const DiagLabelSet& rOtherSet) const;
00205 
00206   /**
00207      Set difference operator.
00208      @return 
00209      Difference DiagLabelSet
00210   */
00211   DiagLabelSet operator - (const DiagLabelSet& rOtherSet) const;
00212 
00213   /** Test for subset. */
00214   bool operator <= (const DiagLabelSet& rOtherSet) const;
00215 
00216   /** Test for superset. */
00217   bool operator >= (const DiagLabelSet& rOtherSet) const;
00218 
00219 
00220  protected:
00221 
00222   /**
00223      Write mDiagLabels to TokenWriter.
00224      @param rTw
00225      Reference to TokenWriter
00226      @param rLabel
00227      Is ignored. Label of the section is "DiagLabels".
00228      @param pContext
00229      Write context to provide contextual information
00230   */  
00231   void DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const;
00232      
00233   /**
00234      Read mDiagLabels from TokenReader.
00235      @param rTr
00236      Reference to TokenReader
00237      @param rLabel
00238      Is ignored. Label of the section is "DiagLabels".
00239      @param pContext
00240      Write context to provide contextual information
00241   */
00242   void DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext);
00243 
00244   /**
00245    *  Copy attribute members
00246    *
00247    *  @param rSrcAttr 
00248    *    Source to copy from
00249    */
00250   void DoAssign(const DiagLabelSet& rSrcAttr); 
00251   
00252   /**
00253    *  Test equality
00254    *  @param rOther 
00255    *    Attribute to compare with
00256    */
00257   bool DoEqual(const DiagLabelSet& rOther) const; 
00258 
00259 }; // class DiagLabelSet
00260 
00261 } // namespace faudes
00262 
00263 #endif

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