diag_attrlabelset.cpp
Go to the documentation of this file.
1 /** @file diag_attrlabelset.cpp
2 Implements the label representation for state estimates.
3 */
4 
5 #include "diag_attrlabelset.h"
6 
7 using namespace std;
8 
9 
10 namespace faudes {
11 
12  // my statics
13 SymbolTable DiagLabelSet::msLabelSymbolTable;
14 Idx DiagLabelSet::msLabelN = DiagLabelSet::msLabelSymbolTable.InsEntry("N");
15 Idx DiagLabelSet::msLabelA = DiagLabelSet::msLabelSymbolTable.InsEntry("A");
16 Idx DiagLabelSet::msLabelRelN = DiagLabelSet::msLabelSymbolTable.InsEntry("relN");
17 Idx DiagLabelSet::msLabelSpecViolated = DiagLabelSet::msLabelSymbolTable.InsEntry("F");
18 
19 // faudes type std
20 FAUDES_TYPE_IMPLEMENTATION(Void,DiagLabelSet,AttributeFlags)
21 
22 
23 // construct
25  // set my static table
26  mDiagLabels.SymbolTablep(&msLabelSymbolTable);
27  FD_DC("DiagLabelSet("<<this<<")::DiagLabelSet() with LabelSymbolTable "<< mDiagLabels.SymbolTablep());
28  // configure unregistered type
29  mDiagLabels.Name("DiagLabels");
30  mDiagLabels.TypeName("DiagLabels");
31  mDiagLabels.XElementTag("Label");
32 }
33 
34 // construct and set symbol table
35 DiagLabelSet::DiagLabelSet(SymbolTable *pSymTab) {
36  // set specified table
37  mDiagLabels.SymbolTablep(pSymTab);
38  FD_DC("DiagLabelSet("<<this<<")::DiagLabelSet() with LabelSymbolTable "<< mDiagLabels.SymbolTablep());
39  // configure unregistered type
40  mDiagLabels.Name("DiagLabels");
41  mDiagLabels.TypeName("DiagLabels");
42  mDiagLabels.XElementTag("Label");
43 }
44 
45 
46 // copy my members
47 void DiagLabelSet::DoAssign(const DiagLabelSet& rSrcAttr) {
48  AttributeFlags::DoAssign(rSrcAttr);
49  mDiagLabels=rSrcAttr.mDiagLabels;
50 }
51 
52 // equality
53 bool DiagLabelSet::DoEqual(const DiagLabelSet& rOtherSet) const {
54  // call base
55  if(!AttributeFlags::DoEqual(rOtherSet)) return false;
56  // test my members
57  if(mDiagLabels != rOtherSet.mDiagLabels) return false;
58  // pass
59  return true;
60 }
61 
62 
63 // IsDefault()
64 bool DiagLabelSet::IsDefault(void) const {
65  return mDiagLabels.Empty();
66 }
67 
68 // StaticLabelSymbolTablep()
69 SymbolTable* DiagLabelSet::StaticLabelSymbolTablep(void) {
70  return &msLabelSymbolTable;
71 }
72 
73 // LabelSymbolTablep()
74 void DiagLabelSet::LabelSymbolTablep(SymbolTable *pSymTab) {
75  mDiagLabels.SymbolTablep(pSymTab);
76 }
77 
78 // Empty()
79 bool DiagLabelSet::Empty(void) const {
80  return mDiagLabels.Empty();
81 }
82 
83 // Size()
84 Idx DiagLabelSet::Size(void) const {
85  return mDiagLabels.Size();
86 }
87 
88 // Exists()
89 bool DiagLabelSet::Exists(Idx index) const {
90  return mDiagLabels.Exists(index);
91 }
92 
93 // Insert()
94 bool DiagLabelSet::Insert(Idx index) {
95  return mDiagLabels.Insert(index);
96 }
97 
98 // InsertSet()
99 void DiagLabelSet::InsertSet(const DiagLabelSet& rSet) {
100  mDiagLabels.InsertSet(rSet.mDiagLabels);
101 }
102 
103 // Erase()
104 bool DiagLabelSet::Erase(Idx index) {
105  return mDiagLabels.Erase(index);
106 }
107 
108 // Clear()
109 void DiagLabelSet::Clear(void) {
110  return mDiagLabels.Clear();
111 }
112 
113 // IndexOfLabelN()
114 Idx DiagLabelSet::IndexOfLabelN(void) {
115  return msLabelN;
116 }
117 
118 // IndexOfLabelA()
119 Idx DiagLabelSet::IndexOfLabelA(void) {
120  return msLabelA;
121 }
122 
123 // IndexOfLabelRelN()
124 Idx DiagLabelSet::IndexOfLabelRelN(void) {
125  return msLabelRelN;
126 }
127 
128 // IndexOfLabelRelN()
129 Idx DiagLabelSet::IndexOfLabelSpecViolated(void) {
130  return msLabelSpecViolated;
131 }
132 
133 // Symbol()
134 string DiagLabelSet::Symbol(Idx index) {
135  return msLabelSymbolTable.Symbol(index);
136 }
137 
138 // PrettyPrintLabelSet()
139 string DiagLabelSet::Str(void) const {
140  string str;
141  NameSet::Iterator it;
142  for (it = mDiagLabels.Begin(); it != mDiagLabels.End(); it++) {
143  str += mDiagLabels.SymbolicName(*it);
144  }
145  return str;
146 }
147 
148 // DoWrite()
149 void DiagLabelSet::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
150  if(IsDefault()) return;
151  mDiagLabels.Write(rTw, "DiagLabels", pContext);
152 }
153 
154 // DoWrite()
155 void DiagLabelSet::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
156  if(IsDefault()) return;
157  mDiagLabels.XWrite(rTw, "DiagLabels", pContext);
158 }
159 
160 // DoRead()
161 void DiagLabelSet::DoRead(TokenReader &rTr, const std::string &rLabel, const Type *pContext) {
162  mDiagLabels.Read(rTr, "DiagLabels", pContext);
163 }
164 
165 // operator *
166 DiagLabelSet DiagLabelSet::operator * (const DiagLabelSet& rOtherSet) const {
167  FD_DC("DiagLabelSet(" << this << ")::operator * (" << &rOtherSet << ")");
168  DiagLabelSet res;
169  res.mDiagLabels = mDiagLabels * rOtherSet.mDiagLabels;
170  return res;
171 }
172 
173 // operator +
174 DiagLabelSet DiagLabelSet::operator + (const DiagLabelSet& rOtherSet) const {
175  FD_DC("DiagLabelSet(" << this << ")::operator + (" << &rOtherSet << ")");
176  DiagLabelSet res;
177  res.mDiagLabels = mDiagLabels + rOtherSet.mDiagLabels;
178  return res;
179 }
180 
181 // operator -
182 DiagLabelSet DiagLabelSet::operator - (const DiagLabelSet& rOtherSet) const {
183  FD_DC("DiagLabelSet(" << this << ")::operator - (" << &rOtherSet << ")");
184  DiagLabelSet res;
185  res.mDiagLabels = mDiagLabels - rOtherSet.mDiagLabels;
186  return res;
187 }
188 
189 
190 // operator <=
191 bool DiagLabelSet::operator <= (const DiagLabelSet& rOtherSet) const {
192  return mDiagLabels.operator <= (rOtherSet.mDiagLabels);
193 }
194 
195 // operator >=
196 bool DiagLabelSet::operator >= (const DiagLabelSet& rOtherSet) const {
197  return mDiagLabels.operator >= (rOtherSet.mDiagLabels);
198 }
199 
200 
201 } // namespace faudes
#define FD_DC(message)
Debug: optional report on container operations.
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
faudes type implementation macros, overall
Definition: cfl_types.h:946
Implements the label representation for state estimates.
NameSet mDiagLabels
Set of diagnoser label names.
A SymbolTable associates sybolic names with indices.
Idx Size(void) const
Size of symboltabel.
A TokenReader reads sequential tokens from a file or string.
A TokenWriter writes sequential tokens to a file, a string or stdout.
Base class of all libFAUDES objects that participate in the run-time interface.
Definition: cfl_types.h:239
Label representation for state estimates.
bool Empty(void) const
Test whether if the TBaseSet is Empty.
Definition: cfl_baseset.h:1824
libFAUDES resides within the namespace faudes.
uint32_t Idx
Type definition for index type (allways 32bit)

libFAUDES 2.32b --- 2024.03.01 --- c++ api documentaion by doxygen