CHROMA
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Chroma::EnumTypeMap< EnumType > Class Template Reference

Main enum std::map holder. More...

#include <enum_type_map.h>

Classes

struct  EnumLookupException
 
struct  StringLookupException
 

Public Types

typedef std::map< std::string, EnumType > Str2Enum
 
typedef std::map< EnumType, std::string > Enum2Str
 
typedef std::map< std::string, EnumType >::iterator Str2EnumIterator
 
typedef std::map< EnumType, std::string >::iterator Enum2StrIterator
 

Public Member Functions

 EnumTypeMap ()
 
bool registerPair (const std::string &s, const EnumType t)
 Function registers a std::string/enum pair. More...
 
EnumType lookUpEnum (const std::string &s)
 Look up an enum based on a std::string. More...
 
std::string lookUpString (const EnumType &t)
 Look up a std::string from an enum. More...
 
void read (const std::string &typeIDString, XMLReader &xml_in, const std::string &path, EnumType &t)
 "Reader" More...
 
void write (const std::string &typeIDString, XMLWriter &xml_out, const std::string &path, const EnumType &t)
 Writer. More...
 
void read (const std::string &typeIDString, BinaryReader &bin_in, EnumType &t)
 "Reader" More...
 
void write (const std::string &typeIDString, BinaryWriter &bin_out, const EnumType &t)
 Writer. More...
 

Private Member Functions

 EnumTypeMap (const EnumTypeMap< EnumType > &t)
 
void dumpMapStrings (const std::string &typeIDString)
 

Private Attributes

Enum2Str enum_map
 
Str2Enum str_map
 

Detailed Description

template<typename EnumType>
class Chroma::EnumTypeMap< EnumType >

Main enum std::map holder.

Enums used throughout the code and their initialization via std::maps. This is used for IO.

Definition at line 26 of file enum_type_map.h.

Member Typedef Documentation

◆ Enum2Str

template<typename EnumType >
typedef std::map<EnumType, std::string> Chroma::EnumTypeMap< EnumType >::Enum2Str

Definition at line 30 of file enum_type_map.h.

◆ Enum2StrIterator

template<typename EnumType >
typedef std::map<EnumType, std::string>::iterator Chroma::EnumTypeMap< EnumType >::Enum2StrIterator

Definition at line 32 of file enum_type_map.h.

◆ Str2Enum

template<typename EnumType >
typedef std::map<std::string, EnumType> Chroma::EnumTypeMap< EnumType >::Str2Enum

Definition at line 29 of file enum_type_map.h.

◆ Str2EnumIterator

template<typename EnumType >
typedef std::map<std::string, EnumType>::iterator Chroma::EnumTypeMap< EnumType >::Str2EnumIterator

Definition at line 31 of file enum_type_map.h.

Constructor & Destructor Documentation

◆ EnumTypeMap() [1/2]

template<typename EnumType >
Chroma::EnumTypeMap< EnumType >::EnumTypeMap ( const EnumTypeMap< EnumType > &  t)
inlineprivate

Definition at line 36 of file enum_type_map.h.

◆ EnumTypeMap() [2/2]

template<typename EnumType >
Chroma::EnumTypeMap< EnumType >::EnumTypeMap ( )
inline

Definition at line 59 of file enum_type_map.h.

Member Function Documentation

◆ dumpMapStrings()

template<typename EnumType >
void Chroma::EnumTypeMap< EnumType >::dumpMapStrings ( const std::string &  typeIDString)
inlineprivate

◆ lookUpEnum()

template<typename EnumType >
EnumType Chroma::EnumTypeMap< EnumType >::lookUpEnum ( const std::string &  s)
inline

Look up an enum based on a std::string.

Definition at line 96 of file enum_type_map.h.

References it, Chroma::s(), Chroma::EnumTypeMap< EnumType >::str_map, and t.

Referenced by Chroma::EnumTypeMap< EnumType >::read().

◆ lookUpString()

template<typename EnumType >
std::string Chroma::EnumTypeMap< EnumType >::lookUpString ( const EnumType &  t)
inline

Look up a std::string from an enum.

Definition at line 113 of file enum_type_map.h.

References Chroma::EnumTypeMap< EnumType >::enum_map, it, Chroma::s(), and t.

Referenced by Chroma::EnumTypeMap< EnumType >::write().

◆ read() [1/2]

template<typename EnumType >
void Chroma::EnumTypeMap< EnumType >::read ( const std::string &  typeIDString,
BinaryReader &  bin_in,
EnumType &  t 
)
inline

◆ read() [2/2]

template<typename EnumType >
void Chroma::EnumTypeMap< EnumType >::read ( const std::string &  typeIDString,
XMLReader &  xml_in,
const std::string &  path,
EnumType &  t 
)
inline

◆ registerPair()

template<typename EnumType >
bool Chroma::EnumTypeMap< EnumType >::registerPair ( const std::string &  s,
const EnumType  t 
)
inline

Function registers a std::string/enum pair.

Enum-String pairs are initialised when the relevant env's "registered" boolean is set, and this may well be before QDP is initialised. So it is not safe to call QDPIO::cerr in this pair registration function.... Printing to std::cerr works tho. So I add it. Message should only be generated if registration fails which is most likely to be due to a duplicate key. This is a useful check that I haven't left duplicates in the registerAll() functions.

Definition at line 73 of file enum_type_map.h.

References Chroma::EnumTypeMap< EnumType >::enum_map, Chroma::s(), Chroma::EnumTypeMap< EnumType >::str_map, and t.

◆ write() [1/2]

template<typename EnumType >
void Chroma::EnumTypeMap< EnumType >::write ( const std::string &  typeIDString,
BinaryWriter &  bin_out,
const EnumType &  t 
)
inline

◆ write() [2/2]

template<typename EnumType >
void Chroma::EnumTypeMap< EnumType >::write ( const std::string &  typeIDString,
XMLWriter &  xml_out,
const std::string &  path,
const EnumType &  t 
)
inline

Member Data Documentation

◆ enum_map

template<typename EnumType >
Enum2Str Chroma::EnumTypeMap< EnumType >::enum_map
private

◆ str_map

template<typename EnumType >
Str2Enum Chroma::EnumTypeMap< EnumType >::str_map
private

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