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 /**
52 Constructor for DiagLabelSet with static LabelSymbolTable.
53 This version reads a file with given label to find the labels
54 inside the file.
55 @param rFilename
56 Filename
57 @param rLabel
58 Token label for the labels in the file; default value "DiagLabels"
59 */
60 DiagLabelSet(const std::string& rFilename, const std::string& rLabel = "DiagLabels") {
61 mDiagLabels.SymbolTablep(&msLabelSymbolTable);
62 mDiagLabels.Read(rFilename,rLabel);
63 };
64
65 /**
66 * Test for default value
67 *
68 * @return
69 * True for default value
70 */
71 bool IsDefault(void) const;
72
73 /**
74 Get pointer to static LabelSymbolTable
75 @return
76 Pointer to static LabelSymbolTable
77 */
78 static SymbolTable* StaticLabelSymbolTablep(void);
79
80 /**
81 Reset pointer mpSymbolTable
82 @param pSymTab
83 Pointer to new symbol table
84 */
85 void LabelSymbolTablep(SymbolTable* pSymTab);
86
87 /**
88 Check if mDiagLabels is empty.
89 @return
90 true if empty
91 */
92 bool Empty(void) const;
93
94 /**
95 Get size of mDiagLabels.
96 @return
97 Number of indices in mDiagLabels.
98 */
99 Idx Size(void) const;
100
101 /**
102 Test existence of index.
103 @param index
104 Index to test
105 @return
106 True if index is in this set
107 */
108 bool Exists(Idx index) const;
109
110 /**
111 Add an element by index.
112 Index must be already known to the global SymbolTable.
113 @param index
114 Index to add
115 @return
116 True, if element was new to set
117 */
118 bool Insert(Idx index);
119
120 /**
121 Insert elements of rSet
122 @param rSet
123 Indices of elements to add
124 */
125 void InsertSet(const DiagLabelSet& rSet);
126
127 /**
128 Delete element by index. The symbolic name is not removed from the SymbolTable.
129 @param index
130 Index to delete.
131 @return
132 True if element did exist.
133 */
134 bool Erase(Idx index);
135
136 /**
137 Clear mDiagLabels.
138 */
139 void Clear(void);
140
141 /**
142 Return index label "normal".
143 @return
144 Index of static msLabelN.
145 */
146 static Idx IndexOfLabelN(void);
147
148 /**
149 Return index label "ambiguous".
150 @return
151 Index of static msLabelA.
152 */ static Idx IndexOfLabelA(void);
153
154 /**
155 Return index label "relatively normal".
156 @return
157 Index of static msLabelRelN.
158 */
159 static Idx IndexOfLabelRelN(void);
160
161 /**
162 Return index label "specification violated".
163 @return
164 Index of static msLabelSpecViolated.
165 */
166 static Idx IndexOfLabelSpecViolated(void);
167
168 /**
169 Symbolic name lookup of element in SymbolTable.
170 @param index
171 Index to look up.
172 @return
173 Symbolic name of index, or empty string "" for non-existent index.
174 */
175 static std::string Symbol(Idx index);
176
177 /**
178 Prints mDiagLabels to a string.
179 @return
180 String representation of mDiagLabels.
181 */
182 std::string Str(void) const;
183
184 /**
185 Set intersection operator.
186 @return
187 Intersection DiagLabelSet
188 */
189 DiagLabelSet operator * (const DiagLabelSet& rOtherSet) const;
190
191 /**
192 Set union operator.
193 @return
194 Union DiagLabelSet
195 */
196 DiagLabelSet operator + (const DiagLabelSet& rOtherSet) const;
197
198 /**
199 Set difference operator.
200 @return
201 Difference DiagLabelSet
202 */
203 DiagLabelSet operator - (const DiagLabelSet& rOtherSet) const;
204
205 /** Test for subset. */
206 bool operator <= (const DiagLabelSet& rOtherSet) const;
207
208 /** Test for superset. */
209 bool operator >= (const DiagLabelSet& rOtherSet) const;
210
211
212 protected:
213
214 /**
215 Write mDiagLabels to TokenWriter.
216 @param rTw
217 Reference to TokenWriter
218 @param rLabel
219 Is ignored. Label of the section is "DiagLabels".
220 @param pContext
221 Write context to provide contextual information
222 */
223 void DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const;
224
225 /**
226 Write mDiagLabels to TokenWriter.
227 @param rTw
228 Reference to TokenWriter
229 @param rLabel
230 Is ignored. Label of the section is "DiagLabels".
231 @param pContext
232 Write context to provide contextual information
233 */
234 void DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const;
235
236 /**
237 Read mDiagLabels from TokenReader.
238 @param rTr
239 Reference to TokenReader
240 @param rLabel
241 Is ignored. Label of the section is "DiagLabels".
242 @param pContext
243 Write context to provide contextual information
244 */
245 void DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext);
246
247 /**
248 * Copy attribute members
249 *
250 * @param rSrcAttr
251 * Source to copy from
252 */
253 void DoAssign(const DiagLabelSet& rSrcAttr);
254
255 /**
256 * Test equality
257 * @param rOther
258 * Attribute to compare with
259 */
260 bool DoEqual(const DiagLabelSet& rOther) const;
261
262}; // class DiagLabelSet
263
264} // namespace faudes
265
266#endif
#define FAUDES_API
#define FAUDES_TYPE_DECLARATION(ftype, ctype, cbase)
Definition cfl_types.h:879
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.33k --- 2025.09.16 --- c++ api documentaion by doxygen