This is Unofficial EPICS BASE Doxygen Site
bitSet.h
Go to the documentation of this file.
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 
24 namespace epics { namespace pvData {
25 
26  class BitSet;
27  typedef std::tr1::shared_ptr<BitSet> BitSetPtr;
28 
57  public:
59  static BitSetPtr create(uint32 nbits);
63  BitSet();
64 
72  BitSet(uint32 nbits);
73 
74 #if __cplusplus>=201103L
75 
81  BitSet(std::initializer_list<uint32> I);
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 
175  uint32 cardinality() const;
176 
184  uint32 size() const;
185 
187  bool logical_and(const BitSet& other) const;
189  bool logical_or(const BitSet& other) const;
190 
200  BitSet& operator&=(const BitSet& set);
201 
211  BitSet& operator|=(const BitSet& set);
212 
227  BitSet& operator^=(const BitSet& set);
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 
259  typedef std::vector<uint64> words_t;
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 
Definition: link.h:174
EPICS_ALWAYS_INLINE T swap(T val)
Definition: byteBuffer.h:209
int i
Definition: scan.c:967
Base class for serialization.
Definition: serialize.h:140
TODO only here because of the Lockable.
Definition: ntaggregate.cpp:16
A vector of bits.
Definition: bitSet.h:56
Mark external symbols and entry points for shared libraries.
Callback class for deserialization.
Definition: serialize.h:89
std::ostream & operator<<(std::ostream &o, const Field &f)
#define epicsShareExtern
Definition: shareLib.h:204
uint64_t uint64
Definition: pvType.h:103
#define POINTER_DEFINITIONS(clazz)
Definition: sharedPtr.h:198
#define epicsShareClass
Definition: shareLib.h:206
This class implements a Bytebuffer that is like the java.nio.ByteBuffer.
Definition: byteBuffer.h:233
bool operator==(const PVField &left, const PVField &right)
Definition: Compare.cpp:328
std::tr1::shared_ptr< BitSet > BitSetPtr
Definition: bitSet.h:26
Callback class for serialization.
Definition: serialize.h:34
int32_t int32
Definition: pvType.h:83
uint32_t uint32
Definition: pvType.h:99