UCommon
|
00001 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks. 00002 // Copyright (C) 2015 Cherokees of Idaho. 00003 // 00004 // This file is part of GNU uCommon C++. 00005 // 00006 // GNU uCommon C++ is free software: you can redistribute it and/or modify 00007 // it under the terms of the GNU Lesser General Public License as published 00008 // by the Free Software Foundation, either version 3 of the License, or 00009 // (at your option) any later version. 00010 // 00011 // GNU uCommon C++ is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public License 00017 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>. 00018 00027 #ifndef _UCOMMON_BITMAP_H_ 00028 #define _UCOMMON_BITMAP_H_ 00029 00030 #ifndef _UCOMMON_CONFIG_H_ 00031 #include <ucommon/platform.h> 00032 #endif 00033 00034 namespace ucommon { 00035 00052 class __EXPORT bitmap 00053 { 00054 protected: 00055 size_t size; 00056 00057 typedef union 00058 { 00059 void *a; 00060 uint8_t *b; 00061 uint16_t *w; 00062 uint32_t *l; 00063 uint64_t *d; 00064 } addr_t; 00065 00066 addr_t addr; 00067 00068 public: 00072 typedef enum { 00073 BMALLOC, 00074 B8, 00075 B16, 00076 B32, 00077 B64, 00078 BMIN = BMALLOC, 00079 BMAX = B64 00080 } bus_t; 00081 00082 protected: 00083 bus_t bus; 00084 00085 unsigned memsize(void) const; 00086 00087 public: 00094 bitmap(void *addr, size_t length, bus_t size = B8); 00095 00101 bitmap(size_t length); 00102 00108 ~bitmap(); 00109 00113 void clear(void); 00114 00120 bool get(size_t offset) const; 00121 00127 void set(size_t offset, bool value); 00128 }; 00129 00130 } // namespace ucommon 00131 00132 #endif