hio_attributes.cpp
Go to the documentation of this file.
1/** @file hio_attributes.cpp Event and state attributes for hierarchical I/O systems */
2
3/* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes)
4
5 Copyright (C) 2006 Sebastian Perk
6 Copyright (C) 2006 Thomas Moor
7 Copyright (C) 2006 Klaus Schmidt
8
9*/
10
11#include "hio_attributes.h"
12
13namespace faudes {
14
15
16/***********************************************************************************
17 *
18 * implementation of HioEventFlags
19 *
20 */
21
22// faudes type std
23FAUDES_TYPE_IMPLEMENTATION(Void,HioEventFlags,AttributeFlags)
24
25// Assign my members
26void HioEventFlags::DoAssign(const HioEventFlags& rSrcAttr) {
27 // call base (incl virtual clear)
29}
30
31//DoWrite(rTw,rLabel,pContext);
32void HioEventFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
33
34 (void) rLabel; (void) pContext;
35 if(IsDefault()) return;
36 FD_DC("HioEventFlags(" << this << ")::DoWrite(tr)");
37
38 Token token;
39 if( (mFlags & ~mAllHioEventFlags) == 0 ) {
40 std::string option;
41 switch (mFlags)
42 {
43 case 4: option = "U";break; //0000 0100
44 case 8: option = "Y";break; //0000 1000
45 case 36: option = "UE";break; //0010 0100
46 case 40: option = "YE";break; //0010 1000
47 case 20: option = "UP";break; //0001 0100
48 case 24: option = "YP";break; //0001 1000
49 case 68: option = "UC";break; //0100 0100
50 case 72: option = "YC";break; //0100 1000
51 case 132: option = "UL";break; //1000 0100
52 case 136: option = "YL";break; //1000 1000
53 default: option = "??";break;
54 }
55 token.SetOption(option);
56 }
57 // if other flags used, write hex
58 else {
59 token.SetInteger16(mFlags);
60 }
61 rTw << token;
62 }
63//}
64
65
66//DoRead(rTw,rLabel,pContext);
67void HioEventFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
68 (void) rLabel;
69 (void) pContext;
70 // initialize with dfeualt
72 Token token;
73 rTr.Peek(token);
74 // faudes format, flags as integer
75 if(token.IsInteger16()) {
76 AttributeFlags::DoRead(rTr,rLabel,pContext);
77 return;
78 }
79 // faudes format, flags as option string
80 if(token.IsOption()) {
81 rTr.Get(token);
82 std::string option=token.OptionValue();
83
84 if(option.find( 'Y', 0) != std::string::npos) SetY();
85 if(option.find( 'U', 0) != std::string::npos) SetU();
86 if(option.find( 'P', 0) != std::string::npos){ SetP(); ClrE();}
87 if(option.find( 'E', 0) != std::string::npos){ SetE(); ClrP();}
88 if(option.find( 'C', 0) != std::string::npos){ SetC(); ClrP();}
89 if(option.find( 'L', 0) != std::string::npos){ SetL(); ClrE();}
90 return;
91 }
92 // xml format
93 while(true) {
94 rTr.Peek(token);
95 // explicit integer
96 if(token.IsBegin("Flags")) {
97 AttributeFlags::DoRead(rTr,rLabel,pContext);
98 continue;
99 }
100 // known bits
101 /*
102 xml format not yet implemented,
103 see iosystem for template
104 */
105 // stop at unknown tag
106 break;
107 }
108}
109
110
111/***********************************************************************************
112 *
113 * implementation of HioStateFlags
114 *
115 */
116/***************************************************************************/
117
118// faudes type std
120
121// Assign my members
122void HioStateFlags::DoAssign(const HioStateFlags& rSrcAttr) {
123 // call base (incl virtual clear)
124 AttributeFlags::DoAssign(rSrcAttr);
125}
126
127//DoWrite(rTw,rLabel,pContext);
128void HioStateFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
129 (void) rLabel; (void) pContext;
130 if(IsDefault()) return;
131 FD_DC("HioStateFlags(" << this << ")::DoWrite(tr)");
132 Token token;
133 if( (mFlags & ~mAllHioStateFlags) == 0 ) {
134 std::string option;
135 if(IsErr()) option = "Err";
136 switch (mFlags&0xFF) // AllHioStateFlags but not ErrFlag
137 {
138 case 1: option = option+"QY"; break; //0000 0001
139 case 2: option = option+"QU"; break; //0000 0010
140 case 4: option = option+"QC"; break; //0000 0100
141 case 6: option = option+"QUc"; break; //0000 0110
142 case 8: option = option+"QP"; break; //0000 1000
143 case 9: option = option+"QYp"; break; //0000 1001
144 case 10: option = option+"QUp"; break; //0000 1010
145 case 16: option = option+"QE"; break; //0001 0000
146 case 17: option = option+"QYe"; break; //0001 0001
147 case 18: option = option+"QUe"; break; //0001 0010
148 case 25: option = option+"QYpYe"; break; //0001 1001
149 case 32: option = option+"QL"; break; //0010 0000
150 case 34: option = option+"QUl"; break; //0010 0010
151 case 64: option = option+"QYcUp"; break; //0100 0000
152 case 128: option = option+"QYlUe"; break; //1000 0000
153
154 default: if( !IsErr() ) option = option+"??"; break;
155 }
156
157 token.SetOption(option);
158 }
159 // if other flags used, write hex
160 else {
161 token.SetInteger16(mFlags);
162 }
163 rTw << token;
164 }
165
166//ToString()
167std::string HioStateFlags::ToString(void) const {
169}
170
171//DoRead(rTw,rLabel,pContext);
172void HioStateFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
173 (void) rLabel;
174 (void) pContext;
175 // initialize with dfeualt
177 Token token;
178 rTr.Peek(token);
179 // faudes format, flags as integer
180 if(token.IsInteger16()) {
181 AttributeFlags::DoRead(rTr,rLabel,pContext);
182 return;
183 }
184 // faudes format, flags as option string
185 if(token.IsOption()) {
186 rTr.Get(token);
187 std::string option=token.OptionValue();
188
189 if(option.find( "QY", 0) != std::string::npos){ SetQY();}
190 if(option.find( "QU", 0) != std::string::npos){ SetQU();}
191 if(option.find( "QC", 0) != std::string::npos){ SetQC();}
192 if(option.find( "QUc", 0) != std::string::npos){ SetQU(); SetQC();}
193 if(option.find( "QP", 0) != std::string::npos){ SetQP();}
194 if(option.find( "QYp", 0) != std::string::npos){ SetQY(); SetQP();}
195 if(option.find( "QUp", 0) != std::string::npos){ SetQU(); SetQP();}
196 if(option.find( "QE", 0) != std::string::npos){ SetQE();}
197 if(option.find( "QYe", 0) != std::string::npos){ SetQY(); SetQE();}
198 if(option.find( "QUe", 0) != std::string::npos){ SetQU(); SetQE();}
199 if(option.find( "QYpYe", 0) != std::string::npos){ SetQY(); SetQP(); SetQE();}
200 if(option.find( "QL", 0) != std::string::npos){ SetQL();}
201 if(option.find( "QUl", 0) != std::string::npos){ SetQU(); SetQL();}
202 if(option.find( "QYcUp", 0) != std::string::npos){ SetQYcUp();}
203 if(option.find( "QYlUe", 0) != std::string::npos){ SetQYlUe();}
204 if(option.find( "Err", 0) != std::string::npos){ SetErr();}
205 return;
206 }
207 // xml format
208 while(true) {
209 rTr.Peek(token);
210 // explicit integer
211 if(token.IsBegin("Flags")) {
212 AttributeFlags::DoRead(rTr,rLabel,pContext);
213 continue;
214 }
215 // known bits
216 /*
217 xml format not yet implemented,
218 see iosystem for template
219 */
220 // stop at unknown tag
221 break;
222 }
223}
224
225
226
227
228} //End namespace
#define FD_DC(message)
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
Definition cfl_types.h:958
void DoAssign(const AttributeFlags &rSrcAttr)
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
static const fType mAllHioEventFlags
static const fType mDefHioEventFlags
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
bool IsDefault(void) const
static const fType mDefHioStateFlags
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
virtual std::string ToString(void) const
static const fType mAllHioStateFlags
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
bool IsDefault(void) const
bool IsErr(void) const
bool Get(Token &token)
bool Peek(Token &token)
bool IsInteger16(void) const
void SetInteger16(const Int number)
void SetOption(const std::string &rName)
bool IsBegin(void) const
const std::string & OptionValue(void) const
bool IsOption(void) const
std::string ToStringInteger16(Int number)
Definition cfl_utils.cpp:54

libFAUDES 2.33k --- 2025.09.16 --- c++ api documentaion by doxygen