diag_attrdiagstate.cpp
Go to the documentation of this file.
1/** @file diag_attrdiagstate.cpp
2Implements state estimates for the current status of the generator (as state attributes).
3*/
4
6
7using namespace std;
8
9namespace faudes {
10
11// faudes type std
12FAUDES_TYPE_IMPLEMENTATION(Void,AttributeDiagnoserState,AttributeFlags)
13
14// consruct
16 // our map type is not in the registry, so we need to configure manually
17 mDiagnoserStateMap.ElementTag("TargetState");
18 mDiagnoserStateMap.Name("TargetStateEstimates");
19 mDiagnoserStateMap.TypeName("TargetStateEstimates");
20}
21
22// copy consruct
29
30// destruct
32
33
34// copy my members
39
40// copy my members
45
46// IsDefault()
48 return mDiagnoserStateMap.Empty();
49}
50
51// Clear()
55
56// DiagnoserStateMap()
60
61// DiagnoserStateMapp()
65
66// DiagnoserStateMap()
68 mDiagnoserStateMap = newDiagStateMap;
69}
70
71// AddStateLabelMapping()
73 DiagLabelSet hset;
74
75 // if gstate is already mapped from, the corresponding DiagLabelSet is loaded
76 if(mDiagnoserStateMap.Exists(gstate)) {
77 hset = mDiagnoserStateMap.Attribute(gstate);
78 }
79 // and the new mapping is added
80 hset.mDiagLabels.Insert(label);
81 mDiagnoserStateMap.Insert(gstate,hset);
82}
83
84// AddStateLabelMap()
86 NameSet::Iterator it;
87 DiagLabelSet hset;
88
89 // if gstate is already mapped from, the corresponding DiagLabelSet is loaded
90 if(mDiagnoserStateMap.Exists(gstate)) {
91 hset = mDiagnoserStateMap.Attribute(gstate);
92 }
93 // add labels
94 for(it = labels.mDiagLabels.Begin(); it != labels.mDiagLabels.End(); it++) {
95 hset.mDiagLabels.Insert(*it);
96 }
97 // set
98 mDiagnoserStateMap.Insert(gstate,hset);
99}
100
101// Str()
104 string str;
105 DiagLabelSet label;
106
107 for (it = mDiagnoserStateMap.Begin(); it != mDiagnoserStateMap.End(); it++) {
108 label = mDiagnoserStateMap.Attribute(*it);
109 if (it != mDiagnoserStateMap.Begin()) {
110 str += " ";
111 }
112 str += ToStringInteger(*it);
113 str += label.Str();
114 }
115 return str;
116}
117
118// ExistsState()
119// not used
121 return mDiagnoserStateMap.Exists(state);
122}
123
124// DoWrite()
125void AttributeDiagnoserState::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
126 if(IsDefault()) return;
127 mDiagnoserStateMap.Write(rTw,"StateEstimates", pContext);
128}
129
130// DoXWrite()
131void AttributeDiagnoserState::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
132 if(IsDefault()) return;
133 mDiagnoserStateMap.XWrite(rTw,"TargetStateEstimates", pContext);
134}
135
136//DoRead()
137void AttributeDiagnoserState::DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext) {
138 mDiagnoserStateMap.Clear();
139 Token token;
140 rTr.Peek(token);
141 // native faudes
142 if(token.IsBegin("StateEstimates"))
143 mDiagnoserStateMap.Read(rTr,"",pContext);
144 // XML format
145 if(token.IsBegin("TargetStateEstimates"))
146 mDiagnoserStateMap.Read(rTr,"",pContext);
147}
148
149// Equality
151 // equal set
152 if(mDiagnoserStateMap != rOtherAttribute.mDiagnoserStateMap) return false;
153 // equal attributes
154 if(!mDiagnoserStateMap.EqualAttributes(rOtherAttribute.mDiagnoserStateMap)) return false;
155 // pass
156 return true;
157}
158
159
160} // namespace faudes
161
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
Definition cfl_types.h:1017
void DoWrite(TokenWriter &rTw, const std::string &rLabel, const Type *pContext) const
void AddStateLabelMapping(Idx state, Idx label)
void DoCopy(const AttributeDiagnoserState &rSrc)
bool DoEqual(const AttributeDiagnoserState &rOther) const
void DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext)
const TaIndexSet< DiagLabelSet > * DiagnoserStateMapp(void) const
const TaIndexSet< DiagLabelSet > & DiagnoserStateMap(void) const
void AddStateLabelMap(Idx gstate, const DiagLabelSet &labels)
void DoXWrite(TokenWriter &rTw, const std::string &rLabel, const Type *pContext) const
void DoMove(AttributeDiagnoserState &rSrc)
TaIndexSet< DiagLabelSet > mDiagnoserStateMap
void DoCopy(const AttributeFlags &rSrcAttr)
std::string Str(void) const
bool Insert(const Idx &rIndex)
bool Peek(Token &token)
bool IsBegin(void) const
virtual void Name(const std::string &rName)
Iterator End(void) const
Iterator Begin(void) const
uint32_t Idx
std::string ToStringInteger(Int number)
Definition cfl_utils.cpp:43

libFAUDES 2.34e --- 2026.03.16 --- c++ api documentaion by doxygen