fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::ebitset_r< T, B > Class Template Reference

Atomic bitset for enums. More...

#include <f8utils.hpp>

Public Member Functions

 ebitset_r ()
 Ctor. More...
 
 ebitset_r (const ebitset_r< T, B > &from)
 
 ebitset_r (const integral_type a)
 
 ebitset_r (const T sbit)
 
ebitset_r< T, B > & operator= (const ebitset_r< T, B > &that)
 
integral_type has (const T sbit) const
 
integral_type operator& (const T sbit) const
 
void set (const T sbit, bool on=true)
 
bool set (const std::vector< std::string > &sset, const std::string &what, bool ignorecase=false, bool on=true)
 
void set (const integral_type bset)
 
void clear (const T sbit)
 
void clearall ()
 Clear all bits. More...
 
void setall (const T sbit)
 
integral_type get () const
 
void operator|= (const T sbit)
 
void operator&= (const T sbit)
 
ebitset_roperator<< (const T sbit)
 

Private Types

using integral_type = B
 

Private Attributes

f8_atomic< integral_typea_
 

Detailed Description

template<typename T, typename B = unsigned int>
class FIX8::ebitset_r< T, B >

Atomic bitset for enums.

Template Parameters
Tthe enum type
Bthe integral type of the enumeration

Definition at line 941 of file f8utils.hpp.

Member Typedef Documentation

template<typename T, typename B = unsigned int>
using FIX8::ebitset_r< T, B >::integral_type = B
private

Definition at line 943 of file f8utils.hpp.

Constructor & Destructor Documentation

template<typename T, typename B = unsigned int>
FIX8::ebitset_r< T, B >::ebitset_r ( )
inline

Ctor.

Definition at line 948 of file f8utils.hpp.

948 { a_ = 0; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
FIX8::ebitset_r< T, B >::ebitset_r ( const ebitset_r< T, B > &  from)
inline

Ctor.

Parameters
fromebitset_r to copy

Definition at line 952 of file f8utils.hpp.

952 { a_ = from.a_; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
FIX8::ebitset_r< T, B >::ebitset_r ( const integral_type  a)
inlineexplicit

Ctor.

Parameters
aintegral type to construct from

Definition at line 956 of file f8utils.hpp.

956 { a_ = a; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
FIX8::ebitset_r< T, B >::ebitset_r ( const T  sbit)
inlineexplicit

Ctor.

Parameters
sbitenum to construct from

Definition at line 960 of file f8utils.hpp.

960 { a_ = (1 << sbit) - 1; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944

Member Function Documentation

template<typename T, typename B = unsigned int>
void FIX8::ebitset_r< T, B >::clear ( const T  sbit)
inline

Clear a bit on or off.

Parameters
sbitenum to set

Definition at line 1011 of file f8utils.hpp.

Referenced by FIX8::Session::start().

1011 { integral_type a = a_; a &= ~(1 << sbit); a_ = a; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
void FIX8::ebitset_r< T, B >::clearall ( )
inline

Clear all bits.

Definition at line 1014 of file f8utils.hpp.

1014 { a_ = 0; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
integral_type FIX8::ebitset_r< T, B >::get ( ) const
inline

Get the enum integral_type.

Returns
integral_type of enum

Definition at line 1022 of file f8utils.hpp.

1022 { return a_; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
integral_type FIX8::ebitset_r< T, B >::has ( const T  sbit) const
inline

Check if an enum is in the set.

Parameters
sbitenum to check
Returns
integral_type of bits if found

Definition at line 975 of file f8utils.hpp.

Referenced by FIX8::Session::is_shutdown().

975 { return a_ & 1 << sbit; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
integral_type FIX8::ebitset_r< T, B >::operator& ( const T  sbit) const
inline

Check if an enum is in the set.

Parameters
sbitenum to check
Returns
integral_type of bits if found

Definition at line 980 of file f8utils.hpp.

980 { return a_ & 1 << sbit; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
void FIX8::ebitset_r< T, B >::operator&= ( const T  sbit)
inline

And a bit value with the current set.

Parameters
sbitto set

Definition at line 1030 of file f8utils.hpp.

1030 { integral_type a = a_; a &= 1 << sbit; a_ = a; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
ebitset_r& FIX8::ebitset_r< T, B >::operator<< ( const T  sbit)
inline

Or a bit value with the current set.

Parameters
sbitto set
Returns
ebitset_r

Definition at line 1035 of file f8utils.hpp.

1035 { a_ |= 1 << sbit; return *this; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
ebitset_r<T, B>& FIX8::ebitset_r< T, B >::operator= ( const ebitset_r< T, B > &  that)
inline

Assignment operator.

Parameters
thatebitset_r to assign from
Returns
this

Definition at line 965 of file f8utils.hpp.

966  {
967  if (this != &that)
968  a_ = that.a_;
969  return *this;
970  }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
void FIX8::ebitset_r< T, B >::operator|= ( const T  sbit)
inline

Or a bit value with the current set.

Parameters
sbitto set

Definition at line 1026 of file f8utils.hpp.

1026 { integral_type a = a_; a |= 1 << sbit; a_ = a; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
void FIX8::ebitset_r< T, B >::set ( const T  sbit,
bool  on = true 
)
inline

Set a bit on or off.

Parameters
sbitenum to set
onset on or off

Definition at line 985 of file f8utils.hpp.

Referenced by FIX8::ebitset_r< SessionControl >::set().

985 { if (on) a_ |= 1 << sbit; else a_ &= ~(1 << sbit); }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
bool FIX8::ebitset_r< T, B >::set ( const std::vector< std::string > &  sset,
const std::string &  what,
bool  ignorecase = false,
bool  on = true 
)
inline

From a set of strings representing the names of each bit in order, set the named bit on.

Parameters
ssetthe set of strings
whatthe string to find and set
ignorecaseif true, ignore case
onset or clear the found bit
Returns
true if found and set

Definition at line 993 of file f8utils.hpp.

994  {
995  auto itr(sset.cbegin());
996  for (; itr != sset.cend(); ++itr)
997  if (ignorecase ? trim(*itr) % what : trim(*itr) == what)
998  break;
999  if (itr == sset.cend())
1000  return false;
1001  set(static_cast<T>(std::distance(sset.cbegin(), itr)), on);
1002  return true;
1003  }
std::string trim(const std::string &source, const std::string &ws=" \t")
Definition: f8utils.hpp:153
void set(const T sbit, bool on=true)
Definition: f8utils.hpp:985
template<typename T, typename B = unsigned int>
void FIX8::ebitset_r< T, B >::set ( const integral_type  bset)
inline

Set a bit on or off.

Parameters
bsetintegral_type to set

Definition at line 1007 of file f8utils.hpp.

1007 { a_ = bset; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944
template<typename T, typename B = unsigned int>
void FIX8::ebitset_r< T, B >::setall ( const T  sbit)
inline

Set all bits to a value.

Parameters
sbitvalue to set to

Definition at line 1018 of file f8utils.hpp.

1018 { a_ = (1 << sbit) - 1; }
f8_atomic< integral_type > a_
Definition: f8utils.hpp:944

Member Data Documentation


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