ios_attributes.cpp
Go to the documentation of this file.
1/** @file ios_attributes.cpp I/O-system attributes */
2
3/*
4 Standart IO Systems Plug-In for FAU Discrete Event Systems
5 Library (libfaudes)
6
7 Copyright (C) 2010, Thomas Wittmann, Thomas Moor
8
9*/
10
11
12#include "ios_attributes.h"
13#include <cfl_types.h>
14
15namespace faudes {
16
17
18/*
19*********************************************************************************
20*********************************************************************************
21*********************************************************************************
22
23Implementation: event attributes
24
25*********************************************************************************
26*********************************************************************************
27*********************************************************************************
28*/
29
30
31// faudes type std
32FAUDES_TYPE_IMPLEMENTATION(Void,AttributeIosEvent,AttributeFlags)
33
34
35// Assign my members
36void AttributeIosEvent::DoAssign(const AttributeIosEvent& rSrcAttr) {
37 // call base (incl virtual clear)
39}
40
41
42//DoWrite(rTw,rLabel,pContext);
44 const std::string& rLabel,
45 const Type* pContext) const
46{
47 (void) rLabel;
48 (void) pContext;
49 // dont write default values
50 if(IsDefault()) return;
51 // debug output
52 FD_DC("AttributeIosEvent(" << this << ")::DoWrite(tr)");
53 Token token;
54 // if further flags are used, let base class write with base 16
55 if( (mFlags & ~mAllIosFlags) != 0 ) {
56 AttributeFlags::DoWrite(rTw,rLabel,pContext);
57 return;
58 }
59 // write my flags symbolically
60 std::string option;
61 switch (mFlags){
62 case 0x10:
63 option = "I";
64 break;
65 case 0x20:
66 option = "O";
67 break;
68 default:
69 option = "IO";
70 break;
71 }
72 rTw.WriteOption(option);
73}
74
75
76//XWrite(rTw)
77void AttributeIosEvent::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
78 (void) rLabel; (void) pContext;
79 if(IsDefault()) return;
80 FD_DC("AttributeIosEvent(" << this << ")::DoXWrite(tw)");
81 Token token;
82 // if further flags are used, let base cxlass write with base 16
83 if( (mFlags & ~mAllIosFlags) != 0 ) {
84 AttributeFlags::DoXWrite(rTw,rLabel,pContext);
85 }
86 // write friendly tags anyway
88 token.SetEmpty("Input");
89 if(!Input()) token.InsAttributeBoolean("value",0);
90 rTw.Write(token);
91 }
93 token.SetEmpty("Output");
94 if(!Output()) token.InsAttributeBoolean("value",0);
95 rTw.Write(token);
96 }
97}
98
99
100
101
102//DoRead(rTw,rLabel,pContext);
104 TokenReader& rTr,
105 const std::string& rLabel,
106 const Type* pContext)
107{
108 (void) rLabel;
109 (void) pContext;
110 // initialize with default value
112 Token token;
113 rTr.Peek(token);
114 // faudes format, flags as integer
115 if(token.IsInteger16()) {
116 AttributeFlags::DoRead(rTr,rLabel,pContext);
117 return;
118 }
119 // faudes format, flags as option string
120 if(token.IsOption()) {
121 rTr.Get(token);
122 std::string option=token.OptionValue();
123 if(option.find( 'I', 0) != std::string::npos) SetInput();
124 if(option.find( 'i', 0) != std::string::npos) ClrInput();
125 if(option.find( 'O', 0) != std::string::npos) SetOutput();
126 if(option.find( 'o', 0) != std::string::npos) ClrOutput();
127 return;
128 }
129 // xml format
130 while(true) {
131 rTr.Peek(token);
132 // explicit integer
133 if(token.IsBegin("Flags")) {
134 AttributeFlags::DoRead(rTr,rLabel,pContext);
135 continue;
136 }
137 // known bits
138 if(token.IsBegin("Input")) {
139 rTr.ReadBegin("Input",token);
140 SetInput();
141 if(token.ExistsAttributeInteger("value"))
142 if(token.AttributeIntegerValue("value")==false)
143 ClrInput();
144 rTr.ReadEnd("Input");
145 continue;
146 }
147 if(token.IsBegin("Output")) {
148 rTr.ReadBegin("Output",token);
149 SetOutput();
150 if(token.ExistsAttributeInteger("value"))
151 if(token.AttributeIntegerValue("value")==false)
152 ClrOutput();
153 rTr.ReadEnd("Output");
154 continue;
155 }
156 // stop at unknown tag
157 break;
158 }
159}
160
161
162/*
163*********************************************************************************
164*********************************************************************************
165*********************************************************************************
166
167Implementation: state attributes
168
169*********************************************************************************
170*********************************************************************************
171*********************************************************************************
172*/
173
174
175
176// faudes type std
178
179//DoAssign( rSrcAttr )
180void AttributeIosState::DoAssign(const AttributeIosState& rSrcAttr) {
181 // call base (incl virtual clear)
182 AttributeFlags::DoAssign(rSrcAttr);
183}
184
185
186//ToString()
187std::string AttributeIosState::ToString(void) const {
189}
190
191
192//DoWrite(rTw,rLabel,pContext);
194 const std::string& rLabel,
195 const Type* pContext) const
196{
197 (void) rLabel;
198 (void) pContext;
199 // dont wrtite default value
200 if(IsDefault()) return;
201 FD_DC("AttributeIosState(" << this << ")::DoWrite(tr)");
202 // if further flags are used, let base class write with base 16
203 if( (mFlags & ~mAllIosFlags) != 0 ) {
204 AttributeFlags::DoWrite(rTw,rLabel,pContext);
205 return;
206 }
207 // write my flags symbolically
208 std::string option;
209 if(Input()) option+="I";
210 if(Output()) option+="O";
211 if(Error()) option+="E";
212 if(option!="")
213 rTw.WriteOption(option);
214}
215
216
217//XWrite(rTw)
218void AttributeIosState::DoXWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
219 (void) rLabel; (void) pContext;
220 if(IsDefault()) return;
221 FD_DC("AttributeIosState(" << this << ")::DoXWrite(tw)");
222 Token token;
223 // if further flags are used, let base class write with base 16
224 if( (mFlags & ~mAllIosFlags) != 0 ) {
225 AttributeFlags::DoXWrite(rTw,rLabel,pContext);
226 }
227 // write friendly tags anyway
229 token.SetEmpty("Input");
230 if(!Input()) token.InsAttributeBoolean("value",0);
231 rTw.Write(token);
232 }
234 token.SetEmpty("Output");
235 if(!Output()) token.InsAttributeBoolean("value",0);
236 rTw.Write(token);
237 }
239 token.SetEmpty("Error");
240 if(!Error()) token.InsAttributeBoolean("value",0);
241 rTw.Write(token);
242 }
243}
244
245
246
247//DoRead(rTw,rLabel,pContext);
249 TokenReader& rTr,
250 const std::string& rLabel,
251 const Type* pContext)
252{
253 (void) rLabel;
254 (void) pContext;
255 // initialize with default value
257 Token token;
258 rTr.Peek(token);
259 // faudes format, flags as integer
260 if(token.IsInteger16()) {
261 AttributeFlags::DoRead(rTr,rLabel,pContext);
262 return;
263 }
264 // faudes format, flags as option string
265 if(token.IsOption()) {
266 rTr.Get(token);
267 std::string option=token.OptionValue();
268 if(option.find( 'I', 0) != std::string::npos) SetInput();
269 if(option.find( 'i', 0) != std::string::npos) ClrInput();
270 if(option.find( 'O', 0) != std::string::npos) SetOutput();
271 if(option.find( 'o', 0) != std::string::npos) ClrOutput();
272 if(option.find( 'E', 0) != std::string::npos) SetError();
273 if(option.find( 'e', 0) != std::string::npos) ClrError();
274 return;
275 }
276 // xml format
277 while(true) {
278 rTr.Peek(token);
279 // explicit integer
280 if(token.IsBegin("Flags")) {
281 AttributeFlags::DoRead(rTr,rLabel,pContext);
282 continue;
283 }
284 // known bits
285 if(token.IsBegin("Input")) {
286 rTr.ReadBegin("Input",token);
287 SetInput();
288 if(token.ExistsAttributeInteger("value"))
289 if(token.AttributeIntegerValue("value")==false)
290 ClrInput();
291 rTr.ReadEnd("Input");
292 continue;
293 }
294 if(token.IsBegin("Output")) {
295 rTr.ReadBegin("Output",token);
296 SetOutput();
297 if(token.ExistsAttributeInteger("value"))
298 if(token.AttributeIntegerValue("value")==false)
299 ClrOutput();
300 rTr.ReadEnd("Output");
301 continue;
302 }
303 if(token.IsBegin("Error")) {
304 rTr.ReadBegin("Error",token);
305 SetError();
306 if(token.ExistsAttributeInteger("value"))
307 if(token.AttributeIntegerValue("value")==false)
308 ClrError();
309 rTr.ReadEnd("Error");
310 continue;
311 }
312 // stop at unknown tag
313 break;
314 }
315}
316
317
318
319}//end namespace faudes
#define FD_DC(message)
#define FAUDES_TYPE_IMPLEMENTATION(ftype, ctype, cbase)
Definition cfl_types.h:958
virtual void DoXWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
void DoAssign(const AttributeFlags &rSrcAttr)
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
virtual void DoXWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
static const fType mInputFlag
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
static const fType mDefIosFlags
static const fType mOutputFlag
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
static const fType mAllIosFlags
static const fType mDefIosFlags
static const fType mErrorFlag
virtual void DoRead(TokenReader &rTr, const std::string &rLabel="", const Type *pContext=0)
virtual void DoXWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
static const fType mOutputFlag
static const fType mInputFlag
static const fType mAllIosFlags
virtual std::string ToString(void) const
virtual void DoWrite(TokenWriter &rTw, const std::string &rLabel="", const Type *pContext=0) const
void ReadEnd(const std::string &rLabel)
void ReadBegin(const std::string &rLabel)
bool Get(Token &token)
bool Peek(Token &token)
void Write(Token &rToken)
void WriteOption(const std::string &rOpt)
bool IsInteger16(void) const
Int AttributeIntegerValue(const std::string &name)
void InsAttributeBoolean(const std::string &name, Int value)
bool IsBegin(void) const
void SetEmpty(const std::string &rName)
const std::string & OptionValue(void) const
bool ExistsAttributeInteger(const std::string &name)
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