• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/math/BitMask.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL 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
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _bitmask_h
00018 #define _bitmask_h
00019 
00020 #include <spl/Debug.h>
00021 #include <spl/types.h>
00022 #include <spl/Memory.h>
00023 
00029 class BitMask : public IMemoryValidate
00030 {
00031 protected:
00032         int m_rows, m_cols;
00033         int m_size;
00034         byte *m_bits;
00035 
00036         void GetByteBit(int row, int col, int *bytenum, int *bytebit);
00037 
00038 public:
00039         BitMask(int rows, int cols);
00040         BitMask(const BitMask& bits);
00041         virtual ~BitMask();
00042 
00043         BitMask& operator =(const BitMask& bits);
00044 
00045         void Set(int row, int col);
00046         bool IsSet(int row, int col);
00047         void Clear(int row, int col);
00048         void Clear();
00049 
00050 #ifdef DEBUG
00051         virtual void ValidateMem() const;
00052         virtual void CheckMem() const;
00053 #endif
00054 };
00055 
00058 #endif