ATLAS Offline Software
TrigPassFlags.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <iostream>
7 
9  : m_container_ptr(0) {}
10 
11 TrigPassFlags::TrigPassFlags(const unsigned int size,const unsigned int flagSize, const void* cont)
12  : m_container_ptr(cont) {
13  std::vector<bool> temp(flagSize,false);
14  m_flagsPerObject.resize(size,temp);
15 }
16 
17 
18 void TrigPassFlags::setFlagBit(const unsigned int position,const unsigned int bitPosition,const bool bitValue, const void *cont) {
19  if (m_container_ptr && cont != m_container_ptr)
20  throw std::runtime_error("Passed container does not match the container that created this TrigPassFlags. No flag bit set.");
21 
22  if ( position >= size() )
23  throw std::runtime_error("Specified flag position is larger than the size of the TrigPassFlags object. No flag bit set.");
24 
25  if ( bitPosition >= flagSize() )
26  throw std::runtime_error("Specified bitPosition is larger than the flag size. No flag bit set.");
27 
28  m_flagsPerObject[position][bitPosition] = bitValue;
29 }
30 
31 void TrigPassFlags::setFlag(const unsigned int position, const std::vector<bool>& flag, const void *cont) {
32  if (m_container_ptr && cont != m_container_ptr)
33  throw std::runtime_error("Passed container does not match the container that created this TrigPassFlags. No flag set.");
34 
35  if ( position >= size() )
36  throw std::runtime_error("Specified flag position is larger than the size of the TrigPassFlags object. No flag set.");
37 
38  if ( flag.size() != flagSize() )
39  throw std::runtime_error("Size of specified flag is different from the flag size of the TrigPassFlags object. No flag set.");
40 
41  m_flagsPerObject[position] = flag;
42 }
43 
44 bool TrigPassFlags::getFlagBit(const unsigned int position, const unsigned int bitPosition) const {
45  if ( position >= size() )
46  throw std::runtime_error("Specified object position is larger than the size of the TrigPassFlags objects.");
47 
48  if ( bitPosition >= flagSize() )
49  throw std::runtime_error("Specified bitPosition is larger than the flag size.");
50 
51  return m_flagsPerObject[position][bitPosition];
52 }
53 
54 const std::vector<bool>& TrigPassFlags::getFlag(const unsigned int position) const {
55  if ( position >= size() )
56  throw std::runtime_error("Specified object position is larger than the size of the TrigPassFlags objects.");
57 
58  return m_flagsPerObject[position];
59 }
60 
61 
TrigPassFlags::setFlagBit
void setFlagBit(const unsigned int position, const unsigned int bitPosition, const bool bitValue, const void *cont=0)
Set bit of the flag at index position.
Definition: TrigPassFlags.cxx:18
TrigPassFlags::size
unsigned int size() const
gets size of the container object vector
Definition: TrigPassFlags.h:73
TrigPassFlags::setFlag
void setFlag(const unsigned int position, const std::vector< bool > &flag, const void *cont=0)
Set the flag at index position.
Definition: TrigPassFlags.cxx:31
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
master.flag
bool flag
Definition: master.py:29
TrigPassFlags::flagSize
unsigned int flagSize() const
gets size of the flag vector for the object at index
Definition: TrigPassFlags.h:78
TrigPassFlags::getFlag
const std::vector< bool > & getFlag(const unsigned int position) const
Returns the flag (vector<bool>) at index position.
Definition: TrigPassFlags.cxx:54
TrigPassFlags.h
TrigPassFlags::TrigPassFlags
TrigPassFlags()
Definition: TrigPassFlags.cxx:8
TrigPassFlags::m_container_ptr
const void * m_container_ptr
Definition: TrigPassFlags.h:83
TrigPassFlags::m_flagsPerObject
std::vector< std::vector< bool > > m_flagsPerObject
list of trainsient n-bit value (STL docu assures that a vector of booleans is efficient)
Definition: TrigPassFlags.h:84
TrigPassFlags::getFlagBit
bool getFlagBit(const unsigned int position, const unsigned int bitPosition) const
Returns the bit 'bitPosition' of the flag at index position.
Definition: TrigPassFlags.cxx:44