CrystalSpace

Public API Reference

Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

flags.h

00001 /*
00002     Copyright (C) 2000 by Jorrit Tyberghein
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public
00015     License along with this library; if not, write to the Free
00016     Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_FLAGS_H__
00020 #define __CS_FLAGS_H__
00021 
00022 #include "csextern.h"
00023 
00027 class csFlags
00028 {
00029 private:
00031   uint32 flags;
00032 
00033 public:
00035   csFlags (uint32 value = 0) : flags (value) { }
00036 
00043   void SetAll (uint32 value)
00044   { flags = value; }
00045 
00052   void Set (uint32 mask)
00053   { flags = (flags & ~mask) | mask; }
00054 
00061   void Reset (uint32 mask)
00062   { flags = (flags & ~mask); }
00063 
00069   void Set (uint32 mask, uint32 value)
00070   { flags = (flags & ~mask) | value; }
00071 
00077   void SetBool (uint32 mask, bool value)
00078   {
00079     if (value) flags = (flags & ~mask) | mask;
00080     else flags = (flags & ~mask);
00081   }
00082 
00084   uint32 Get () const
00085   { return flags; }
00086 
00088   bool Check (uint32 mask) const
00089   { return (flags & mask) != 0; }
00090 
00092   bool CheckAll (uint32 mask) const
00093   { return (flags & mask) == mask; }
00094 };
00095 
00096 #endif // __CS_FLAGS_H__
00097 

Generated for Crystal Space by doxygen 1.3.9.1