libFAUDES

Sections

Index

cfl_cgenerator.cpp

Go to the documentation of this file.
00001 /** @file cfl_cgenerator.cpp Classes TcGenerator, cGenerator and AttributeCFlags */
00002 
00003 
00004 /* FAU Discrete Event Systems Library (libfaudes)
00005 
00006    Copyright (C) 2006  Bernd Opitz
00007    Copyright (C) 2007  Thomas Moor
00008    Exclusive copyright is granted to Klaus Schmidt
00009 
00010    This library is free software; you can redistribute it and/or
00011    modify it under the terms of the GNU Lesser General Public
00012    License as published by the Free Software Foundation; either
00013    version 2.1 of the License, or (at your option) any later version.
00014 
00015    This library is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018    Lesser General Public License for more details.
00019 
00020    You should have received a copy of the GNU Lesser General Public
00021    License along with this library; if not, write to the Free Software
00022    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00023 
00024 
00025       
00026 #include "cfl_cgenerator.h" 
00027 
00028 
00029 namespace faudes {
00030 
00031 
00032 /***********************************************************************************
00033  *
00034  * implementation of AttributeCFlags 
00035  *
00036  */
00037 
00038 
00039 // faudes type std
00040 FAUDES_TYPE_IMPLEMENTATION(AttributeCFlags,AttributeFlags)
00041 
00042 // Assign my members
00043 AttributeCFlags& AttributeCFlags::DoAssign(const AttributeCFlags& rSrcAttr) { 
00044   // call base
00045   AttributeFlags::DoAssign(rSrcAttr);
00046   // no additional members
00047   return *this;
00048 }
00049 
00050 // Test my members
00051 bool AttributeCFlags::DoEqual(const AttributeCFlags& rOther) const { 
00052   // call base
00053   if(!AttributeFlags::DoEqual(rOther)) return false;
00054   // no additional members
00055   return true;
00056 }
00057 
00058 //Write(rTw)
00059 // Note: you should write attributes in a section, so that
00060 // the AttributeVoid read method can detect and skip them.
00061 // Here, we make an execption of the rule ...
00062 void AttributeCFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00063   (void) rLabel; (void) pContext;
00064   if(AttributeCFlags::IsDefault()) return;
00065   FD_DC("AttributeCFlags(" << this << ")::DoWrite(tr)");
00066   Token token;
00067   // if no other flags used, write option string
00068   if( (mFlags & ~mAllCFlags) == 0 ) {
00069     std::string option;
00070     if((mDefCFlags & mControllableFlag) != (mFlags & mControllableFlag)) {
00071       if(Controllable()) option = option+"C";
00072       else option = option+"c";
00073     }
00074     if((mDefCFlags & mObservableFlag) != (mFlags & mObservableFlag)) {
00075       if(Observable()) option = option+"O";
00076       else option = option+"o";
00077     }
00078     if((mDefCFlags & mForcibleFlag) != (mFlags & mForcibleFlag)) {
00079       if(Forcible()) option = option+"F";
00080       else option = option+"f";
00081     }
00082     if((mDefCFlags & mAbstractionFlag) != (mFlags & mAbstractionFlag)) {
00083       if(Highlevel()) option = option+"A";
00084       else option = option+"a";
00085     }
00086     token.SetOption(option);
00087   } 
00088   // if other flags used, write hex
00089   else { 
00090     token.SetInteger16(mFlags);
00091   }
00092   rTw << token;
00093 }
00094 
00095 //DoRead(rTr)
00096 void AttributeCFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00097   (void) rLabel; (void) pContext;
00098   mFlags=mDefCFlags;
00099   Token token;
00100   rTr.Peek(token);
00101   if(token.Type()==Token::Integer16) { 
00102     rTr.Get(token);
00103     mFlags=token.IntegerValue();
00104     return;
00105   } 
00106   if(token.Type()==Token::Option) { 
00107     rTr.Get(token);
00108     std::string option=token.StringValue();
00109     if(option.find( 'C', 0) != std::string::npos) SetControllable();
00110     if(option.find( 'c', 0) != std::string::npos) ClrControllable();
00111     if(option.find( 'O', 0) != std::string::npos) SetObservable();
00112     if(option.find( 'o', 0) != std::string::npos) ClrObservable();
00113     if(option.find( 'F', 0) != std::string::npos) SetForcible();
00114     if(option.find( 'f', 0) != std::string::npos) ClrForcible();
00115     if(option.find( 'A', 0) != std::string::npos) SetHighlevel();
00116     if(option.find( 'a', 0) != std::string::npos) SetLowlevel();
00117     return;
00118   }
00119 }
00120 
00121 
00122 } // end namespace

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