ATLAS Offline Software
BitOp.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 /*
3  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
4 */
5 #ifndef TRIGT1INTERFACES_BITOP_H
6 #define TRIGT1INTERFACES_BITOP_H
7 
8 // STL includes:
9 #include <string>
10 
24 class BitOp {
25 
26 public:
32  static void printBin( unsigned int uintValue ) { printBinN( uintValue, 31 ); }
33  static void printBin( int intValue ) { printBinN( intValue, 31 ); }
34  static void printBinN( unsigned int uintValue, int nbits );
35  static void printBinN( int intValue, int nbits );
36 
38  static const std::string printBits( const int value, const int startbit,
39  const int endbit );
40 
47  inline static bool isSet( const unsigned int *uintValue, int bit ) {
48  return ( *uintValue == ( *uintValue | ( 1 << bit ) ) );
49  }
50 
51  inline static bool isSet( const int *intValue, int bit ) {
52  return ( *intValue == ( *intValue | ( 1 << bit ) ) );
53  }
54 
59  inline static void setBit( unsigned int *uintValue, int bit ) {
60  *uintValue |= ( 1 << bit );
61  }
62  inline static void setBit( int *intValue, int bit ) {
63  *intValue |= ( 1 << bit );
64  }
65 
70  inline static void clearBit( unsigned int *uintValue, int bit ) {
71  *uintValue |= ( 1 << bit ); *uintValue ^= ( 1 << bit );
72  }
73  inline static void clearBit( int *intValue, int bit ) {
74  *intValue |= ( 1 << bit ); *intValue ^= ( 1 << bit );
75  }
76 
83  inline static void sImposeNBits( unsigned int *uintValue, int stbit, int wrd ) {
84  *uintValue |= ( wrd << stbit );
85  }
86  inline static void sImposeNBits( int *intValue, int stbit, int wrd ) {
87  *intValue |= ( wrd << stbit );
88  }
89  inline static void sImposeNBits( unsigned int *uintValue, int stbit,
90  unsigned int wrd ) {
91  *uintValue |= ( wrd << stbit );
92  }
93  inline static void sImposeNBits( int *intValue, int stbit, unsigned int wrd ) {
94  *intValue |= ( wrd << stbit );
95  }
96 
98  static unsigned int alignBits( int value, int startbit, int endbit );
100  static unsigned int createMask( int startbit, int endbit );
101 
106  static unsigned int getValue( const unsigned int * uintValue,
107  const unsigned int mask );
108 
109 }; // class BitOp
110 
111 #endif // TRIGT1INTERFACES_BITOP_H
BitOp::clearBit
static void clearBit(int *intValue, int bit)
Definition: BitOp.h:73
BitOp::isSet
static bool isSet(const int *intValue, int bit)
Definition: BitOp.h:51
BitOp::printBin
static void printBin(unsigned int uintValue)
Utitlity function to print out the binary representation of an input int or unsigned int value.
Definition: BitOp.h:32
BitOp::clearBit
static void clearBit(unsigned int *uintValue, int bit)
Clear the given bit in the given integer.
Definition: BitOp.h:70
athena.value
value
Definition: athena.py:122
BitOp
Utility class for integer bit operations.
Definition: BitOp.h:24
python.utils.AtlRunQueryLookup.mask
string mask
Definition: AtlRunQueryLookup.py:460
BitOp::printBinN
static void printBinN(unsigned int uintValue, int nbits)
Definition: BitOp.cxx:19
BitOp::printBin
static void printBin(int intValue)
Definition: BitOp.h:33
BitOp::sImposeNBits
static void sImposeNBits(int *intValue, int stbit, int wrd)
Definition: BitOp.h:86
BitOp::printBits
static const std::string printBits(const int value, const int startbit, const int endbit)
print selected bit range into string
Definition: BitOp.cxx:100
BitOp::setBit
static void setBit(int *intValue, int bit)
Definition: BitOp.h:62
BitOp::isSet
static bool isSet(const unsigned int *uintValue, int bit)
Check if a the given bit in the given unsigned int or int value is set.
Definition: BitOp.h:47
BitOp::sImposeNBits
static void sImposeNBits(int *intValue, int stbit, unsigned int wrd)
Definition: BitOp.h:93
BitOp::setBit
static void setBit(unsigned int *uintValue, int bit)
Set the given bit in the given unsigned int or int value.
Definition: BitOp.h:59
BitOp::createMask
static unsigned int createMask(int startbit, int endbit)
create a 32 bit long mask with 1s from given start to end position
Definition: BitOp.cxx:85
BitOp::sImposeNBits
static void sImposeNBits(unsigned int *uintValue, int stbit, int wrd)
Superimpose the given integer wrd starting at bit stbit onto integer or unsigned interger value.
Definition: BitOp.h:83
BitOp::alignBits
static unsigned int alignBits(int value, int startbit, int endbit)
align given bits using start and end position into 32 bits
Definition: BitOp.cxx:67
BitOp::sImposeNBits
static void sImposeNBits(unsigned int *uintValue, int stbit, unsigned int wrd)
Definition: BitOp.h:89
BitOp::getValue
static unsigned int getValue(const unsigned int *uintValue, const unsigned int mask)
get the value in the input word represented by a bit pattern given as a bitmask
Definition: BitOp.cxx:47