attributes.h

Go to the documentation of this file.
00001 
00004 /* FAU Discrete Event Systems Library (libfaudes)
00005 
00006 Copyright (C) 2007  Thomas Moor
00007 Exclusive copyright is granted to Klaus Schmidt
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU Lesser General Public
00011 License as published by the Free Software Foundation; either
00012 version 2.1 of the License, or (at your option) any later version.
00013 
00014 This library is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public
00020 License along with this library; if not, write to the Free Software
00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00022 
00023 
00024 #ifndef FAUDES_ATTRIBUTES_H
00025 #define FAUDES_ATTRIBUTES_H
00026 
00027 #include "interface.h"
00028 #include "tokenreader.h"
00029 #include "tokenwriter.h"
00030 
00031 namespace faudes {
00032 
00033 
00043 class AttributeVoid {
00044  public:
00045 
00047   AttributeVoid(void) {};
00048 
00050   virtual ~AttributeVoid(void) {};
00051 
00063   void Write(const std::string& rLabel="", const Type* pContext=0) const;
00064 
00082   void Write(const std::string& pFileName, const std::string& rLabel="",
00083        const Type* pContext=0, std::ios::openmode openmode = std::ios::out|std::ios::trunc) const;
00084 
00100   void Write(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00101 
00116   std::string ToString(const std::string& rLabel="", const Type* pContext=0) const;
00117 
00134   void Read(const std::string& rFileName, const std::string& rLabel = "", const Type* pContext=0);
00135 
00152   void Read(TokenReader& rTr, const std::string& rLabel = "", const Type* pContext=0);
00153 
00154 
00158   bool IsDefault(void) const {return true;};
00159 
00163   void SetDefault(void) {};
00164 
00168   void Clear(void) { SetDefault(); };
00169 
00170  protected:
00171 
00193   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
00194  
00211   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00212 
00225   void Skip(TokenReader& rTr);
00226 
00227  
00228 
00229 }; // class AttributeVoid
00230 
00231 
00233 typedef unsigned long int fType;
00234 
00251 class AttributeFlags : public AttributeVoid {
00252  public:
00253 
00255   AttributeFlags(void) : mFlags(mDefFlags) {};
00256 
00258   virtual ~AttributeFlags(void) {};
00259 
00263   bool Test(fType mask) const { return ( (mFlags & mask) != 0 ); };
00264 
00268   bool TestAll(fType mask) const { return ( (mFlags & mask) == mask ); };
00269 
00273   bool TestSome(fType mask) const { return ( (mFlags & mask) != 0 ); };
00274 
00278   bool TestNone(fType mask) const { return ( (mFlags & mask) == 0 ); };
00279 
00283   void Set(fType mask) {mFlags |= mask; };
00284 
00288   void Clr(fType mask) {mFlags &= ~mask; };
00289 
00293   bool IsDefault(void) const {return mFlags==mDefFlags;};
00294 
00296   fType mFlags;
00297 
00298   /* default flags */
00299   const static fType mDefFlags=0x0;
00300 
00301 
00302 protected:
00303 
00320   virtual void DoRead(TokenReader& rTr,  const std::string& rLabel = "", const Type* pContext=0);
00321  
00338   virtual void DoWrite(TokenWriter& rTw, const std::string& rLabel="",const Type* pContext=0) const;
00339 
00340 
00341 
00342 }; // class AttributeFlags
00343 
00344 
00345 } // namespace faudes
00346 
00347 #endif

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