ios_attributes.hGo to the documentation of this file.00001 /** @file ios_attributes.h I/O-system attributes */ 00002 00003 /* 00004 IO Systems Plug-In 00005 for FAU Discrete Event Systems Library (libFAUDES) 00006 00007 Copyright (C) 2010, Thomas Wittmann, Thomas Moor 00008 00009 */ 00010 00011 #ifndef FAUDES_IOS_ATTRIBUTES_H 00012 #define FAUDES_IOS_ATTRIBUTES_H 00013 00014 // debugging: 00015 #ifdef FAUDES_DEBUG_IOSYS 00016 #define FD_DIO(message) FAUDES_WRITE_CONSOLE("FAUDES_IOSYS: " << message) 00017 #else 00018 #define FD_DIO(message) 00019 #endif 00020 00021 #include "corefaudes.h" 00022 00023 namespace faudes { 00024 00025 00026 /** 00027 * Attributes for events in DES with in- and outputs 00028 * 00029 * The class AttributeIosEvent holds a bitarray to handle an event's io-properties 00030 * 00031 * In order to envolve the event's io-properties during file-io 00032 * the DoRead/DoWrite methods were overwritten. Use Attributes 00033 * +I+ and +O+ in .gen file to make sure an event will be inserted in 00034 * Iput or OTput event set. 00035 * 00036 * @ingroup iosysplugin 00037 */ 00038 00039 class AttributeIosEvent : public AttributeFlags { 00040 00041 FAUDES_TYPE_DECLARATION(Void,AttributeIosEvent,AttributeFlags ) 00042 00043 public: 00044 00045 00046 /** 00047 * Default constructor 00048 */ 00049 AttributeIosEvent(void) : AttributeFlags() { 00050 mFlags=mDefIosFlags; 00051 } 00052 00053 /** 00054 * Copy constructor 00055 */ 00056 AttributeIosEvent(const AttributeIosEvent& rSrc) : AttributeFlags() { 00057 mFlags=rSrc.mFlags; 00058 }; 00059 00060 /** 00061 * Destructor 00062 */ 00063 virtual ~AttributeIosEvent(void) { 00064 }; 00065 00066 /** 00067 * Set output flag 00068 * 00069 * Note: this will clear the input flag. 00070 * 00071 */ 00072 void SetOutput(void) { 00073 mFlags |= mOutputFlag; 00074 } 00075 00076 /** 00077 * Clear output flag 00078 * 00079 * Note: this will clear the input flag. 00080 * 00081 */ 00082 void ClrOutput(void) { 00083 mFlags &= ~mOutputFlag; 00084 }; 00085 00086 /** 00087 * Set input flag 00088 * 00089 * Note: this will clear the output flag. 00090 * 00091 */ 00092 void SetInput(void) { 00093 mFlags |= mInputFlag; 00094 } 00095 00096 00097 /** 00098 * Clear input flag 00099 * 00100 * Note: this will clear the input flag. 00101 * 00102 */ 00103 void ClrInput(void) { 00104 mFlags &= ~mInputFlag; 00105 }; 00106 00107 /** 00108 * Test output flag 00109 * 00110 * @return 00111 * true: state is an output state 00112 * false: state is not an output state 00113 */ 00114 bool Output(void) const { 00115 return (mFlags & mOutputFlag) != 0 ; 00116 } 00117 00118 00119 /** 00120 * Test input flag 00121 * 00122 * @return 00123 * true: state is an input state 00124 * false: state is not an input state 00125 */ 00126 bool Input(void) const { 00127 return (mFlags & mInputFlag) != 0; 00128 } 00129 00130 00131 00132 /** 00133 * Check an event's io-properties for default value. 00134 * 00135 * If an event has default properties, it's wether an input 00136 * nor to output event. 00137 * 00138 * @return 00139 * true: event has default properties 00140 * false: event has non-default properties 00141 */ 00142 bool IsDefault(void) const { 00143 return mFlags==mDefIosFlags; 00144 } 00145 00146 protected: 00147 00148 // flag masks for the event properties 00149 const static fType mInputFlag =0x010; 00150 const static fType mOutputFlag =0x020; 00151 00152 // overall default value 00153 const static fType mDefIosFlags =0x000 ; 00154 00155 // all flags 00156 const static fType mAllIosFlags =0x030; 00157 00158 00159 /** 00160 * Assignment method. 00161 * 00162 * @param rSrcAttr 00163 * Source to assign from 00164 */ 00165 void DoAssign(const AttributeIosEvent& rSrcAttr); 00166 00167 00168 /** 00169 * Reads attribute from TokenReader, see AttributeVoid for public wrappers. 00170 * Reads a single token if it can be interpreted as IosEventFlag, that is, if 00171 * it is a respective option string or hex number. Label and Context 00172 * argument are ignored. No token mismatch exceptions are thrown on error. 00173 * 00174 * @param rTr 00175 * TokenReader to read from 00176 * @param rLabel 00177 * Section to read 00178 * @param pContext 00179 * Read context to provide contextual information 00180 * @exception Exception 00181 * - IO error (id 1) 00182 */ 00183 virtual void DoRead(TokenReader& rTr, 00184 const std::string& rLabel="", 00185 const Type* pContext=0); 00186 00187 /** 00188 * Writes attribute to TokenWriter, see AttributeVoid for public wrappers. 00189 * Label and Context argument are ignored. 00190 * 00191 * @param rTw 00192 * TokenWriter to write to 00193 * @param rLabel 00194 * Section to write 00195 * @param pContext 00196 * Write context to provide contextual information 00197 * 00198 * @exception Exception 00199 * - IO error (id 2) 00200 */ 00201 virtual void DoWrite(TokenWriter& rTw, 00202 const std::string& rLabel="", 00203 const Type* pContext=0) const; 00204 00205 /** 00206 * Writes attribute to TokenWriter, see AttributeVoid for public wrappers. 00207 * Label and Context argument are ignored. 00208 * 00209 * @param rTw 00210 * TokenWriter to write to 00211 * @param rLabel 00212 * Section to write 00213 * @param pContext 00214 * Write context to provide contextual information 00215 * 00216 * @exception Exception 00217 * - IO error (id 2) 00218 */ 00219 virtual void DoXWrite(TokenWriter& rTw, 00220 const std::string& rLabel="", 00221 const Type* pContext=0) const; 00222 00223 }; // class AttributeIosEvent 00224 00225 00226 // Convenience typedef 00227 typedef TaNameSet<AttributeIosEvent> IosEventSet; 00228 00229 00230 00231 /** 00232 * Attributes for states in DESs with in- and outputs 00233 * 00234 * The class AttributeIosState holds a bitarray to handle a state's io-properties. 00235 * A state is said to be an in- or output state if the set of active events 00236 * contains only in- or output events. 00237 * 00238 * In order to envolve the state's io-properties during file-io 00239 * the DoRead/DoWrite methods were overwritten. Use +I+ for input, +O+ for 00240 * output states. 00241 * 00242 * @ingroup iosysplugin 00243 */ 00244 00245 class AttributeIosState : public AttributeFlags 00246 { 00247 00248 FAUDES_TYPE_DECLARATION(Void,AttributeIosState,AttributeFlags) 00249 00250 public: 00251 00252 /** 00253 * Default constructor 00254 */ 00255 AttributeIosState(void) : AttributeFlags() { 00256 mFlags=mDefIosFlags; 00257 }; 00258 00259 /** 00260 * Copy constructor 00261 */ 00262 AttributeIosState(const AttributeIosState& rSrc) : AttributeFlags() { 00263 mFlags=rSrc.mFlags; 00264 }; 00265 00266 /** 00267 * Destructor 00268 */ 00269 virtual ~AttributeIosState(void) {}; 00270 00271 /** 00272 * Set output flag 00273 * 00274 * Note: this will clear the input flag. 00275 * 00276 */ 00277 void SetOutput(void) { 00278 mFlags |= mOutputFlag; 00279 }; 00280 00281 /** 00282 * Clear output flag 00283 * 00284 * Note: this will clear the input flag. 00285 * 00286 */ 00287 void ClrOutput(void) { 00288 mFlags &= ~mOutputFlag; 00289 }; 00290 00291 /** 00292 * Set input flag 00293 * 00294 * Note: this will clear the output flag. 00295 * 00296 */ 00297 void SetInput(void) { 00298 mFlags |= mInputFlag; 00299 }; 00300 00301 00302 /** 00303 * Clear input flag 00304 * 00305 * Note: this will clear the input flag. 00306 * 00307 */ 00308 void ClrInput(void) { 00309 mFlags &= ~mInputFlag; 00310 }; 00311 00312 00313 /** 00314 * Set error flag 00315 * 00316 */ 00317 void SetError(void) { 00318 mFlags |= mErrorFlag; 00319 }; 00320 00321 00322 /** 00323 * Clear error flag 00324 * 00325 */ 00326 void ClrError(void) { 00327 mFlags &= ~mErrorFlag; 00328 }; 00329 00330 /** 00331 * Test output flag 00332 * 00333 * @return 00334 * true: state is an output state 00335 * false: state is not an output state 00336 */ 00337 bool Output(void) const { 00338 return (mFlags & mOutputFlag) != 0 ; 00339 }; 00340 00341 00342 /** 00343 * Test input flag 00344 * 00345 * @return 00346 * true: state is an input state 00347 * false: state is not an input state 00348 */ 00349 bool Input(void) const { 00350 return (mFlags & mInputFlag) != 0; 00351 }; 00352 00353 00354 00355 /** 00356 * Check error flag 00357 * 00358 * @return 00359 * true: state is an error state 00360 * false: state is not an error state 00361 */ 00362 bool Error(void) const { 00363 return (mFlags & mErrorFlag) != 0; 00364 }; 00365 00366 /** 00367 * Check a state's io-properties for default value. 00368 * 00369 * If a state has default properties, it's neither an input 00370 * nor to output state. 00371 * 00372 * @return 00373 * true: event has default properties 00374 * false: event has non-default properties 00375 */ 00376 bool IsDefault(void) const { 00377 return mFlags==mDefIosFlags; 00378 }; 00379 00380 // Flag masks for the 10 properties 00381 const static fType mInputFlag = 0x10; 00382 const static fType mOutputFlag = 0x20; 00383 const static fType mErrorFlag = 0x40; 00384 00385 /** 00386 * Write attribute to string 00387 * 00388 * @return 00389 * string representation of attributes 00390 * 00391 */ 00392 virtual std::string ToString(void) const; 00393 00394 00395 protected: 00396 00397 // Overall default value 00398 const static fType mDefIosFlags = 0x00; 00399 // All flags 00400 const static fType mAllIosFlags = 0x70; 00401 00402 00403 /** 00404 * Assignment method. 00405 * 00406 * @param rSrcAttr 00407 * Source to assign from 00408 */ 00409 void DoAssign(const AttributeIosState& rSrcAttr); 00410 00411 /** 00412 * Reads attribute from TokenReader, see AttributeVoid for public wrappers. 00413 * Reads a single token if it can be interpreted as IosStateFlag, that is, if 00414 * it is a respective option string or hex number. Label and Context 00415 * argument are ignored. No token mismatch exceptions are thrown on error. 00416 * 00417 * @param rTr 00418 * TokenReader to read from 00419 * @param rLabel 00420 * Section to read 00421 * @param pContext 00422 * Read context to provide contextual information 00423 * 00424 * @exception Exception 00425 * - IO error (id 1) 00426 */ 00427 00428 virtual void DoRead(TokenReader& rTr, const std::string& rLabel="", const Type* pContext=0); 00429 00430 /** 00431 * Writes attribute to TokenWriter, see AttributeVoid for public wrappers. 00432 * Label and Context argument are ignored. 00433 * 00434 * @param rTw 00435 * TokenWriter to write to 00436 * @param rLabel 00437 * Section to write 00438 * @param pContext 00439 * Write context to provide contextual information 00440 * 00441 * @exception Exception 00442 * - IO error (id 2) 00443 */ 00444 virtual void DoWrite(TokenWriter& rTw,const std::string& rLabel="", const Type* pContext=0) const; 00445 00446 /** 00447 * Writes attribute to TokenWriter, see AttributeVoid for public wrappers. 00448 * Label and Context argument are ignored. 00449 * 00450 * @param rTw 00451 * TokenWriter to write to 00452 * @param rLabel 00453 * Section to write 00454 * @param pContext 00455 * Write context to provide contextual information 00456 * 00457 * @exception Exception 00458 * - IO error (id 2) 00459 */ 00460 virtual void DoXWrite(TokenWriter& rTw, 00461 const std::string& rLabel="", 00462 const Type* pContext=0) const; 00463 00464 }; 00465 00466 00467 // convenience typedef 00468 typedef TaIndexSet<AttributeIosState> IosStateSet; 00469 00470 00471 00472 00473 00474 }// end namespace faudes 00475 #endif libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |