diag_attrlabelset.h
Go to the documentation of this file.
1/** @file diag_attrlabelset.h
2 Label representation for state estimates.
3*/
4
5#ifndef DIAG_LABELSET_H
6#define DIAG_LABELSET_H
7
8#include "corefaudes.h"
9#include "diag_debug.h"
10
11namespace faudes {
12
13/**
14 * Implements the label representation for state estimates.
15 * This class has its own static SymbolTable and label names are stored in mDiagLabels.
16 *
17 * @ingroup DiagnosisPlugIn
18 */
20
22
23 private:
24 /** Static global symbol table for possible labels of the diagnoser attribute, e.g.,
25 N, A, and specific failure labels. */
27 /** Static index of label "normal". */
28 static Idx msLabelN;
29 /** Static index of label "ambiguous". */
30 static Idx msLabelA;
31 /** Static index of label "relatively normal" (only for diagnoser building purpose). */
33 /** Static index of label "specification violated". */
35
36 public:
37 /** Set of diagnoser label names. */
39
40 public:
41
42 /** Convenience definition of NameSet::Iterator. */
43 typedef NameSet::Iterator Iterator;
44
45 /** Constructor for DiagLabelSet with static LabelSymbolTable. */
46 DiagLabelSet(void);
47
48 /** Constructor for DiagLabelSet with specified SymbolTable. */
49 DiagLabelSet(SymbolTable *pSymTab);
50
51 /** Copy Constructor*/
52 DiagLabelSet(const DiagLabelSet& rSrcAttr);
53
54 /**
55 Constructor for DiagLabelSet with static LabelSymbolTable.
56 This version reads a file with given label to find the labels
57 inside the file.
58 @param rFilename
59 Filename
60 @param rLabel
61 Token label for the labels in the file; default value "DiagLabels"
62 */
63 DiagLabelSet(const std::string& rFilename, const std::string& rLabel = "DiagLabels") {
64 mDiagLabels.SymbolTablep(&msLabelSymbolTable);
65 mDiagLabels.Read(rFilename,rLabel);
66 };
67
68 /**
69 * Test for default value
70 *
71 * @return
72 * True for default value
73 */
74 bool IsDefault(void) const;
75
76 /**
77 Get pointer to static LabelSymbolTable
78 @return
79 Pointer to static LabelSymbolTable
80 */
81 static SymbolTable* StaticLabelSymbolTablep(void);
82
83 /**
84 Reset pointer mpSymbolTable
85 @param pSymTab
86 Pointer to new symbol table
87 */
88 void LabelSymbolTablep(SymbolTable* pSymTab);
89
90 /**
91 Check if mDiagLabels is empty.
92 @return
93 true if empty
94 */
95 bool Empty(void) const;
96
97 /**
98 Get size of mDiagLabels.
99 @return
100 Number of indices in mDiagLabels.
101 */
102 Idx Size(void) const;
103
104 /**
105 Test existence of index.
106 @param index
107 Index to test
108 @return
109 True if index is in this set
110 */
111 bool Exists(Idx index) const;
112
113 /**
114 Add an element by index.
115 Index must be already known to the global SymbolTable.
116 @param index
117 Index to add
118 @return
119 True, if element was new to set
120 */
121 bool Insert(Idx index);
122
123 /**
124 Insert elements of rSet
125 @param rSet
126 Indices of elements to add
127 */
128 void InsertSet(const DiagLabelSet& rSet);
129
130 /**
131 Delete element by index. The symbolic name is not removed from the SymbolTable.
132 @param index
133 Index to delete.
134 @return
135 True if element did exist.
136 */
137 bool Erase(Idx index);
138
139 /**
140 Clear mDiagLabels.
141 */
142 void Clear(void);
143
144 /**
145 Return index label "normal".
146 @return
147 Index of static msLabelN.
148 */
149 static Idx IndexOfLabelN(void);
150
151 /**
152 Return index label "ambiguous".
153 @return
154 Index of static msLabelA.
155 */ static Idx IndexOfLabelA(void);
156
157 /**
158 Return index label "relatively normal".
159 @return
160 Index of static msLabelRelN.
161 */
162 static Idx IndexOfLabelRelN(void);
163
164 /**
165 Return index label "specification violated".
166 @return
167 Index of static msLabelSpecViolated.
168 */
169 static Idx IndexOfLabelSpecViolated(void);
170
171 /**
172 Symbolic name lookup of element in SymbolTable.
173 @param index
174 Index to look up.
175 @return
176 Symbolic name of index, or empty string "" for non-existent index.
177 */
178 static std::string Symbol(Idx index);
179
180 /**
181 Prints mDiagLabels to a string.
182 @return
183 String representation of mDiagLabels.
184 */
185 std::string Str(void) const;
186
187 /**
188 Set intersection operator.
189 @return
190 Intersection DiagLabelSet
191 */
192 DiagLabelSet operator * (const DiagLabelSet& rOtherSet) const;
193
194 /**
195 Set union operator.
196 @return
197 Union DiagLabelSet
198 */
199 DiagLabelSet operator + (const DiagLabelSet& rOtherSet) const;
200
201 /**
202 Set difference operator.
203 @return
204 Difference DiagLabelSet
205 */
206 DiagLabelSet operator - (const DiagLabelSet& rOtherSet) const;
207
208 /** Test for subset. */
209 bool operator <= (const DiagLabelSet& rOtherSet) const;
210
211 /** Test for superset. */
212 bool operator >= (const DiagLabelSet& rOtherSet) const;
213
214
215 protected:
216
217 /**
218 Write mDiagLabels to TokenWriter.
219 @param rTw
220 Reference to TokenWriter
221 @param rLabel
222 Is ignored. Label of the section is "DiagLabels".
223 @param pContext
224 Write context to provide contextual information
225 */
226 void DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const;
227
228 /**
229 Write mDiagLabels to TokenWriter.
230 @param rTw
231 Reference to TokenWriter
232 @param rLabel
233 Is ignored. Label of the section is "DiagLabels".
234 @param pContext
235 Write context to provide contextual information
236 */
237 void DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const;
238
239 /**
240 Read mDiagLabels from TokenReader.
241 @param rTr
242 Reference to TokenReader
243 @param rLabel
244 Is ignored. Label of the section is "DiagLabels".
245 @param pContext
246 Write context to provide contextual information
247 */
248 void DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext);
249
250 /**
251 * Copy attribute members
252 *
253 * @param rSrcAttr
254 * Source to copy from
255 */
256 void DoCopy(const DiagLabelSet& rSrcAttr);
257
258 /**
259 * Copy attribute members
260 *
261 * @param rSrcAttr
262 * Source to copy from
263 */
264 void DoMove(DiagLabelSet& rSrcAttr);
265
266 /**
267 * Test equality
268 * @param rOther
269 * Attribute to compare with
270 */
271 bool DoEqual(const DiagLabelSet& rOther) const;
272
273}; // class DiagLabelSet
274
275} // namespace faudes
276
277#endif
#define FAUDES_API
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
Definition cfl_types.h:918
NameSet::Iterator Iterator
DiagLabelSet(const std::string &rFilename, const std::string &rLabel="DiagLabels")
static SymbolTable msLabelSymbolTable
SymbolTable * SymbolTablep(void) const
void Read(const std::string &rFileName, const std::string &rLabel="", const Type *pContext=0)
uint32_t Idx

libFAUDES 2.34d --- 2026.03.11 --- c++ api documentaion by doxygen