libFAUDES

Sections

Index

diag_attrfailuretypes.h

Go to the documentation of this file.
00001 /** @file diag_attrfailuretypes.h
00002     Contains the failure and indicator partition for a system (used as global attribute).
00003 */
00004 
00005 #ifndef DIAG_ATTRFAILURETYPES_H
00006 #define DIAG_ATTRFAILURETYPES_H
00007 
00008 #include <vector>
00009 #include <map>
00010 #include <set>
00011 #include "corefaudes.h"
00012 #include "diag_attrfailureevents.h"
00013 #include "diag_debug.h"
00014 
00015 namespace faudes {
00016 
00017 /**
00018  * Partitions the failure and indicator events.
00019  * This attribute is a wrapper to a nameset with failuretype attributes.
00020  *
00021  * @ingroup DiagnosisPlugIn
00022  */
00023 class AttributeFailureTypeMap : public AttributeFlags {
00024 
00025 FAUDES_TYPE_DECLARATION(AttributeFailureTypeMap,AttributeFlags)
00026 
00027    public:
00028 
00029   /** 
00030    * Failure and indicator event partition. 
00031    * Mapping of failure type indices (as defined in GlobalEventSymbolTable) 
00032    * to associated failure events and indicator events. 
00033    */
00034   TaNameSet<AttributeFailureEvents> mFailureTypeMap;
00035   
00036   /** Default constructor. */
00037   AttributeFailureTypeMap(void) : AttributeFlags() {
00038     mFailureTypeMap.Name("FailureTypes");
00039     mFailureTypeMap.SymbolTablep(DiagLabelSet::StaticLabelSymbolTablep());
00040   };
00041   
00042   /** Constructor from file. */
00043   AttributeFailureTypeMap(const std::string& rFilename)  : AttributeFlags() {
00044     mFailureTypeMap.Name("FailureTypes");
00045     mFailureTypeMap.SymbolTablep(DiagLabelSet::StaticLabelSymbolTablep());
00046     Read(rFilename);
00047   };
00048   
00049   /** Copyconstructor */
00050   AttributeFailureTypeMap(const AttributeFailureTypeMap& rOtherAttr)  : AttributeFlags(rOtherAttr) {
00051     mFailureTypeMap.Name("FailureTypes");
00052     mFailureTypeMap.SymbolTablep(DiagLabelSet::StaticLabelSymbolTablep());
00053     DoAssign(rOtherAttr);
00054   }
00055 
00056   /** Destructor. */
00057   ~AttributeFailureTypeMap(void) {};
00058 
00059   /**
00060    *  Test for default value.
00061    *
00062    *  @return
00063    *    True for default value
00064    */
00065   bool IsDefault(void) const;
00066   
00067   /**
00068    * Test if mFailureTypeMap is empty.
00069    *
00070    * @return
00071    *   True if empty
00072   */
00073   bool Empty(void) const;
00074 
00075   /**
00076    *  Clears mFailureTypeMap.
00077    */
00078   void Clear(void);
00079 
00080   /**
00081    *  Add a set of failure events to failure type map. 
00082    *  Make sure that you do not insert a failure event which is part of another failure type as well!
00083    *
00084    *  @param failureType
00085    *    Name of failure type
00086    *  @param rfailureEvents
00087    *    Associated failure events
00088    *  @return
00089    *    Index of entry for failure type name in LabelSymbolTable.
00090    *  @exception Exception
00091    *  - Adding failure to LabelSymbolTable failed (id 300).
00092    */
00093   Idx AddFailureTypeMapping(const std::string& failureType, const EventSet& rfailureEvents);
00094   
00095   /**
00096    *  Inserts entire failure type map to mFailureTypeMap.
00097    *
00098    *  @param rFailureMap
00099    *    Mapping of failure type names to failure events
00100    */  
00101   void AddFailureTypeMap(const std::map<std::string,EventSet>& rFailureMap);
00102   
00103   /**
00104    *  Returns failure type of failure event.
00105    *
00106    *  @param failureEvent
00107    *    Index of failure event.
00108    *  @return
00109    *    Index of failure type.
00110    */
00111   Idx FailureType(Idx failureEvent) const;
00112   
00113   /**
00114    *  Obtain all failure events in mFailureTypeMap.
00115    *
00116    *  @return
00117    *    EventSet containing all failure events.
00118    */
00119   EventSet AllFailureEvents(void) const;
00120   
00121  protected:
00122   
00123   /**
00124    *  Write mFailureTypeMap to TokenWriter.
00125    *
00126    *  @param rTw
00127    *    Reference to TokenWriter
00128    *  @param rLabel
00129    *    Is ignored. Failure events are written in a section "FailureEvents" and indicator events in a separate section "IndicatorEvents".
00130    *  @param pContext
00131    *    Write context to provide contextual information
00132    */
00133   void DoWrite(TokenWriter& rTw, const std::string& rLabel = "", const Type* pContext = 0) const;
00134   
00135   /**
00136    *  Read mFailureTypeMap from TokenReader.
00137    *
00138    *  @param rTr
00139    *    Reference to TokenReader
00140    *  @param rLabel
00141    *    Is ignored. Failure events are read from section "FailureEvents" and indicator events from section "IndicatorEvents".
00142    *  @param pContext
00143    *    Write context to provide contextual information
00144    */
00145   void DoRead(TokenReader &rTr, const std::string &rLabel = "", const Type *pContext = 0);
00146   
00147   /**
00148    *  Copy attribute members.
00149    *
00150    *  @param rSrcAttr 
00151    *    Source to copy from
00152    */
00153   AttributeFailureTypeMap& DoAssign(const AttributeFailureTypeMap& rSrcAttr);   
00154 
00155   /**
00156    *  Test equality
00157    *
00158    *  @param rAttr 
00159    *    Other attribute to compare with
00160    */
00161    bool  DoEqual(const AttributeFailureTypeMap& rAttr) const;   
00162 
00163   
00164 }; // class AttributeFailureTypeMap
00165 
00166 
00167 } // namespace faudes
00168 
00169 #endif

libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3