diag_attrfailuretypes.cppGo to the documentation of this file.00001 /** @file diag_attrfailuretypes.cpp 00002 Failure and indicator partition for a system (used as global attribute). 00003 */ 00004 00005 #include "diag_attrfailuretypes.h" 00006 00007 using namespace std; 00008 00009 namespace faudes { 00010 00011 // faudes type std 00012 FAUDES_TYPE_IMPLEMENTATION(Void,AttributeFailureTypeMap,AttributeFlags) 00013 00014 // construct 00015 AttributeFailureTypeMap::AttributeFailureTypeMap(void) : AttributeFlags() { 00016 // configure unregistered type 00017 // note: its just my member which is not registered, the attribute is registered 00018 mFailureTypeMap.TypeName("FailureTypes"); 00019 mFailureTypeMap.XElementTag("FailureType"); 00020 mFailureTypeMap.Name("FailureTypes"); 00021 // always use static symbol table 00022 mFailureTypeMap.SymbolTablep(DiagLabelSet::StaticLabelSymbolTablep()); 00023 } 00024 00025 // comnstruct from file 00026 AttributeFailureTypeMap::AttributeFailureTypeMap(const std::string& rFilename) : AttributeFlags() { 00027 // configure unregistered type 00028 // note: its just my member which is not registered, the attribute is registered 00029 mFailureTypeMap.TypeName("FailureTypes"); 00030 mFailureTypeMap.XElementTag("FailureType"); 00031 mFailureTypeMap.Name("FailureTypes"); 00032 // always use static symbol table 00033 mFailureTypeMap.SymbolTablep(DiagLabelSet::StaticLabelSymbolTablep()); 00034 // read 00035 Read(rFilename); 00036 } 00037 00038 // copycontruct 00039 AttributeFailureTypeMap::AttributeFailureTypeMap(const AttributeFailureTypeMap& rOtherAttr) : AttributeFlags(rOtherAttr) { 00040 // configure unregistered type 00041 // note: its just my member which is not registered, the attribute is registered 00042 mFailureTypeMap.TypeName("FailureTypes"); 00043 mFailureTypeMap.XElementTag("FailureType"); 00044 mFailureTypeMap.Name("FailureTypes"); 00045 // always use static symbol table 00046 mFailureTypeMap.SymbolTablep(DiagLabelSet::StaticLabelSymbolTablep()); 00047 // copy 00048 DoAssign(rOtherAttr); 00049 } 00050 00051 00052 // copy my members 00053 void AttributeFailureTypeMap::DoAssign(const AttributeFailureTypeMap& rSrcAttr) { 00054 AttributeFlags::DoAssign(rSrcAttr); 00055 mFailureTypeMap = rSrcAttr.mFailureTypeMap; 00056 } 00057 00058 // Equality 00059 bool AttributeFailureTypeMap::DoEqual(const AttributeFailureTypeMap& rAttr) const { 00060 // test base 00061 if(!AttributeFlags::DoEqual(rAttr)) return false; 00062 // my members 00063 if(mFailureTypeMap!=rAttr.mFailureTypeMap) return false; 00064 // pass 00065 return true; 00066 } 00067 00068 00069 // IsDefault() 00070 bool AttributeFailureTypeMap::IsDefault(void) const{ 00071 return mFailureTypeMap.Empty(); 00072 } 00073 00074 // Empty() 00075 bool AttributeFailureTypeMap::Empty(void) const { 00076 return mFailureTypeMap.Empty(); 00077 } 00078 00079 // Clear() 00080 void AttributeFailureTypeMap::Clear(void) { 00081 mFailureTypeMap.Clear(); 00082 } 00083 00084 // AddFailureTypeMapping() 00085 Idx AttributeFailureTypeMap::AddFailureTypeMapping(const std::string& failureType, const EventSet& rfailureEvents) { 00086 Idx failureLabelIndex; 00087 SymbolTable* mpLabelSymbolTable = DiagLabelSet::StaticLabelSymbolTablep(); 00088 00089 // Insert failureType in msLabelSymbolTable of DiagLabelSet. 00090 // If failure type name does already exist in LabelSymbolTable, InsEntry returns index of existing entry. 00091 try { 00092 failureLabelIndex = mpLabelSymbolTable->InsEntry(failureType); 00093 } 00094 catch (faudes::Exception& exception) { 00095 stringstream errstr; 00096 errstr << "Have not been able to add failure with Index " << failureType << " to LabelSymbolTable" << endl; 00097 throw Exception("AttributeFailureTypeMap::AddFailureTypeMapping()", errstr.str(), 300); 00098 } 00099 // store failure event set in AttributeFailureEvents 00100 AttributeFailureEvents fEvents; 00101 fEvents.mFailureEvents.InsertSet(rfailureEvents); 00102 00103 // write new map entry 00104 mFailureTypeMap.Insert(failureLabelIndex,fEvents); 00105 00106 return failureLabelIndex; 00107 } 00108 00109 // AddFailureTypeMap() 00110 void AttributeFailureTypeMap::AddFailureTypeMap(const std::map<std::string,EventSet>& rFailureMap) { 00111 map<string,EventSet>::const_iterator it; 00112 00113 for(it = rFailureMap.begin(); it != rFailureMap.end(); it++) { 00114 AddFailureTypeMapping(it->first,it->second); 00115 } 00116 } 00117 00118 // FailureType() 00119 // not used 00120 Idx AttributeFailureTypeMap::FailureType(Idx failureEvent) const { 00121 TaNameSet<AttributeFailureEvents>::Iterator it; 00122 00123 for(it = mFailureTypeMap.Begin(); it != mFailureTypeMap.End(); it++) { 00124 if (mFailureTypeMap.Attribute(*it).mFailureEvents.Exists(failureEvent)) { 00125 return *it; 00126 } 00127 } 00128 return 0; 00129 } 00130 00131 // AllFailureEvents() 00132 EventSet AttributeFailureTypeMap::AllFailureEvents(void) const { 00133 EventSet failures; 00134 AttributeFailureEvents failureAttr; 00135 TaNameSet<AttributeFailureEvents>::Iterator it; 00136 00137 failures.Clear(); 00138 for(it = mFailureTypeMap.Begin(); it != mFailureTypeMap.End(); it++) { 00139 failureAttr = mFailureTypeMap.Attribute(*it); 00140 failures.InsertSet(failureAttr.mFailureEvents); 00141 } 00142 return failures; 00143 } 00144 00145 // DoWrite() 00146 void AttributeFailureTypeMap::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const { 00147 if(IsDefault()) return; 00148 mFailureTypeMap.Write(rTw,"FailureTypes", pContext); 00149 } 00150 00151 // DoXWrite() 00152 void AttributeFailureTypeMap::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const { 00153 if(IsDefault()) return; 00154 mFailureTypeMap.XWrite(rTw,"FailureTypes", pContext); 00155 } 00156 00157 // DoRead() 00158 void AttributeFailureTypeMap::DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext) { 00159 mFailureTypeMap.Clear(); 00160 Token token; 00161 rTr.Peek(token); 00162 if(!token.IsBegin("FailureTypes")) return; 00163 mFailureTypeMap.Read(rTr, "FailureTypes", pContext); 00164 } 00165 00166 00167 } // namespace faudes 00168 libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |