UCommon
bitmap.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This file is part of GNU uCommon C++.
5 //
6 // GNU uCommon C++ is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // GNU uCommon C++ is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
18 
27 #ifndef _UCOMMON_BITMAP_H_
28 #define _UCOMMON_BITMAP_H_
29 
30 #ifndef _UCOMMON_CONFIG_H_
31 #include <ucommon/platform.h>
32 #endif
33 
34 namespace ucommon {
35 
52 class __EXPORT bitmap
53 {
54 protected:
55  size_t size;
56 
57  typedef union
58  {
59  void *a;
60  uint8_t *b;
61  uint16_t *w;
62  uint32_t *l;
63  uint64_t *d;
64  } addr_t;
65 
66  addr_t addr;
67 
68 public:
72  typedef enum {
74  B8,
75  B16,
76  B32,
77  B64,
78  BMIN = BMALLOC,
79  BMAX = B64
80  } bus_t;
81 
82 protected:
83  bus_t bus;
84 
85  unsigned memsize(void) const;
86 
87 public:
94  bitmap(void *addr, size_t length, bus_t size = B8);
95 
101  explicit bitmap(size_t length);
102 
108  ~bitmap();
109 
113  void clear(void);
114 
120  bool get(size_t offset) const;
121 
127  void set(size_t offset, bool value);
128 };
129 
130 } // namespace ucommon
131 
132 #endif
Accessing a bitmap on a 32 bit device.
Definition: bitmap.h:76
Accessing a bitmap on 8 bit bus device.
Definition: bitmap.h:74
Various miscellaneous platform specific headers and defines.
Accessing a bitmap on a 64 bit device.
Definition: bitmap.h:77
A class to access bit fields in external bitmaps.
Definition: bitmap.h:52
Accessing a bitmap on a 16 bit device.
Definition: bitmap.h:75
struct sockaddr * addr(Socket::address &address)
A convenience function to convert a socket address list into a socket address.
Definition: socket.h:2015
Use default cpu size.
Definition: bitmap.h:73
Common namespace for all ucommon objects.
Definition: access.h:47