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 
00048   /** Constructor for DiagLabelSet with specified SymbolTable. */
00049   DiagLabelSet(SymbolTable *pSymTab);
00050 
00051   /**
00052      Constructor for DiagLabelSet with static LabelSymbolTable.
00053      This version reads a file with given label to find the labels
00054      inside the file.
00055      @param rFilename
00056      Filename
00057      @param rLabel
00058      Token label for the labels in the file; default value "DiagLabels"
00059   */
00060   DiagLabelSet(const std::string& rFilename, const std::string& rLabel = "DiagLabels") {
00061     mDiagLabels.SymbolTablep(&msLabelSymbolTable);
00062     mDiagLabels.Read(rFilename,rLabel);
00063   };
00064 
00065   /**
00066    *  Test for default value
00067    *
00068    *  @return
00069    *    True for default value
00070    */
00071   bool IsDefault(void) const;
00072   
00073   /**
00074      Get pointer to static LabelSymbolTable
00075      @return
00076      Pointer to static LabelSymbolTable
00077   */
00078   static SymbolTable* StaticLabelSymbolTablep(void);
00079 
00080   /**
00081      Reset pointer mpSymbolTable
00082      @param pSymTab
00083      Pointer to new symbol table
00084   */
00085   void LabelSymbolTablep(SymbolTable* pSymTab);
00086 
00087   /**
00088      Check if mDiagLabels is empty.
00089      @return
00090      true if empty
00091   */
00092   bool Empty(void) const;
00093 
00094   /**
00095      Get size of mDiagLabels.
00096      @return
00097      Number of indices in mDiagLabels.
00098   */
00099   Idx Size(void) const;
00100   
00101   /**
00102      Test existence of index.
00103      @param index
00104      Index to test
00105      @return
00106      True if index is in this set
00107   */  
00108   bool Exists(Idx index) const;
00109 
00110   /**
00111      Add an element by index. 
00112      Index must be already known to the global SymbolTable. 
00113      @param index
00114      Index to add
00115      @return 
00116      True, if element was new to set
00117   */
00118   bool Insert(Idx index);
00119   
00120   /**
00121      Insert elements of rSet
00122      @param rSet
00123      Indices of elements to add
00124   */
00125   void InsertSet(const DiagLabelSet& rSet);
00126   
00127   /**
00128      Delete element by index. The symbolic name is not removed from the SymbolTable.
00129      @param index
00130      Index to delete.
00131      @return 
00132      True if element did exist.
00133   */  
00134   bool Erase(Idx index);
00135 
00136   /**
00137      Clear mDiagLabels.
00138   */  
00139   void Clear(void);
00140   
00141   /**
00142      Return index label "normal".
00143      @return
00144      Index of static msLabelN.
00145   */
00146   static Idx IndexOfLabelN(void);
00147   
00148   /**
00149      Return index label "ambiguous".
00150      @return
00151      Index of static msLabelA.
00152   */  static Idx IndexOfLabelA(void);
00153   
00154   /**
00155      Return index label "relatively normal".
00156      @return
00157      Index of static msLabelRelN.
00158   */
00159   static Idx IndexOfLabelRelN(void);
00160   
00161   /**
00162      Return index label "specification violated".
00163      @return
00164      Index of static msLabelSpecViolated.
00165   */
00166   static Idx IndexOfLabelSpecViolated(void);
00167   
00168   /**
00169      Symbolic name lookup of element in SymbolTable.
00170      @param index
00171      Index to look up.
00172      @return
00173      Symbolic name of index, or empty string "" for non-existent index.
00174   */
00175   static std::string Symbol(Idx index);
00176   
00177   /**
00178      Prints mDiagLabels to a string.
00179      @return
00180      String representation of mDiagLabels.
00181   */  
00182   std::string Str(void) const;
00183   
00184   /**
00185      Set intersection operator.
00186      @return
00187      Intersection DiagLabelSet
00188   */
00189   DiagLabelSet operator * (const DiagLabelSet& rOtherSet) const;
00190 
00191   /**
00192      Set union operator.
00193      @return 
00194      Union DiagLabelSet
00195   */
00196   DiagLabelSet operator + (const DiagLabelSet& rOtherSet) const;
00197 
00198   /**
00199      Set difference operator.
00200      @return 
00201      Difference DiagLabelSet
00202   */
00203   DiagLabelSet operator - (const DiagLabelSet& rOtherSet) const;
00204 
00205   /** Test for subset. */
00206   bool operator <= (const DiagLabelSet& rOtherSet) const;
00207 
00208   /** Test for superset. */
00209   bool operator >= (const DiagLabelSet& rOtherSet) const;
00210 
00211 
00212  protected:
00213 
00214   /**
00215      Write mDiagLabels to TokenWriter.
00216      @param rTw
00217      Reference to TokenWriter
00218      @param rLabel
00219      Is ignored. Label of the section is "DiagLabels".
00220      @param pContext
00221      Write context to provide contextual information
00222   */  
00223   void DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const;
00224      
00225   /**
00226      Write mDiagLabels to TokenWriter.
00227      @param rTw
00228      Reference to TokenWriter
00229      @param rLabel
00230      Is ignored. Label of the section is "DiagLabels".
00231      @param pContext
00232      Write context to provide contextual information
00233   */  
00234   void DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const;
00235      
00236   /**
00237      Read mDiagLabels from TokenReader.
00238      @param rTr
00239      Reference to TokenReader
00240      @param rLabel
00241      Is ignored. Label of the section is "DiagLabels".
00242      @param pContext
00243      Write context to provide contextual information
00244   */
00245   void DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext);
00246 
00247   /**
00248    *  Copy attribute members
00249    *
00250    *  @param rSrcAttr 
00251    *    Source to copy from
00252    */
00253   void DoAssign(const DiagLabelSet& rSrcAttr); 
00254   
00255   /**
00256    *  Test equality
00257    *  @param rOther 
00258    *    Attribute to compare with
00259    */
00260   bool DoEqual(const DiagLabelSet& rOther) const; 
00261 
00262 }; // class DiagLabelSet
00263 
00264 } // namespace faudes
00265 
00266 #endif

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