Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
KM3NETDAQ::JBits Struct Reference

Auxiliary data structure for range of bits. More...

#include <JDAQ.hh>

Public Member Functions

 JBits ()
 Default constructor.
 
 JBits (int __lsb, int __msb)
 Constructor.
 
int get () const
 Get bit mask.
 
int write (const int value) const
 Write given value as bit mask.
 
int read (const int mask) const
 Read given bit mask as value.
 
bool has (const int mask) const
 Test bit mask.
 

Public Attributes

int lsb
 least significant bit
 
int msb
 most significant bit
 

Detailed Description

Auxiliary data structure for range of bits.

Definition at line 152 of file JDAQ.hh.

Constructor & Destructor Documentation

◆ JBits() [1/2]

KM3NETDAQ::JBits::JBits ( )
inline

Default constructor.

Definition at line 156 of file JDAQ.hh.

156 :
157 lsb(0),
158 msb(0)
159 {}
int lsb
least significant bit
Definition JDAQ.hh:268
int msb
most significant bit
Definition JDAQ.hh:269

◆ JBits() [2/2]

KM3NETDAQ::JBits::JBits ( int __lsb,
int __msb )
inline

Constructor.

Parameters
__lsbleast significant bit [0, 31]
__msbmost significant bit [lsb, 31]

Definition at line 168 of file JDAQ.hh.

168 :
169 lsb(__lsb),
170 msb(__msb)
171 {
172 if (lsb < 0 || lsb > 31 ||
174 throw JDAQException("JBits: illegal bit range.");
175 }
176 }

Member Function Documentation

◆ get()

int KM3NETDAQ::JBits::get ( ) const
inline

Get bit mask.

In the returned mask, the bits from lsb (included) to msb (included) are set to 1.

Returns
bit mask

Definition at line 186 of file JDAQ.hh.

187 {
188 static const unsigned int mask[] = { 0x00000001,
189 0x00000003,
190 0x00000007,
191 0x0000000F,
192
193 0x0000001F,
194 0x0000003F,
195 0x0000007F,
196 0x000000FF,
197
198 0x000001FF,
199 0x000003FF,
200 0x000007FF,
201 0x00000FFF,
202
203 0x00001FFF,
204 0x00003FFF,
205 0x00007FFF,
206 0x0000FFFF,
207
208 0x0001FFFF,
209 0x0003FFFF,
210 0x0007FFFF,
211 0x000FFFFF,
212
213 0x001FFFFF,
214 0x003FFFFF,
215 0x007FFFFF,
216 0x00FFFFFF,
217
218 0x01FFFFFF,
219 0x03FFFFFF,
220 0x07FFFFFF,
221 0x0FFFFFFF,
222
223 0x1FFFFFFF,
224 0x3FFFFFFF,
225 0x7FFFFFFF,
226 0xFFFFFFFF };
227
228 return (int) (mask[msb-lsb] << lsb);
229 }

◆ write()

int KM3NETDAQ::JBits::write ( const int value) const
inline

Write given value as bit mask.

Parameters
valuevalue
Returns
bit mask

Definition at line 238 of file JDAQ.hh.

239 {
240 return (value << lsb) & get();
241 }
int get() const
Get bit mask.
Definition JDAQ.hh:186

◆ read()

int KM3NETDAQ::JBits::read ( const int mask) const
inline

Read given bit mask as value.

Parameters
maskbit mask
Returns
value

Definition at line 250 of file JDAQ.hh.

251 {
252 return (mask & get()) >> lsb;
253 }

◆ has()

bool KM3NETDAQ::JBits::has ( const int mask) const
inline

Test bit mask.

Parameters
maskbit mask
Returns
true if at least one of the bits is set; else false

Definition at line 262 of file JDAQ.hh.

263 {
264 return (get() & mask) != 0;
265 }

Member Data Documentation

◆ lsb

int KM3NETDAQ::JBits::lsb

least significant bit

Definition at line 268 of file JDAQ.hh.

◆ msb

int KM3NETDAQ::JBits::msb

most significant bit

Definition at line 269 of file JDAQ.hh.


The documentation for this struct was generated from the following file: