About
User Reference
C++ API
luafaudes
Developer
Links
libFAUDES online
libFAUDES

Sections

Index

hio_attributes.cpp

Go 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; (void) pContext;
00069     mFlags=mDefHioEventFlags;
00070   Token token;
00071   rTr.Peek(token);
00072   if(token.IsInteger16()) { 
00073     rTr.Get(token);
00074     mFlags=token.IntegerValue();
00075     return;
00076   } 
00077   if(token.IsOption()) { 
00078     rTr.Get(token);
00079     std::string option=token.OptionValue();
00080 
00081     if(option.find( 'Y', 0) != std::string::npos) SetY();
00082     if(option.find( 'U', 0) != std::string::npos) SetU();
00083     if(option.find( 'P', 0) != std::string::npos){ SetP(); ClrE();}
00084     if(option.find( 'E', 0) != std::string::npos){ SetE(); ClrP();}
00085     if(option.find( 'C', 0) != std::string::npos){ SetC(); ClrP();}
00086     if(option.find( 'L', 0) != std::string::npos){ SetL(); ClrE();}
00087     return;
00088   }
00089 }
00090 
00091 
00092 /***********************************************************************************
00093  *
00094  * implementation of HioStateFlags 
00095  *
00096  */
00097 /***************************************************************************/
00098 
00099 // faudes type std
00100 FAUDES_TYPE_IMPLEMENTATION(Void,HioStateFlags,AttributeFlags)
00101 
00102 // Assign my members
00103 void HioStateFlags::DoAssign(const HioStateFlags& rSrcAttr) { 
00104   // call base (incl virtual clear)
00105   AttributeFlags::DoAssign(rSrcAttr);
00106 }
00107 
00108 //DoWrite(rTw,rLabel,pContext);
00109 void HioStateFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00110   (void) rLabel; (void) pContext;
00111   if(IsDefault()) return;
00112   FD_DC("HioStateFlags(" << this << ")::DoWrite(tr)");
00113     Token token;
00114     if( (mFlags & ~mAllHioStateFlags) == 0 ) {
00115       std::string option;
00116       if(IsErr()) option = "Err";
00117     switch (mFlags&0xFF) // AllHioStateFlags but not ErrFlag
00118     {
00119            case   1: option = option+"QY";     break; //0000 0001
00120            case   2: option = option+"QU";     break; //0000 0010
00121            case   4: option = option+"QC";     break; //0000 0100
00122            case   6: option = option+"QUc";     break; //0000 0110
00123            case   8: option = option+"QP";     break; //0000 1000
00124            case   9: option = option+"QYp";     break; //0000 1001
00125            case   10: option = option+"QUp";     break; //0000 1010
00126            case  16: option = option+"QE";     break; //0001 0000
00127            case  17: option = option+"QYe";     break; //0001 0001
00128            case  18: option = option+"QUe";     break; //0001 0010
00129            case  25: option = option+"QYpYe";     break; //0001 1001
00130            case  32: option = option+"QL";     break; //0010 0000
00131            case  34: option = option+"QUl";     break; //0010 0010
00132            case  64: option = option+"QYcUp"; break; //0100 0000
00133            case 128: option = option+"QYlUe"; break; //1000 0000
00134            
00135            default: if( !IsErr() ) option = option+"??";      break;
00136            }
00137       
00138       token.SetOption(option);
00139     } 
00140     // if other flags used, write hex
00141     else { 
00142       token.SetInteger16(mFlags);
00143     }
00144     rTw << token;
00145   }
00146 
00147 //ToString()
00148 std::string HioStateFlags::ToString(void) const {
00149   return ToStringInteger16(mFlags);
00150 }
00151 
00152 //DoRead(rTw,rLabel,pContext);
00153 void HioStateFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00154   (void) rLabel; (void) pContext;
00155   mFlags=mDefHioStateFlags;
00156   Token token;
00157   rTr.Peek(token);
00158   if(token.IsInteger16()) { 
00159     rTr.Get(token);
00160     mFlags=token.IntegerValue();
00161     return;
00162   } 
00163   if(token.IsOption()) { 
00164     rTr.Get(token);
00165     std::string option=token.OptionValue();
00166 
00167     if(option.find( "QY", 0) != std::string::npos){ SetQY();}
00168     if(option.find( "QU", 0) != std::string::npos){ SetQU();}
00169     if(option.find( "QC", 0) != std::string::npos){ SetQC();}
00170     if(option.find( "QUc", 0) != std::string::npos){ SetQU(); SetQC();}
00171     if(option.find( "QP", 0) != std::string::npos){ SetQP();}
00172     if(option.find( "QYp", 0) != std::string::npos){ SetQY(); SetQP();}
00173     if(option.find( "QUp", 0) != std::string::npos){ SetQU(); SetQP();}
00174     if(option.find( "QE", 0) != std::string::npos){ SetQE();}
00175     if(option.find( "QYe", 0) != std::string::npos){ SetQY(); SetQE();}
00176     if(option.find( "QUe", 0) != std::string::npos){ SetQU(); SetQE();}
00177     if(option.find( "QYpYe", 0) != std::string::npos){ SetQY(); SetQP(); SetQE();}
00178     if(option.find( "QL", 0) != std::string::npos){ SetQL();}
00179     if(option.find( "QUl", 0) != std::string::npos){ SetQU(); SetQL();}
00180     if(option.find( "QYcUp", 0) != std::string::npos){ SetQYcUp();}
00181     if(option.find( "QYlUe", 0) != std::string::npos){ SetQYlUe();}
00182     if(option.find( "Err", 0) != std::string::npos){ SetErr();}
00183     return;
00184   } 
00185  }
00186 } //End namespace

libFAUDES 2.20s --- 2011.10.12 --- c++ source docu by doxygen