Add main page for Doxygen generated documentation.
[tairent.git] / src / core / bitfield.h
bloba2bca865480846553253eaad396e48a08cd8a598
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation and appearing *
8 * in the file LICENSE.GPL included in the packaging of this file. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * General Public License for more details. *
14 * *
15 ***************************************************************************/
17 #ifndef _core_bitfield_h
18 #define _core_bitfield_h
20 #include <cstddef>
22 #include <tairon/core/string.h>
24 namespace Tairent
27 namespace Core
30 /** \brief BitField is an array of bits.
32 class BitField
34 public:
35 /** Constructs an empty BitField object of specific length.
37 * \param len Length of the bitfield (i.e. number of bits).
39 BitField(size_t len);
41 /** Constructs a BitField object from a memory.
43 BitField(const char *mem, size_t len);
45 /** Destroys the object.
47 ~BitField();
49 /** Returns bit value at specific position.
51 * \param index Position of the bit.
53 bool getBit(size_t index);
55 /** Returns pointer to the internal data structure.
57 const char *getData() {
58 return data;
61 /** Returns length of this bitfield.
63 size_t getLength() {
64 return length;
67 /** Returns number of bits that are not set.
69 size_t getRemaining() {
70 return remaining;
73 /** Sets a bit at specific position.
75 * \param index Position of the bit.
76 * \param value Value of the new bit.
78 void setBit(size_t index, bool value = true);
80 private:
81 /** Bitfield.
83 char *data;
85 /** Length of the bitfield.
87 size_t length;
89 /** Number of bits that are still unset.
91 size_t remaining;
94 }; // namespace Core
96 }; // namespace Tairent
98 #endif
100 // vim: ai sw=4 ts=4 noet fdm=marker