|
libFAUDES
Sections
Index
|
diag_attrdiagstate.cppGo to the documentation of this file.00001 /** @file diag_attrdiagstate.cpp 00002 Implements state estimates for the current status of the generator (as state attributes). 00003 */ 00004 00005 #include "diag_attrdiagstate.h" 00006 00007 using namespace std; 00008 00009 namespace faudes { 00010 00011 // faudes type std 00012 FAUDES_TYPE_IMPLEMENTATION(AttributeDiagnoserState,AttributeFlags) 00013 00014 // copy my members 00015 AttributeDiagnoserState& AttributeDiagnoserState::DoAssign(const AttributeDiagnoserState& rSrcAttr) { 00016 AttributeFlags::DoAssign(rSrcAttr); 00017 mDiagnoserStateMap=rSrcAttr.mDiagnoserStateMap; 00018 return *this; 00019 } 00020 00021 // IsDefault() 00022 bool AttributeDiagnoserState::IsDefault(void) const { 00023 return mDiagnoserStateMap.Empty(); 00024 } 00025 00026 // Clear() 00027 void AttributeDiagnoserState::Clear(void) { 00028 mDiagnoserStateMap.Clear(); 00029 } 00030 00031 // DiagnoserStateMap() 00032 const TaIndexSet<DiagLabelSet>& AttributeDiagnoserState::DiagnoserStateMap(void) const { 00033 return mDiagnoserStateMap; 00034 } 00035 00036 // DiagnoserStateMapp() 00037 const TaIndexSet<DiagLabelSet>* AttributeDiagnoserState::DiagnoserStateMapp(void) const { 00038 return &mDiagnoserStateMap; 00039 } 00040 00041 // DiagnoserStateMap() 00042 void AttributeDiagnoserState::DiagnoserStateMap(const TaIndexSet<DiagLabelSet>& newDiagStateMap) { 00043 mDiagnoserStateMap = newDiagStateMap; 00044 } 00045 00046 // AddStateLabelMapping() 00047 void AttributeDiagnoserState::AddStateLabelMapping(Idx gstate, Idx label) { 00048 DiagLabelSet hset; 00049 00050 // if gstate is already mapped from, the corresponding DiagLabelSet is loaded 00051 if(mDiagnoserStateMap.Exists(gstate)) { 00052 hset = mDiagnoserStateMap.Attribute(gstate); 00053 } 00054 // and the new mapping is added 00055 hset.mDiagLabels.Insert(label); 00056 mDiagnoserStateMap.Insert(gstate,hset); 00057 } 00058 00059 // AddStateLabelMap() 00060 void AttributeDiagnoserState::AddStateLabelMap(Idx gstate, const DiagLabelSet& labels) { 00061 NameSet::Iterator it; 00062 DiagLabelSet hset; 00063 00064 // if gstate is already mapped from, the corresponding DiagLabelSet is loaded 00065 if(mDiagnoserStateMap.Exists(gstate)) { 00066 hset = mDiagnoserStateMap.Attribute(gstate); 00067 } 00068 // add labels 00069 for(it = labels.mDiagLabels.Begin(); it != labels.mDiagLabels.End(); it++) { 00070 hset.mDiagLabels.Insert(*it); 00071 } 00072 // set 00073 mDiagnoserStateMap.Insert(gstate,hset); 00074 } 00075 00076 // Str() 00077 string AttributeDiagnoserState::Str(void) const { 00078 TaIndexSet<DiagLabelSet>::Iterator it; 00079 string str; 00080 DiagLabelSet label; 00081 00082 for (it = mDiagnoserStateMap.Begin(); it != mDiagnoserStateMap.End(); it++) { 00083 label = mDiagnoserStateMap.Attribute(*it); 00084 if (it != mDiagnoserStateMap.Begin()) { 00085 str += " "; 00086 } 00087 str += ToStringInteger(*it); 00088 str += label.Str(); 00089 } 00090 return str; 00091 } 00092 00093 // ExistsState() 00094 // not used 00095 bool AttributeDiagnoserState::ExistsState(Idx state) const { 00096 return mDiagnoserStateMap.Exists(state); 00097 } 00098 00099 // DoWrite() 00100 void AttributeDiagnoserState::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const { 00101 if(IsDefault()) return; 00102 mDiagnoserStateMap.Write(rTw,"StateEstimates", pContext); 00103 } 00104 00105 //DoRead() 00106 void AttributeDiagnoserState::DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext) { 00107 mDiagnoserStateMap.Clear(); 00108 Token token; 00109 rTr.Peek(token); 00110 if(token.Type()!=Token::Begin) return; 00111 if(token.StringValue()!="StateEstimates") return; 00112 mDiagnoserStateMap.Read(rTr,"StateEstimates",pContext); 00113 } 00114 00115 // Equality 00116 bool AttributeDiagnoserState::DoEqual(const AttributeDiagnoserState& rOtherAttribute) const { 00117 // equal set 00118 if(mDiagnoserStateMap != rOtherAttribute.mDiagnoserStateMap) return false; 00119 // equal attributes 00120 if(!mDiagnoserStateMap.EqualAttributes(rOtherAttribute.mDiagnoserStateMap)) return false; 00121 // pass 00122 return true; 00123 } 00124 00125 00126 } // namespace faudes 00127 |
libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3