OpenZWave Library
1.6.0
cpp
src
Bitfield.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
//
3
// Bitfield.h
4
//
5
// Variable length bitfield implementation
6
//
7
// Copyright (c) 2011 Mal Lansell <openzwave@lansell.org>
8
//
9
// SOFTWARE NOTICE AND LICENSE
10
//
11
// This file is part of OpenZWave.
12
//
13
// OpenZWave is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU Lesser General Public License as published
15
// by the Free Software Foundation, either version 3 of the License,
16
// or (at your option) any later version.
17
//
18
// OpenZWave is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
// GNU Lesser General Public License for more details.
22
//
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25
//
26
//-----------------------------------------------------------------------------
27
28
#ifndef _Bitfield_H
29
#define _Bitfield_H
30
31
#include <vector>
32
#include "
Defs.h
"
33
34
namespace
OpenZWave
35
{
36
class
OPENZWAVE_EXPORT
Bitfield
37
{
38
friend
class
Iterator
;
39
40
public
:
41
Bitfield
();
42
Bitfield
(
uint32
value);
43
~
Bitfield
();
44
bool
Set(
uint8
_idx );
45
bool
Clear(
uint8
_idx );
46
bool
IsSet(
uint8
_idx )
const
;
47
uint32
GetNumSetBits()
const
;
48
uint32
GetValue()
const
;
49
bool
SetValue(
uint32
val);
50
uint32
GetSize()
const
;
51
class
Iterator
52
{
53
friend
class
Bitfield
;
54
55
public
:
56
uint32
operator *()
const
;
57
Iterator
& operator++();
58
Iterator
operator++(
int
);
59
60
bool
operator ==(
const
Iterator
&rhs);
61
bool
operator !=(
const
Iterator
&rhs);
62
private
:
63
Iterator
(
Bitfield
const
* _bitfield,
uint32
_idx );
64
65
void
NextSetBit();
66
67
uint32
m_idx;
68
Bitfield
const
* m_bitfield;
69
};
70
71
Iterator
Begin()
const
;
72
Iterator
End()
const
;
73
74
private
:
75
OPENZWAVE_EXPORT_WARNINGS_OFF
76
vector<uint32> m_bits;
77
OPENZWAVE_EXPORT_WARNINGS_ON
78
uint32
m_numSetBits;
79
uint32
m_value;
80
};
81
}
// namespace OpenZWave
82
83
#endif
84
85
86
uint32
unsigned int uint32
Definition:
Defs.h:95
uint8
unsigned char uint8
Definition:
Defs.h:89
OPENZWAVE_EXPORT_WARNINGS_OFF
#define OPENZWAVE_EXPORT_WARNINGS_OFF
Definition:
Defs.h:52
OPENZWAVE_EXPORT_WARNINGS_ON
#define OPENZWAVE_EXPORT_WARNINGS_ON
Definition:
Defs.h:53
OpenZWave::Bitfield
Definition:
Bitfield.h:37
OpenZWave::Bitfield::Iterator
Definition:
Bitfield.h:52
OPENZWAVE_EXPORT
#define OPENZWAVE_EXPORT
Definition:
Defs.h:51
Defs.h
OpenZWave
Definition:
Bitfield.h:35
Generated on Wed Nov 11 2020 16:02:47 for OpenZWave Library by
1.8.20