Public Types | Public Member Functions | Public Attributes | List of all members
FlaggerBase< E, T > Class Template Referenceabstract

#include <FlagBase.h>

Inheritance diagram for FlaggerBase< E, T >:
Inheritance graph
[legend]

Public Types

typedef E value_t
 
typedef T storage_t
 
typedef Dictionary< std::string, E > dict_t
 
typedef dict_t::key_t key_t
 

Public Member Functions

 FlaggerBase (char separator=',')
 
 FlaggerBase (storage_t &v, char separator=',')
 Value-referencing constructor. More...
 
virtual const dict_tgetDict () const =0
 Returns the static dictionary created for this value_t . More...
 
virtual void reset ()
 
virtual void set (const key_t &key)
 Sets one or several flags.
 
virtual void set (const value_t &value)
 Set a single flag.
 
virtual void set (const FlaggerBase< E > &flagger)
 
virtual bool isSet (const storage_t &x) const =0
 Checks if a given bit, or any of given bits, is set. More...
 
bool isSet (const key_t &key) const
 
const storage_t & getValue () const
 
 operator const storage_t & () const
 Given an integer, retrieves dictionary keys corresponding to each index of set bits.
 
 operator storage_t & ()
 
 operator bool () const
 
virtual const key_t & str () const =0
 String corresponding the current value. Returns empty, if not found.
 
 operator const key_t & () const
 
void debug (std::ostream &ostr) const
 

Public Attributes

storage_t & value
 
char separator
 

Detailed Description

template<typename E = std::size_t, typename T = E>
class drain::FlaggerBase< E, T >

A Flag mapper designed for global use, also supporting ENUM types. @See Perhaps replacing GlobalFlagger later.

Example:

enum Crit {DATA, ELANGLE, TIME};
template <>
const SingleFlagger<Crit>::dict_t SingleFlagger<Crit>::dict = {{"DATA", DATA}, {"ELANGLE", ELANGLE}, {"TIME", TIME}};

Inside a class:

class Reader {
public:
enum Mode {ATTRIBUTES=1, DATASETS=2};
}
// In the same or another header file:
template <>
// In the definition file:
template <>
{{"ATTRIBUTES", Reader::ATTRIBUTES}, {"DATASETS", Reader::DATASETS}};
Two-way mapping between strings and objects of template class T.
Definition: Dictionary.h:63
Definition: Flags.h:70
Definition: Flags-example.cpp:165
Template Parameters
E- single-value type: enum or integer
T- storage type (bit vector, "state"). T should not be enum, if E is numeric.

Constructor & Destructor Documentation

◆ FlaggerBase()

FlaggerBase ( storage_t &  v,
char  separator = ',' 
)
inline

Value-referencing constructor.

An external value will be used, leaving protected ownValue unused . Reconsider design. Should the value ever be referenced?

Member Function Documentation

◆ getDict()

virtual const dict_t& getDict ( ) const
pure virtual

Returns the static dictionary created for this value_t .

Notice that this function is non-static but returns a reference to a static dictionary. In C++ virtual functions must be non-static. This is nevertheless handy in templated design, for example.

Implemented in MultiFlagger< E, T >, MultiFlagger< int >, MultiFlagger< group_t, group_t >, and SingleFlagger< E >.

◆ isSet()

virtual bool isSet ( const storage_t &  x) const
pure virtual

Checks if a given bit, or any of given bits, is set.

SingleFlagger: exact match MultiFlagger: bitwise OR > 0

Implemented in MultiFlagger< int >, MultiFlagger< group_t, group_t >, and SingleFlagger< E >.


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