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 ATTRIBUTES_H 00025 00026 #include "tokenreader.h" 00027 #include "tokenwriter.h" 00028 00029 namespace faudes { 00030 00031 00041 class AttributeVoid { 00042 public: 00043 00045 AttributeVoid(void) {}; 00046 00048 virtual ~AttributeVoid(void) {}; 00049 00064 virtual void Read(TokenReader& rTr); 00065 00075 virtual void Write(TokenWriter& rTw) const; 00076 00081 virtual void Write(void) const {}; 00082 00092 virtual std::string ToString(void) const { return "";}; 00093 00097 bool IsDefault(void) const {return true;}; 00098 00099 00100 }; // class AttributeVoid 00101 00102 00104 typedef unsigned long int fType; 00105 00122 class AttributeFlags : public AttributeVoid { 00123 public: 00124 00126 AttributeFlags(void) : mFlags(mDefFlags) {}; 00127 00129 virtual ~AttributeFlags(void) {}; 00130 00134 bool Test(fType mask) const { return ( (mFlags & mask) != 0 ); }; 00135 00139 bool TestAll(fType mask) const { return ( (mFlags & mask) == mask ); }; 00140 00144 bool TestSome(fType mask) const { return ( (mFlags & mask) != 0 ); }; 00145 00149 bool TestNone(fType mask) const { return ( (mFlags & mask) == 0 ); }; 00150 00154 void Set(fType mask) {mFlags |= mask; }; 00155 00159 void Clr(fType mask) {mFlags &= ~mask; }; 00160 00161 00171 virtual void Write(TokenWriter& rTw) const; 00172 00173 00178 virtual void Write(void) const; 00179 00191 virtual void Read(TokenReader& rTr); 00192 00200 virtual std::string ToString(void) const { return ToStringInteger16(mFlags);}; 00201 00205 bool IsDefault(void) const {return mFlags==mDefFlags;}; 00206 00208 fType mFlags; 00209 00210 /* default flags */ 00211 const static fType mDefFlags=0x0; 00212 00213 00214 }; // class AttributeFlags 00215 00216 00217 } // namespace faudes 00218 00219 #define ATTRIBUTES_H 00220 #endif