PVData C++ 8.0.7
Loading...
Searching...
No Matches
bitSet.h
1/* bitSet.h */
2/*
3 * Copyright information and license terms for this software can be
4 * found in the file LICENSE that is included with the distribution
5 */
9#ifndef BITSET_H
10#define BITSET_H
11
12#if __cplusplus>=201103L
13# include <initializer_list>
14#endif
15
16#include <vector>
17
18#include <pv/pvType.h>
19#include <pv/serialize.h>
20#include <pv/sharedPtr.h>
21
22#include <shareLib.h>
23
24namespace epics { namespace pvData {
25
26 class BitSet;
27 typedef std::tr1::shared_ptr<BitSet> BitSetPtr;
28
56 class epicsShareClass BitSet : public Serializable {
57 public:
58 POINTER_DEFINITIONS(BitSet);
59 static BitSetPtr create(uint32 nbits);
64
72 BitSet(uint32 nbits);
73
74#if __cplusplus>=201103L
82#endif
83
87 virtual ~BitSet();
88
95 BitSet& flip(uint32 bitIndex);
96
102 BitSet& set(uint32 bitIndex);
103
109 BitSet& clear(uint32 bitIndex);
110
117 void set(uint32 bitIndex, bool value);
118
127 bool get(uint32 bitIndex) const;
128
132 void clear();
133
151 int32 nextSetBit(uint32 fromIndex) const;
152
160 int32 nextClearBit(uint32 fromIndex) const;
161
168 bool isEmpty() const;
169
176
184 uint32 size() const;
185
187 bool logical_and(const BitSet& other) const;
189 bool logical_or(const BitSet& other) const;
190
201
212
228
232 BitSet& operator=(const BitSet &set);
233
235 void swap(BitSet& set);
236
243 void or_and(const BitSet& set1, const BitSet& set2);
244
248 bool operator==(const BitSet &set) const;
249
250 bool operator!=(const BitSet &set) const;
251
252 virtual void serialize(ByteBuffer *buffer,
253 SerializableControl *flusher) const;
254 virtual void deserialize(ByteBuffer *buffer,
255 DeserializableControl *flusher);
256
257 private:
258
261 words_t words;
262
263 private:
269 void recalculateWordsInUse();
270
275 void ensureCapacity(uint32 wordsRequired);
276
284 void expandTo(uint32 wordIndex);
285
298 static uint32 numberOfTrailingZeros(uint64 i);
299
308 static uint32 bitCount(uint64 i);
309
310 };
311
312 epicsShareExtern std::ostream& operator<<(std::ostream& o, const BitSet& b);
313
314}}
315#endif /* BITSET_H */
316
317
318
bool operator!=(const multimap< _Key, _Tp, _Compare, _Alloc > &__x, const multimap< _Key, _Tp, _Compare, _Alloc > &__y)
basic_ostream< _CharT, _Traits > & operator<<(basic_ostream< _CharT, _Traits > &__os, const basic_string< _CharT, _Traits, _Alloc > &__str)
A vector of bits.
Definition bitSet.h:56
BitSet & operator=(const BitSet &set)
virtual void serialize(ByteBuffer *buffer, SerializableControl *flusher) const
BitSet & set(uint32 bitIndex)
uint32 size() const
int32 nextSetBit(uint32 fromIndex) const
bool isEmpty() const
BitSet & operator|=(const BitSet &set)
bool get(uint32 bitIndex) const
void set(uint32 bitIndex, bool value)
bool logical_and(const BitSet &other) const
Returns true if any bit is set in both *this and other.
BitSet & operator&=(const BitSet &set)
void or_and(const BitSet &set1, const BitSet &set2)
uint32 cardinality() const
BitSet & operator^=(const BitSet &set)
void swap(BitSet &set)
Swap contents.
BitSet & flip(uint32 bitIndex)
virtual void deserialize(ByteBuffer *buffer, DeserializableControl *flusher)
int32 nextClearBit(uint32 fromIndex) const
BitSet(uint32 nbits)
bool operator==(const BitSet &set) const
bool logical_or(const BitSet &other) const
Returns true if any bit is set in both *this or other.
BitSet & clear(uint32 bitIndex)
This class implements a Bytebuffer that is like the java.nio.ByteBuffer.
Definition byteBuffer.h:237
Callback class for deserialization.
Definition serialize.h:93
Callback class for serialization.
Definition serialize.h:42
Base class for serialization.
Definition serialize.h:138
uint32_t uint32
Definition pvType.h:99
int32_t int32
Definition pvType.h:83
uint64_t uint64
Definition pvType.h:103
epics
Definition convert.h:21