ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11TrigPassFlags::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
18void 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
31void 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
44bool 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
54const 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
unsigned int flagSize() const
gets size of the flag vector for the object at index
bool getFlagBit(const unsigned int position, const unsigned int bitPosition) const
Returns the bit 'bitPosition' of the flag at index position.
const std::vector< bool > & getFlag(const unsigned int position) const
Returns the flag (vector<bool>) at index position.
std::vector< std::vector< bool > > m_flagsPerObject
list of trainsient n-bit value (STL docu assures that a vector of booleans is efficient)
const void * m_container_ptr
unsigned int size() const
gets size of the container object vector
void setFlag(const unsigned int position, const std::vector< bool > &flag, const void *cont=0)
Set the flag at index position.
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.