CrystalSpace

Public API Reference

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

csutil/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 
00025 class csFlags
00026 {
00027 private:
00029   uint32 flags;
00030 
00031 public:
00033   csFlags (uint32 value = 0) : flags (value) { }
00034 
00041   void SetAll (uint32 value)
00042   { flags = value; }
00043 
00050   void Set (uint32 mask)
00051   { flags = (flags & ~mask) | mask; }
00052 
00059   void Reset (uint32 mask)
00060   { flags = (flags & ~mask); }
00061 
00067   void Set (uint32 mask, uint32 value)
00068   { flags = (flags & ~mask) | value; }
00069 
00075   void SetBool (uint32 mask, bool value)
00076   {
00077     if (value) flags = (flags & ~mask) | mask;
00078     else flags = (flags & ~mask);
00079   }
00080 
00082   uint32 Get () const
00083   { return flags; }
00084 
00086   bool Check (uint32 mask) const
00087   { return (flags & mask) != 0; }
00088 
00090   bool CheckAll (uint32 mask) const
00091   { return (flags & mask) == mask; }
00092 };
00093 
00094 #endif // __CS_FLAGS_H__
00095 

Generated for Crystal Space by doxygen 1.2.18