The Sparta Modeling Framework
|
The type-to-type name map. Not really necessary, but useful. More...
#include <KeyValue.hpp>
Classes | |
class | TypeNameVisitor |
Visitor class for looking up type name. More... | |
Public Member Functions | |
template<class U > | |
KeyValue (const std::string &key, U val, const std::string &desc="") | |
Construct a Key/Value pair. | |
std::string | getKey () const |
Get the key. | |
void | setDesc (const std::string &desc) |
Set the description. | |
std::string | getDesc () const |
Get the Description. | |
template<class T > | |
const T | getValue () const |
Get the value of this key/value. | |
template<class T > | |
void | operator= (const T &rhp) |
Assign a new value to this object. | |
template<class T > | |
operator T () const | |
Cast operator for the key/value. | |
const std::string & | getTypeName () const |
Gets the compiler-independent readable type string of the value currently held. | |
Static Public Member Functions | |
template<typename T > | |
static bool | hasTypeNameFor () |
Determines if there is a known compiler-independent typename for type T. | |
template<typename T > | |
static const std::string & | lookupTypeName () |
Determines if there is a known compiler-independent typename for type T. | |
Static Public Attributes | |
static TypeToTypeNameMap | GBL_type_name_map |
Map of internal typeid names to C++ names. | |
Protected Member Functions | |
template<class T > | |
T & | getValueRef_ () |
Gets a reference to the value currently held by this object if the correct template type is specified. | |
template<class T > | |
const T & | getValueRef_ () const |
The type-to-type name map. Not really necessary, but useful.
The variant list that the KeyValue class will support. To add a new type, just add it to the end of this list.
All elements in this list must:
This class hold a key/value pair
Definition at line 75 of file KeyValue.hpp.
|
inline |
Construct a Key/Value pair.
key | The key |
val | The ValueVar (can be anything of any of the above supported types) |
Example usage:
Definition at line 104 of file KeyValue.hpp.
|
inline |
|
inline |
|
inline |
Gets the compiler-independent readable type string of the value currently held.
SpartaException | if held variant type is not a known type. This indicates a serious error. |
Definition at line 261 of file KeyValue.hpp.
|
inline |
Get the value of this key/value.
boost::bad_get | if the type requested does not match the type of the key |
A painful way to get to the value of the key/value. Example usage:
Definition at line 158 of file KeyValue.hpp.
|
inlineprotected |
Gets a reference to the value currently held by this object if the correct template type is specified.
T | type to get current value as. This nmust be the type described by getTypeName or an exception will likely be thrown |
boost::bad_get | if T does not match the current held type. |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 279 of file KeyValue.hpp.
|
inlineprotected |
Definition at line 294 of file KeyValue.hpp.
|
inlinestatic |
Determines if there is a known compiler-independent typename for type T.
T | Type for which a name will be looked up |
Definition at line 216 of file KeyValue.hpp.
|
inlinestatic |
Determines if there is a known compiler-independent typename for type T.
T | Type for which a name will be looked up |
SpartaException | if no name was found associated with type T |
Definition at line 231 of file KeyValue.hpp.
|
inline |
Cast operator for the key/value.
boost::bad_get | if the type requested does not match the type of the key |
A fast way to get to the value of the key/value. Example usage:
Definition at line 206 of file KeyValue.hpp.
|
inline |
Assign a new value to this object.
SpartaException | if value specified cannot be assigned to the internal variant. |
Definition at line 189 of file KeyValue.hpp.
|
inline |
Set the description.
desc | The description of this key/value pair |
Definition at line 133 of file KeyValue.hpp.
|
static |
Map of internal typeid names to C++ names.
Used for looking up human-readable C++ names based on variant or template types.
Definition at line 87 of file KeyValue.hpp.