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(HioEventFlags,AttributeFlags)
00024 
00025 // Assign my members
00026 HioEventFlags& HioEventFlags::DoAssign(const HioEventFlags& rSrcAttr) { 
00027   // call base (incl virtual clear)
00028   AttributeFlags::DoAssign(rSrcAttr);
00029   // no additional members
00030   return *this;
00031 }
00032 
00033 //DoWrite(rTw,rLabel,pContext);
00034 void HioEventFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {  
00035 
00036   (void) rLabel; (void) pContext;
00037   if(IsDefault()) return;
00038   FD_DC("HioEventFlags(" << this << ")::DoWrite(tr)");
00039   
00040     Token token;
00041     if( (mFlags & ~mAllHioEventFlags) == 0 ) {
00042       std::string option;
00043     switch (mFlags)
00044     {
00045            case 4:  option = "U";break; //0000 0100
00046            case 8:  option = "Y";break; //0000 1000
00047            case 36:  option = "UE";break; //0010 0100
00048            case 40:  option = "YE";break; //0010 1000
00049            case 20:  option = "UP";break; //0001 0100
00050            case 24:  option = "YP";break; //0001 1000
00051            case 68:  option = "UC";break; //0100 0100
00052            case 72:  option = "YC";break; //0100 1000
00053            case 132: option = "UL";break; //1000 0100
00054            case 136: option = "YL";break; //1000 1000
00055            default:  option = "??";break;
00056            }
00057       token.SetOption(option);
00058     } 
00059     // if other flags used, write hex
00060     else { 
00061       token.SetInteger16(mFlags);
00062     }
00063     rTw << token;
00064   }
00065 //}
00066 
00067 
00068 //DoRead(rTw,rLabel,pContext);
00069 void HioEventFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00070   (void) rLabel; (void) pContext;
00071     mFlags=mDefHioEventFlags;
00072   Token token;
00073   rTr.Peek(token);
00074   if(token.Type()==Token::Integer16) { 
00075     rTr.Get(token);
00076     mFlags=token.IntegerValue();
00077     return;
00078   } 
00079   if(token.Type()==Token::Option) { 
00080     rTr.Get(token);
00081     std::string option=token.StringValue();
00082 
00083     if(option.find( 'Y', 0) != std::string::npos) SetY();
00084     if(option.find( 'U', 0) != std::string::npos) SetU();
00085     if(option.find( 'P', 0) != std::string::npos){ SetP(); ClrE();}
00086     if(option.find( 'E', 0) != std::string::npos){ SetE(); ClrP();}
00087     if(option.find( 'C', 0) != std::string::npos){ SetC(); ClrP();}
00088     if(option.find( 'L', 0) != std::string::npos){ SetL(); ClrE();}
00089     return;
00090   }
00091 }
00092 
00093 
00094 /***********************************************************************************
00095  *
00096  * implementation of HioStateFlags 
00097  *
00098  */
00099 /***************************************************************************/
00100 
00101 // faudes type std
00102 FAUDES_TYPE_IMPLEMENTATION(HioStateFlags,AttributeFlags)
00103 
00104 // Assign my members
00105 HioStateFlags& HioStateFlags::DoAssign(const HioStateFlags& rSrcAttr) { 
00106   // call base (incl virtual clear)
00107   AttributeFlags::DoAssign(rSrcAttr);
00108   // no additional members
00109   return *this;
00110 }
00111 
00112 //DoWrite(rTw,rLabel,pContext);
00113 void HioStateFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00114   (void) rLabel; (void) pContext;
00115   if(IsDefault()) return;
00116   FD_DC("HioStateFlags(" << this << ")::DoWrite(tr)");
00117     Token token;
00118     if( (mFlags & ~mAllHioStateFlags) == 0 ) {
00119       std::string option;
00120       if(IsErr()) option = "Err";
00121     switch (mFlags&0xFF) // AllHioStateFlags but not ErrFlag
00122     {
00123            case   1: option = option+"QY";     break; //0000 0001
00124            case   2: option = option+"QU";     break; //0000 0010
00125            case   4: option = option+"QC";     break; //0000 0100
00126            case   6: option = option+"QUc";     break; //0000 0110
00127            case   8: option = option+"QP";     break; //0000 1000
00128            case   9: option = option+"QYp";     break; //0000 1001
00129            case   10: option = option+"QUp";     break; //0000 1010
00130            case  16: option = option+"QE";     break; //0001 0000
00131            case  17: option = option+"QYe";     break; //0001 0001
00132            case  18: option = option+"QUe";     break; //0001 0010
00133            case  25: option = option+"QYpYe";     break; //0001 1001
00134            case  32: option = option+"QL";     break; //0010 0000
00135            case  34: option = option+"QUl";     break; //0010 0010
00136            case  64: option = option+"QYcUp"; break; //0100 0000
00137            case 128: option = option+"QYlUe"; break; //1000 0000
00138            
00139            default: if( !IsErr() ) option = option+"??";      break;
00140            }
00141       
00142       token.SetOption(option);
00143     } 
00144     // if other flags used, write hex
00145     else { 
00146       token.SetInteger16(mFlags);
00147     }
00148     rTw << token;
00149   }
00150 
00151 //ToString()
00152 std::string HioStateFlags::ToString(void) const {
00153   return ToStringInteger16(mFlags);
00154 }
00155 
00156 //DoRead(rTw,rLabel,pContext);
00157 void HioStateFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00158   (void) rLabel; (void) pContext;
00159   mFlags=mDefHioStateFlags;
00160   Token token;
00161   rTr.Peek(token);
00162   if(token.Type()==Token::Integer16) { 
00163     rTr.Get(token);
00164     mFlags=token.IntegerValue();
00165     return;
00166   } 
00167   if(token.Type()==Token::Option) { 
00168     rTr.Get(token);
00169     std::string option=token.StringValue();
00170 
00171     if(option.find( "QY", 0) != std::string::npos){ SetQY();}
00172     if(option.find( "QU", 0) != std::string::npos){ SetQU();}
00173     if(option.find( "QC", 0) != std::string::npos){ SetQC();}
00174     if(option.find( "QUc", 0) != std::string::npos){ SetQU(); SetQC();}
00175     if(option.find( "QP", 0) != std::string::npos){ SetQP();}
00176     if(option.find( "QYp", 0) != std::string::npos){ SetQY(); SetQP();}
00177     if(option.find( "QUp", 0) != std::string::npos){ SetQU(); SetQP();}
00178     if(option.find( "QE", 0) != std::string::npos){ SetQE();}
00179     if(option.find( "QYe", 0) != std::string::npos){ SetQY(); SetQE();}
00180     if(option.find( "QUe", 0) != std::string::npos){ SetQU(); SetQE();}
00181     if(option.find( "QYpYe", 0) != std::string::npos){ SetQY(); SetQP(); SetQE();}
00182     if(option.find( "QL", 0) != std::string::npos){ SetQL();}
00183     if(option.find( "QUl", 0) != std::string::npos){ SetQU(); SetQL();}
00184     if(option.find( "QYcUp", 0) != std::string::npos){ SetQYcUp();}
00185     if(option.find( "QYlUe", 0) != std::string::npos){ SetQYlUe();}
00186     if(option.find( "Err", 0) != std::string::npos){ SetErr();}
00187     return;
00188   } 
00189  }
00190 } //End namespace

libFAUDES 2.16b --- 2010-9-8 --- c++ source docu by doxygen 1.6.3