cgenerator.cpp

Go to the documentation of this file.
00001 
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 "cgenerator.h" 
00027 
00028 
00029 namespace faudes {
00030 
00031 
00032 /***********************************************************************************
00033  *
00034  * implementation of AttributeCFlags 
00035  *
00036  */
00037 
00038 //Write(rTw)
00039 // Note: you should write attributes in a section, so that
00040 // the AttributeVoid read method can detect and skip them.
00041 // Here, we make an execption of the rule ...
00042 void AttributeCFlags::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00043   (void) rLabel; (void) pContext;
00044   if(IsDefault()) return;
00045   FD_DC("AttributeCFlags(" << this << ")::DoWrite(tr)");
00046   Token token;
00047   // if no other flags used, write option string
00048   if( (mFlags & ~mAllCFlags) == 0 ) {
00049     std::string option;
00050     if((mDefCFlags & mControllableFlag) != (mFlags & mControllableFlag)) {
00051       if(Controllable()) option = option+"C";
00052       else option = option+"c";
00053     }
00054     if((mDefCFlags & mObservableFlag) != (mFlags & mObservableFlag)) {
00055       if(Observable()) option = option+"O";
00056       else option = option+"o";
00057     }
00058     if((mDefCFlags & mForcibleFlag) != (mFlags & mForcibleFlag)) {
00059       if(Forcible()) option = option+"F";
00060       else option = option+"f";
00061     }
00062     token.SetOption(option);
00063   } 
00064   // if other flags used, write hex
00065   else { 
00066     token.SetInteger16(mFlags);
00067   }
00068   rTw << token;
00069 }
00070 
00071 //DoRead(rTr)
00072 void AttributeCFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00073   (void) rLabel; (void) pContext;
00074   mFlags=mDefCFlags;
00075   Token token;
00076   rTr.Peek(token);
00077   if(token.Type()==Token::Integer16) { 
00078     rTr.Get(token);
00079     mFlags=token.IntegerValue();
00080     return;
00081   } 
00082   if(token.Type()==Token::Option) { 
00083     rTr.Get(token);
00084     std::string option=token.StringValue();
00085     if(option.find( 'C', 0) != std::string::npos) SetControllable();
00086     if(option.find( 'c', 0) != std::string::npos) ClrControllable();
00087     if(option.find( 'O', 0) != std::string::npos) SetObservable();
00088     if(option.find( 'o', 0) != std::string::npos) ClrObservable();
00089     if(option.find( 'F', 0) != std::string::npos) SetForcible();
00090     if(option.find( 'f', 0) != std::string::npos) ClrForcible();
00091     return;
00092   }
00093 }
00094 
00095 
00096 
00097 
00098 } // end namespace

Generated on Mon Nov 10 08:13:14 2008 for libFAUDES 2.11v by  doxygen 1.4.4