hio_attributes.cppGo to the documentation of this file.00001 /** @file hio_attributes.cpp Event and state attributes for hierarchical I/O systems */ 00002 00003 /* Hierarchical IO Systems Plug-In for FAU Discrete Event Systems Library (libfaudes) 00004 00005 Copyright (C) 2006 Sebastian Perk 00006 Copyright (C) 2006 Thomas Moor 00007 Copyright (C) 2006 Klaus Schmidt 00008 00009 */ 00010 00011 #include "hio_attributes.h" 00012 00013 namespace faudes { 00014 00015 00016 /*********************************************************************************** 00017 * 00018 * implementation of HioEventFlags 00019 * 00020 */ 00021 00022 // faudes type std 00023 FAUDES_TYPE_IMPLEMENTATION(Void,HioEventFlags,AttributeFlags) 00024 00025 // Assign my members 00026 void HioEventFlags::DoAssign(const HioEventFlags& rSrcAttr) { 00027 // call base (incl virtual clear) 00028 AttributeFlags::DoAssign(rSrcAttr); 00029 } 00030 00031 //DoWrite(rTw,rLabel,pContext); 00032 void HioEventFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const { 00033 00034 (void) rLabel; (void) pContext; 00035 if(IsDefault()) return; 00036 FD_DC("HioEventFlags(" << this << ")::DoWrite(tr)"); 00037 00038 Token token; 00039 if( (mFlags & ~mAllHioEventFlags) == 0 ) { 00040 std::string option; 00041 switch (mFlags) 00042 { 00043 case 4: option = "U";break; //0000 0100 00044 case 8: option = "Y";break; //0000 1000 00045 case 36: option = "UE";break; //0010 0100 00046 case 40: option = "YE";break; //0010 1000 00047 case 20: option = "UP";break; //0001 0100 00048 case 24: option = "YP";break; //0001 1000 00049 case 68: option = "UC";break; //0100 0100 00050 case 72: option = "YC";break; //0100 1000 00051 case 132: option = "UL";break; //1000 0100 00052 case 136: option = "YL";break; //1000 1000 00053 default: option = "??";break; 00054 } 00055 token.SetOption(option); 00056 } 00057 // if other flags used, write hex 00058 else { 00059 token.SetInteger16(mFlags); 00060 } 00061 rTw << token; 00062 } 00063 //} 00064 00065 00066 //DoRead(rTw,rLabel,pContext); 00067 void HioEventFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) { 00068 (void) rLabel; 00069 (void) pContext; 00070 // initialize with dfeualt 00071 mFlags=mDefHioEventFlags; 00072 Token token; 00073 rTr.Peek(token); 00074 // faudes format, flags as integer 00075 if(token.IsInteger16()) { 00076 AttributeFlags::DoRead(rTr,rLabel,pContext); 00077 return; 00078 } 00079 // faudes format, flags as option string 00080 if(token.IsOption()) { 00081 rTr.Get(token); 00082 std::string option=token.OptionValue(); 00083 00084 if(option.find( 'Y', 0) != std::string::npos) SetY(); 00085 if(option.find( 'U', 0) != std::string::npos) SetU(); 00086 if(option.find( 'P', 0) != std::string::npos){ SetP(); ClrE();} 00087 if(option.find( 'E', 0) != std::string::npos){ SetE(); ClrP();} 00088 if(option.find( 'C', 0) != std::string::npos){ SetC(); ClrP();} 00089 if(option.find( 'L', 0) != std::string::npos){ SetL(); ClrE();} 00090 return; 00091 } 00092 // xml format 00093 while(true) { 00094 rTr.Peek(token); 00095 // explicit integer 00096 if(token.IsBegin("Flags")) { 00097 AttributeFlags::DoRead(rTr,rLabel,pContext); 00098 continue; 00099 } 00100 // known bits 00101 /* 00102 xml format not yet implemented, 00103 see iosystem for template 00104 */ 00105 // stop at unknown tag 00106 break; 00107 } 00108 } 00109 00110 00111 /*********************************************************************************** 00112 * 00113 * implementation of HioStateFlags 00114 * 00115 */ 00116 /***************************************************************************/ 00117 00118 // faudes type std 00119 FAUDES_TYPE_IMPLEMENTATION(Void,HioStateFlags,AttributeFlags) 00120 00121 // Assign my members 00122 void HioStateFlags::DoAssign(const HioStateFlags& rSrcAttr) { 00123 // call base (incl virtual clear) 00124 AttributeFlags::DoAssign(rSrcAttr); 00125 } 00126 00127 //DoWrite(rTw,rLabel,pContext); 00128 void HioStateFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const { 00129 (void) rLabel; (void) pContext; 00130 if(IsDefault()) return; 00131 FD_DC("HioStateFlags(" << this << ")::DoWrite(tr)"); 00132 Token token; 00133 if( (mFlags & ~mAllHioStateFlags) == 0 ) { 00134 std::string option; 00135 if(IsErr()) option = "Err"; 00136 switch (mFlags&0xFF) // AllHioStateFlags but not ErrFlag 00137 { 00138 case 1: option = option+"QY"; break; //0000 0001 00139 case 2: option = option+"QU"; break; //0000 0010 00140 case 4: option = option+"QC"; break; //0000 0100 00141 case 6: option = option+"QUc"; break; //0000 0110 00142 case 8: option = option+"QP"; break; //0000 1000 00143 case 9: option = option+"QYp"; break; //0000 1001 00144 case 10: option = option+"QUp"; break; //0000 1010 00145 case 16: option = option+"QE"; break; //0001 0000 00146 case 17: option = option+"QYe"; break; //0001 0001 00147 case 18: option = option+"QUe"; break; //0001 0010 00148 case 25: option = option+"QYpYe"; break; //0001 1001 00149 case 32: option = option+"QL"; break; //0010 0000 00150 case 34: option = option+"QUl"; break; //0010 0010 00151 case 64: option = option+"QYcUp"; break; //0100 0000 00152 case 128: option = option+"QYlUe"; break; //1000 0000 00153 00154 default: if( !IsErr() ) option = option+"??"; break; 00155 } 00156 00157 token.SetOption(option); 00158 } 00159 // if other flags used, write hex 00160 else { 00161 token.SetInteger16(mFlags); 00162 } 00163 rTw << token; 00164 } 00165 00166 //ToString() 00167 std::string HioStateFlags::ToString(void) const { 00168 return ToStringInteger16(mFlags); 00169 } 00170 00171 //DoRead(rTw,rLabel,pContext); 00172 void HioStateFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) { 00173 (void) rLabel; 00174 (void) pContext; 00175 // initialize with dfeualt 00176 mFlags=mDefHioStateFlags; 00177 Token token; 00178 rTr.Peek(token); 00179 // faudes format, flags as integer 00180 if(token.IsInteger16()) { 00181 AttributeFlags::DoRead(rTr,rLabel,pContext); 00182 return; 00183 } 00184 // faudes format, flags as option string 00185 if(token.IsOption()) { 00186 rTr.Get(token); 00187 std::string option=token.OptionValue(); 00188 00189 if(option.find( "QY", 0) != std::string::npos){ SetQY();} 00190 if(option.find( "QU", 0) != std::string::npos){ SetQU();} 00191 if(option.find( "QC", 0) != std::string::npos){ SetQC();} 00192 if(option.find( "QUc", 0) != std::string::npos){ SetQU(); SetQC();} 00193 if(option.find( "QP", 0) != std::string::npos){ SetQP();} 00194 if(option.find( "QYp", 0) != std::string::npos){ SetQY(); SetQP();} 00195 if(option.find( "QUp", 0) != std::string::npos){ SetQU(); SetQP();} 00196 if(option.find( "QE", 0) != std::string::npos){ SetQE();} 00197 if(option.find( "QYe", 0) != std::string::npos){ SetQY(); SetQE();} 00198 if(option.find( "QUe", 0) != std::string::npos){ SetQU(); SetQE();} 00199 if(option.find( "QYpYe", 0) != std::string::npos){ SetQY(); SetQP(); SetQE();} 00200 if(option.find( "QL", 0) != std::string::npos){ SetQL();} 00201 if(option.find( "QUl", 0) != std::string::npos){ SetQU(); SetQL();} 00202 if(option.find( "QYcUp", 0) != std::string::npos){ SetQYcUp();} 00203 if(option.find( "QYlUe", 0) != std::string::npos){ SetQYlUe();} 00204 if(option.find( "Err", 0) != std::string::npos){ SetErr();} 00205 return; 00206 } 00207 // xml format 00208 while(true) { 00209 rTr.Peek(token); 00210 // explicit integer 00211 if(token.IsBegin("Flags")) { 00212 AttributeFlags::DoRead(rTr,rLabel,pContext); 00213 continue; 00214 } 00215 // known bits 00216 /* 00217 xml format not yet implemented, 00218 see iosystem for template 00219 */ 00220 // stop at unknown tag 00221 break; 00222 } 00223 } 00224 00225 00226 00227 00228 } //End namespace libFAUDES 2.23h --- 2014.04.03 --- c++ api documentaion by doxygen |