libFAUDES

Sections

Index

cfl_attributes.cpp

Go to the documentation of this file.
00001 /** @file cfl_attributes.cpp Classes AttributeVoid and AttributeFlags  */
00002 
00003 /* FAU Discrete Event Systems Library (libfaudes)
00004 
00005    Copyright (C) 2006  Bernd Opitz
00006    Exclusive copyright is granted to Klaus Schmidt
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Lesser General Public
00010    License as published by the Free Software Foundation; either
00011    version 2.1 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Lesser General Public License for more details.
00017 
00018    You should have received a copy of the GNU Lesser General Public
00019    License along with this library; if not, write to the Free Software
00020    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00021 
00022 
00023 #include "cfl_attributes.h"
00024 
00025 
00026 namespace faudes {
00027 
00028 /***********************************************************************************
00029  *
00030  * implementation of AttributeVoid 
00031  *
00032  */
00033 
00034 // faudes type
00035 FAUDES_TYPE_IMPLEMENTATION(AttributeVoid,Type)
00036 
00037 // constructor
00038 AttributeVoid::AttributeVoid(void) {
00039   FAUDES_OBJCOUNT_INC("Attribute");
00040 }
00041 
00042 // destructor
00043 AttributeVoid::~AttributeVoid(void) {
00044   FAUDES_OBJCOUNT_DEC("Attribute");
00045 }
00046 
00047 //DoWrite(rTr,rLabel,pContext)
00048 void AttributeVoid::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00049   (void) rTw; (void) rLabel; (void) pContext;
00050   FD_DC("AttributeVoid::DoWrite()");
00051 }
00052 
00053 //DoRead(rTr,rLabel,pContext)
00054 void AttributeVoid::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00055   (void) rLabel; (void) pContext; (void) rTr;
00056   FD_DC("AttributeVoid::DoRead()");
00057 }
00058 
00059 //Skip(rTr)
00060 void AttributeVoid::Skip(TokenReader& rTr) {
00061   FD_DC("AttributeVoid::Skip()");
00062   Token token;
00063   while(rTr.Peek(token)) {
00064     // break on index or name, since this is the next element
00065     if((token.Type()==Token::String) || (token.Type()==Token::Integer)) {
00066       break;
00067     }
00068     // break on end, since this is the end of the set
00069     if(token.Type()==Token::End) {
00070       break;
00071     }
00072     // break on Consecutive section, since this belongs to the set
00073     if((token.Type()==Token::Begin) && (token.StringValue() == "Consecutive")) {
00074       break;
00075     }
00076     // skip any attribute section from other file format
00077     if(token.Type()==Token::Begin){
00078       rTr.ReadBegin(token.StringValue());
00079       rTr.ReadEnd(token.StringValue());
00080       continue;
00081     }  
00082     // skip any other token from other file format
00083     rTr.Get(token);
00084   }
00085 }
00086 
00087 
00088 
00089 /***********************************************************************************
00090  *
00091  * implementation of AttributeFlags 
00092  *
00093  */
00094 
00095 // faudes type
00096 FAUDES_TYPE_IMPLEMENTATION(AttributeFlags,AttributeVoid)
00097 
00098 // Assign my members
00099 AttributeFlags& AttributeFlags::DoAssign(const AttributeFlags& rSrcAttr) { 
00100   // call virtual clear: TODO: dont clear in virtual function
00101   Clear();
00102   // assign my members
00103   mFlags=rSrcAttr.mFlags; 
00104   return *this;
00105 }
00106 
00107 // Test my members for equality
00108 bool AttributeFlags::DoEqual(const AttributeFlags& rOther) const { 
00109   return ( mFlags==rOther.mFlags ); 
00110 }
00111 
00112 //DoWrite(rTw)
00113 // Note: you should write attributes in a section, so that
00114 // the AttributeVoid read method can detect and skip them.
00115 // Here, we make an execption of the rule ...
00116 void AttributeFlags::DoWrite(TokenWriter& rTw,const std::string& rLabel, const Type* pContext) const {
00117   (void) rLabel; (void) pContext;
00118   if(!AttributeFlags::IsDefault()) {
00119     FD_DC("AttributeFlags(" << this << ")::DoWrite(tr)");
00120     Token token;
00121     token.SetInteger16(mFlags);
00122     rTw << token;
00123   }
00124 }
00125 
00126 
00127 //DoRead(rTr)
00128 void AttributeFlags::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00129   (void) rLabel; (void) pContext;
00130   FD_DC("AttributeFlag(" << this << ")::DoRead(tr)");
00131   Token token;
00132   rTr.Peek(token);
00133   if(token.Type()==Token::Integer16) { 
00134     rTr.Get(token);
00135     mFlags=token.IntegerValue();
00136   } else {
00137     mFlags=mDefFlags;
00138   }
00139 }
00140 
00141 
00142 } // namespace

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