LArSoft
v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
|
Classes and functions to manage bit masks and flags. More...
Namespaces | |
details | |
errors | |
Namespace enclosing BitMask exceptions. | |
Classes | |
class | BitMask |
A class containing a set of flags. More... | |
struct | BitMaskFromValuesTag |
Type for constructor tag from values. More... | |
struct | Bits_t |
Type identifying a set of bits. More... | |
struct | Flag_t |
Type identifying a flag. Operations are implemented as free functions. More... | |
class | FlagSet |
A class containing a set of flags. More... | |
Typedefs | |
using | Index_t = unsigned int |
Type to denote the index of the flag. More... | |
Functions | |
template<typename Storage > | |
std::ostream & | operator<< (std::ostream &out, Flag_t< Storage > flag) |
Output of a flag into a stream (prints its index). More... | |
template<typename Storage > | |
std::string | to_string (Flag_t< Storage > const flag) |
Convert a flag into a stream (shows its index). More... | |
template<typename Stream , typename Storage > | |
Stream & | operator<< (Stream &&out, BitMask< Storage > const &mask) |
Output of a bit mask into a stream. More... | |
template<typename Storage > | |
constexpr BitMask< Storage > | makeMask (Bits_t< Storage > bits) |
Constructs a mask from bits. More... | |
template<unsigned int NBits, typename Storage > | |
std::ostream & | operator<< (std::ostream &out, FlagSet< NBits, Storage > const &flags) |
Output of a flag set into a stream. More... | |
Comparison operators for flags (based on the index) | |
template<typename Storage > | |
constexpr bool | operator== (Index_t left, Flag_t< Storage > right) |
template<typename Storage > | |
constexpr bool | operator== (Flag_t< Storage > left, Index_t right) |
template<typename Storage > | |
constexpr bool | operator!= (Index_t left, Flag_t< Storage > right) |
template<typename Storage > | |
constexpr bool | operator!= (Flag_t< Storage > left, Index_t right) |
template<typename Storage > | |
constexpr bool | operator< (Index_t left, Flag_t< Storage > right) |
template<typename Storage > | |
constexpr bool | operator< (Flag_t< Storage > left, Index_t right) |
template<typename Storage > | |
constexpr bool | operator> (Index_t left, Flag_t< Storage > right) |
template<typename Storage > | |
constexpr bool | operator> (Flag_t< Storage > left, Index_t right) |
template<typename Storage > | |
constexpr bool | operator<= (Index_t left, Flag_t< Storage > right) |
template<typename Storage > | |
constexpr bool | operator<= (Flag_t< Storage > left, Index_t right) |
template<typename Storage > | |
constexpr bool | operator>= (Index_t left, Flag_t< Storage > right) |
template<typename Storage > | |
constexpr bool | operator>= (Flag_t< Storage > left, Index_t right) |
Flag and bit operations. | |
Any bitwise operation with a flag returns a | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator| (Bits_t< Storage > left, Bits_t< Storage > right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator| (Bits_t< Storage > left, typename Bits_t< Storage >::Flag_t right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator| (typename Bits_t< Storage >::Flag_t left, Bits_t< Storage > right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator| (Flag_t< Storage > left, Flag_t< Storage > right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator+ (Bits_t< Storage > left, Bits_t< Storage > right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator+ (Bits_t< Storage > left, typename Bits_t< Storage >::Flag_t right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator+ (typename Bits_t< Storage >::Flag_t left, Bits_t< Storage > right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
template<typename Storage > | |
constexpr Bits_t< Storage > | operator+ (Flag_t< Storage > left, Flag_t< Storage > right) |
Returns a new Bits_t with all the bits from both arguments set. More... | |
Flag and mask management | |
The operations use the first operand as the starting point for the result. The binary operations in this group are:
The unary operations are:
| |
template<typename Storage > | |
constexpr BitMask< Storage > | operator| (BitMask< Storage > left, BitMask< Storage > right) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator| (BitMask< Storage > left, typename BitMask< Storage >::Bits_t right) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator| (typename BitMask< Storage >::Bits_t left, BitMask< Storage > right) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator& (BitMask< Storage > left, BitMask< Storage > right) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator& (BitMask< Storage > left, typename BitMask< Storage >::Bits_t right) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator& (typename BitMask< Storage >::Bits_t left, BitMask< Storage > right) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator& (Bits_t< Storage > left, Bits_t< Storage > right) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator+ (BitMask< Storage > baseMask, BitMask< Storage > mask) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator+ (BitMask< Storage > baseMask, typename BitMask< Storage >::Bits_t bits) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator+ (typename BitMask< Storage >::Bits_t baseBits, BitMask< Storage > mask) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator- (BitMask< Storage > baseMask, BitMask< Storage > mask) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator- (BitMask< Storage > baseMask, typename BitMask< Storage >::Bits_t bits) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator- (typename BitMask< Storage >::Bits_t baseBits, BitMask< Storage > mask) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator- (Bits_t< Storage > baseBits, Bits_t< Storage > bits) |
template<typename Storage > | |
constexpr BitMask< Storage > | operator+ (BitMask< Storage > mask) |
Returns a copy of the mask. More... | |
template<typename Storage > | |
constexpr BitMask< Storage > | operator+ (Bits_t< Storage > bits) |
Returns a mask with the specified bits set. More... | |
template<typename Storage > | |
constexpr BitMask< Storage > | operator- (Bits_t< Storage > bits) |
Returns a mask M = -B so that A + M is equivalent to A - B . More... | |
template<typename Storage > | |
constexpr BitMask< Storage > | operator- (Flag_t< Storage > flag) |
Returns a mask M = -B so that A + M is equivalent to A - B . More... | |
template<typename Storage > | |
constexpr BitMask< Storage > | operator~ (BitMask< Storage > mask) |
Returns a bit set which unsets the specified bits. More... | |
template<typename Storage > | |
constexpr BitMask< Storage > | Set (Flag_t< Storage > flag) |
Returns a bit mask which sets the specified flag. More... | |
template<typename Storage > | |
constexpr BitMask< Storage > | Unset (Flag_t< Storage > flag) |
Returns a bit mask which unsets the specified flag. More... | |
Variables | |
constexpr BitMaskFromValuesTag | maskFromValues {} |
Value useful for BitMask constructors from value. More... | |
Classes and functions to manage bit masks and flags.
In this namespace a "hierarchy" of classes are defined:
Flag_t
: a single bit; it can be initialized with the bit index, but it is stored as a bit mask. A flag has two states: set and unset.Bits_t
: a set of flags (represented as a bit mask).BitMask
: a set of flags which can have one of three states each: set, unset or undefined.FlagSet
: a set of flags (like BitMask
), with the knowledge of a total number of supported flags.The first three classes manage exactly how many bits they have storage for. FlagSet
instead has also the notion of how many flags are actually supported. A number of flag-wise operations are defined. The result of an operation between two classes might be a class of a superior level in the hierarchy. In this sense, the lower objects should be intended as shortcut representations of Bits_t
. More specifically:
Bits_t
can be created out of a Flag_t
BitMask
can be created out of a Bits_t
(or a Flag_t
)~Flag_t
is not definedBits_t | Bits_t
and Bits_t + Bits_t
are still Bits_t
(and they are equivalent)Bits_t & Bits_t
and Bits_t - Bits_t
are BitMask
, to preserve the information of bits that are defined and unset~Bits_t
is a BitMask
as well using util::flags::Index_t = typedef unsigned int |
constexpr BitMask<Storage> util::flags::makeMask | ( | Bits_t< Storage > | bits | ) |
Constructs a mask from bits.
Referenced by recob::TrajectoryPointFlags::DefaultFlagsMask(), recob::TrajectoryPointFlags::dump(), and operator<<().
constexpr bool util::flags::operator!= | ( | Index_t | left, |
Flag_t< Storage > | right | ||
) |
Definition at line 144 of file BitMask.h.
References util::flags::Flag_t< Storage >::index().
constexpr bool util::flags::operator!= | ( | Flag_t< Storage > | left, |
Index_t | right | ||
) |
Definition at line 147 of file BitMask.h.
References util::flags::Flag_t< Storage >::index(), and art::right().
constexpr BitMask<Storage> util::flags::operator& | ( | BitMask< Storage > | left, |
BitMask< Storage > | right | ||
) |
Returns a mask which intersects two of them.
BitMask<Storage>::intersectWithMask()
constexpr BitMask<Storage> util::flags::operator& | ( | BitMask< Storage > | left, |
typename BitMask< Storage >::Bits_t | right | ||
) |
Returns a mask which intersects two of them.
BitMask<Storage>::intersectWithMask()
constexpr BitMask<Storage> util::flags::operator& | ( | typename BitMask< Storage >::Bits_t | left, |
BitMask< Storage > | right | ||
) |
Returns a mask which intersects two of them.
BitMask<Storage>::intersectWithMask()
constexpr BitMask<Storage> util::flags::operator& | ( | Bits_t< Storage > | left, |
Bits_t< Storage > | right | ||
) |
Returns a mask which intersects two of them.
BitMask<Storage>::intersectWithMask()
constexpr Bits_t<Storage> util::flags::operator+ | ( | Bits_t< Storage > | left, |
Bits_t< Storage > | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
Referenced by operator<<().
constexpr Bits_t<Storage> util::flags::operator+ | ( | Bits_t< Storage > | left, |
typename Bits_t< Storage >::Flag_t | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
constexpr Bits_t<Storage> util::flags::operator+ | ( | typename Bits_t< Storage >::Flag_t | left, |
Bits_t< Storage > | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
constexpr Bits_t<Storage> util::flags::operator+ | ( | Flag_t< Storage > | left, |
Flag_t< Storage > | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
constexpr BitMask<Storage> util::flags::operator+ | ( | BitMask< Storage > | baseMask, |
BitMask< Storage > | mask | ||
) |
Returns a mask which merges two of them.
BitMask<Storage>::mergeIntoMask()
constexpr BitMask<Storage> util::flags::operator+ | ( | BitMask< Storage > | baseMask, |
typename BitMask< Storage >::Bits_t | bits | ||
) |
Returns a mask which merges two of them
BitMask<Storage>::mergeIntoMask()
constexpr BitMask<Storage> util::flags::operator+ | ( | typename BitMask< Storage >::Bits_t | baseBits, |
BitMask< Storage > | mask | ||
) |
Returns a mask which merges two of them
BitMask<Storage>::mergeIntoMask()
constexpr BitMask<Storage> util::flags::operator+ | ( | BitMask< Storage > | mask | ) |
Returns a copy of the mask.
constexpr BitMask<Storage> util::flags::operator+ | ( | Bits_t< Storage > | bits | ) |
Returns a mask with the specified bits set.
constexpr BitMask<Storage> util::flags::operator- | ( | BitMask< Storage > | baseMask, |
BitMask< Storage > | mask | ||
) |
Returns a mask set which defines and unsets the bits set in the mask.
BitMask<Storage>::unsetMask()
Referenced by operator<<().
constexpr BitMask<Storage> util::flags::operator- | ( | BitMask< Storage > | baseMask, |
typename BitMask< Storage >::Bits_t | bits | ||
) |
Returns a mask set which defines and unsets the specified bits.
BitMask<Storage>::unsetMask()
constexpr BitMask<Storage> util::flags::operator- | ( | typename BitMask< Storage >::Bits_t | baseBits, |
BitMask< Storage > | mask | ||
) |
Returns a mask set which defines and unsets the bits set in the mask.
BitMask<Storage>::unsetMask()
constexpr BitMask<Storage> util::flags::operator- | ( | Bits_t< Storage > | baseBits, |
Bits_t< Storage > | bits | ||
) |
Returns a mask which defines and unsets the specified bits.
BitMask<Storage>::unsetMask()
constexpr BitMask<Storage> util::flags::operator- | ( | Bits_t< Storage > | bits | ) |
Returns a mask M = -B
so that A + M
is equivalent to A - B
.
constexpr BitMask<Storage> util::flags::operator- | ( | Flag_t< Storage > | flag | ) |
Returns a mask M = -B
so that A + M
is equivalent to A - B
.
constexpr bool util::flags::operator< | ( | Index_t | left, |
Flag_t< Storage > | right | ||
) |
Definition at line 151 of file BitMask.h.
References art::left(), and art::right().
constexpr bool util::flags::operator< | ( | Flag_t< Storage > | left, |
Index_t | right | ||
) |
Definition at line 154 of file BitMask.h.
References art::right().
std::ostream& util::flags::operator<< | ( | std::ostream & | out, |
Flag_t< Storage > | flag | ||
) |
std::ostream& util::flags::operator<< | ( | std::ostream & | out, |
FlagSet< NBits, Storage > const & | flags | ||
) |
Stream& util::flags::operator<< | ( | Stream && | out, |
BitMask< Storage > const & | mask | ||
) |
Output of a bit mask into a stream.
Definition at line 1203 of file BitMask.h.
References art::left(), makeMask(), operator+(), operator-(), art::right(), Set(), and Unset().
constexpr bool util::flags::operator<= | ( | Index_t | left, |
Flag_t< Storage > | right | ||
) |
Definition at line 165 of file BitMask.h.
References art::right().
constexpr bool util::flags::operator<= | ( | Flag_t< Storage > | left, |
Index_t | right | ||
) |
Definition at line 168 of file BitMask.h.
References art::right().
constexpr bool util::flags::operator== | ( | Index_t | left, |
Flag_t< Storage > | right | ||
) |
Definition at line 137 of file BitMask.h.
References util::flags::Flag_t< Storage >::index().
constexpr bool util::flags::operator== | ( | Flag_t< Storage > | left, |
Index_t | right | ||
) |
Definition at line 140 of file BitMask.h.
References util::flags::Flag_t< Storage >::index(), and art::right().
constexpr bool util::flags::operator> | ( | Index_t | left, |
Flag_t< Storage > | right | ||
) |
Definition at line 158 of file BitMask.h.
References util::flags::Flag_t< Storage >::index().
constexpr bool util::flags::operator> | ( | Flag_t< Storage > | left, |
Index_t | right | ||
) |
Definition at line 161 of file BitMask.h.
References util::flags::Flag_t< Storage >::index(), and art::right().
constexpr bool util::flags::operator>= | ( | Index_t | left, |
Flag_t< Storage > | right | ||
) |
Definition at line 172 of file BitMask.h.
References util::flags::Flag_t< Storage >::index().
constexpr bool util::flags::operator>= | ( | Flag_t< Storage > | left, |
Index_t | right | ||
) |
Definition at line 175 of file BitMask.h.
References util::flags::Flag_t< Storage >::index(), and art::right().
constexpr Bits_t<Storage> util::flags::operator| | ( | Bits_t< Storage > | left, |
Bits_t< Storage > | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
constexpr Bits_t<Storage> util::flags::operator| | ( | Bits_t< Storage > | left, |
typename Bits_t< Storage >::Flag_t | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
constexpr Bits_t<Storage> util::flags::operator| | ( | typename Bits_t< Storage >::Flag_t | left, |
Bits_t< Storage > | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
constexpr Bits_t<Storage> util::flags::operator| | ( | Flag_t< Storage > | left, |
Flag_t< Storage > | right | ||
) |
Returns a new Bits_t with all the bits from both arguments set.
constexpr BitMask<Storage> util::flags::operator| | ( | BitMask< Storage > | left, |
BitMask< Storage > | right | ||
) |
Returns a mask which combines two of them.
BitMask<Storage>::combineWithMask()
constexpr BitMask<Storage> util::flags::operator| | ( | BitMask< Storage > | left, |
typename BitMask< Storage >::Bits_t | right | ||
) |
Returns a mask which merges two of them.
BitMask<Storage>::combineWithMask()
constexpr BitMask<Storage> util::flags::operator| | ( | typename BitMask< Storage >::Bits_t | left, |
BitMask< Storage > | right | ||
) |
Returns a mask which merges two of them.
BitMask<Storage>::combineWithMask()
constexpr BitMask<Storage> util::flags::operator~ | ( | BitMask< Storage > | mask | ) |
Returns a bit set which unsets the specified bits.
Returns a bit mask which sets the specified flag.
Referenced by operator<<().
std::string util::flags::to_string | ( | Flag_t< Storage > const | flag | ) |
Convert a flag into a stream (shows its index).
Definition at line 187 of file BitMask.h.
References util::flags::Flag_t< Storage >::index().
Referenced by proxy::details::associationRangesImpl(), lar::CollectionView< BoundaryListRangeBase< BoundaryIter > >::at(), calo::LinearEnergyAlg::CalculateEnergy(), sim::MCShower::Charge(), util::LazyVector< T, A >::check_range(), util::TensorIndices< 1U >::checkOuterIndex(), shower::EMShowerAlg::CheckShowerPlanes(), evd::RecoBaseDrawer::Cluster2D(), lar_pandora::LArPandoraOutput::CollectAllPfoOutcomes(), tca::CompleteIncomplete3DVertices(), reco_tool::BaselinedGausFitCache::CreateFunction(), recob::TrajectoryPointFlagTraits::decorateFlagName(), geo::part::PartitionContainer< Data >::describeIntro(), art::BasicOutputOptionsHandler::doCheckOptions(), recob::DumpPFParticles::DotFileName(), sim::MCShower::dQdx(), evd::TQPad::Draw(), evd::RecoBaseDrawer::DrawTrackOrtho(), evd::RecoBaseDrawer::DrawTrackVertexAssns2D(), tca::DumpTj(), evd::RecoBaseDrawer::EndPoint2D(), fhicl::detail::PrintAllowedConfiguration::enter_sequence(), mf::service::ELdestination::fillUsrMsg(), larg4::AuxDetReadoutGeometry::FindAndMakeAuxDet(), larg4::AuxDetReadoutGeometry::FindAndMakeAuxDetSensitive(), reco_tool::PeakFitterGaussian::findPeakParameters(), evgb::GENIEHelper::GENIEHelper(), lar_content::LArFormattingHelper::GetFormatCharacter(), lariov::DBFolder::GetTupleColumn(), fhicl::Name::index(), lar_content::MasterAlgorithm::InitializeWorkerInstances(), art::RPManager::makeRPs_(), tca::TruthMatcher::MatchAndSum(), evd::RawDataDrawer::ManyOperations::Name(), util::EventChangeTracker_t::operator std::string(), sim::ParticleName(), lar::example::SpacePartition< PointIter >::pointIndex(), evgen::SingleGen::presentOptions(), tca::Print2DShowers(), tca::Print2V(), tca::Print3S(), tca::Print3V(), tca::PrintAllTraj(), cluster::ClusterCrawlerAlg::PrintHit(), tca::PrintHit(), tca::PrintHitShort(), tca::PrintP(), tca::PrintPFP(), tca::PrintPos(), tca::PrintShower(), tca::PrintStopFlag(), tca::PrintT(), ProcessSingleFile(), evd::RecoBaseDrawer::Prong2D(), fhicl::intermediate_table::put(), lar::example::PointIsolationAlg< Coord >::rangeString(), art::detail::resolveRangeSetInfo(), evgen::NeutronOsc::SelectAnnihilationMode(), evgen::SingleGen::setup(), evd::TWQProjectionView::SetUpTPCselection(), evd::RecoBaseDrawer::Slice2D(), strip_pset(), evd::TWQProjectionView::TotalElementsString(), recob::TrackTrajectory::TrackTrajectory(), recob::Trajectory::Trajectory(), sim::TruthCCNCname(), sim::TruthInteractionTypeName(), sim::TruthOriginName(), lariov::DBFolder::UpdateData(), lar::example::PointIsolationAlg< Coord >::validateConfiguration(), evd::RecoBaseDrawer::Vertex2D(), geo::PlaneGeo::ViewName(), fhicl::ParameterSet::walk(), and want_pset().
Returns a bit mask which unsets the specified flag.
Referenced by operator<<().
constexpr BitMaskFromValuesTag util::flags::maskFromValues {} |