StringValueMap Class Reference

The StringValueMap class is a subclass of VariantContainer and is comparable to a std::map<std::string, T> containing values of type T. More...

#include <ArmarXCore/observers/variant/StringValueMap.h>

+ Inheritance diagram for StringValueMap:

Public Member Functions

void addElement (const std::string &key, const VariantContainerBasePtr &variantContainer, const Ice::Current &c=Ice::emptyCurrent) override
 
void addVariant (const std::string &key, const Variant &variant)
 
void clear (const Ice::Current &c=Ice::emptyCurrent) override
 clear calls clear() on the internal StringValueMap::elements container
 
VariantContainerBasePtr cloneContainer (const Ice::Current &c=Ice::emptyCurrent) const override
 
void deserialize (const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
 
template<typename ContainerType>
IceInternal::Handle< ContainerType > getElement (const std::string &key) const
 getElement is the getter-function to retrieve variants from the list.
 
VariantContainerBasePtr getElementBase (const std::string &key, const Ice::Current &c=Ice::emptyCurrent) const override
 getElementBase is the slice-interface implementation for getting an Element and only returns a basepointer, so a manual upcast is usually necessary.
 
int getSize (const Ice::Current &c=Ice::emptyCurrent) const override
 
Ice::Int getType (const Ice::Current &c=Ice::emptyCurrent) const override
 
VariantPtr getVariant (const std::string &key) const
 getVariant returns a pointer to a Variant object associated with key
 
Ice::ObjectPtr ice_clone () const override
 
StringValueMap & operator= (const StringValueMap &source)
 
void serialize (const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
 
void setElement (const std::string &key, const VariantContainerBasePtr &variantContainer, const Ice::Current &c=Ice::emptyCurrent) override
 
template<typename ValueType>
void setElements (const std::map< std::string, ValueType > &map)
 setElements adds all pairs from map to the current instance using StringValueMap::setElement().
 
template<typename ValueType>
void setElements (const std::vector< std::string > &keyVec, const std::vector< ValueType > &values)
 setElements adds elements with keyVec as keys and values as associated values using StringValueMap::setElement().
 
 StringValueMap (bool forceSingleTypeMap=true)
 
 StringValueMap (const ContainerType &subType)
 
 StringValueMap (const StringValueMap &source)
 
 StringValueMap (VariantTypeId subType)
 
template<typename Type>
std::map< std::string, Type > toContainerStdMap () const
 toContainerStdMap creates a std::map<std::string, Type> from this container.
 
template<class ValueType>
std::map< std::string, ValueType > toStdMap ()
 toStdMap creates a std::map<std::string, ValueType> from this container.
 
std::string toString (const Ice::Current &=Ice::emptyCurrent) const override
 
bool validateElements (const Ice::Current &c=Ice::emptyCurrent) override
 
- Public Member Functions inherited from VariantContainer
VariantDataClassPtr clone (const Ice::Current &c=Ice::emptyCurrent) const override
 
ContainerTypePtr getContainerType (const Ice::Current &c=Ice::emptyCurrent) const override
 
Ice::Int getType (const Ice::Current &c=Ice::emptyCurrent) const override
 
std::string output (const Ice::Current &c=Ice::emptyCurrent) const override
 
void setContainerType (const ContainerTypePtr &containerType, const Ice::Current &c=Ice::emptyCurrent) override
 
bool validate (const Ice::Current &c=Ice::emptyCurrent) override
 

Static Public Member Functions

template<typename Type>
static StringValueMapPtr FromContainerStdMap (const std::map< std::string, Type > &map)
 FromStdMap creates a StringValueMap from a std::map<std::string, Type>.
 
template<typename Type>
static StringValueMapPtr FromStdMap (const std::map< std::string, Type > &map)
 FromStdMap creates a StringValueMap from a std::map<std::string, Type>.
 
static VariantTypeId getStaticType (const Ice::Current &c=Ice::emptyCurrent)
 
static std::string getTypePrefix ()
 

Protected Attributes

bool forceSingleTypeMap = true
 

Detailed Description

The StringValueMap class is a subclass of VariantContainer and is comparable to a std::map<std::string, T> containing values of type T.

Constructor & Destructor Documentation

◆ StringValueMap() [1/4]

StringValueMap ( bool forceSingleTypeMap = true)

◆ StringValueMap() [2/4]

StringValueMap ( const StringValueMap & source)

◆ StringValueMap() [3/4]

StringValueMap ( const ContainerType & subType)
explicit

◆ StringValueMap() [4/4]

StringValueMap ( VariantTypeId subType)
explicit

Member Function Documentation

◆ addElement()

void addElement ( const std::string & key,
const VariantContainerBasePtr & variantContainer,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ addVariant()

void addVariant ( const std::string & key,
const Variant & variant )

◆ clear()

void clear ( const Ice::Current & c = Ice::emptyCurrent)
override

clear calls clear() on the internal StringValueMap::elements container

Parameters
c

◆ cloneContainer()

VariantContainerBasePtr cloneContainer ( const Ice::Current & c = Ice::emptyCurrent) const
override

◆ deserialize()

void deserialize ( const ObjectSerializerBasePtr & serializer,
const ::Ice::Current & = Ice::emptyCurrent )
override

◆ FromContainerStdMap()

template<typename Type>
static StringValueMapPtr FromContainerStdMap ( const std::map< std::string, Type > & map)
inlinestatic

FromStdMap creates a StringValueMap from a std::map<std::string, Type>.

std::map<std::string, VariantContainerPtr> containerMap;
cotnainerMap["c1"] = new VariantContainer();
containerMap["c2"] = new VariantContainer();
static StringValueMapPtr FromContainerStdMap(const std::map< std::string, Type > &map)
FromStdMap creates a StringValueMap from a std::map<std::string, Type>.
Definition StringValueMap.h:229
VariantContainer is the base class of all other Variant container classes.
Definition VariantContainer.h:85
IceInternal::Handle< StringValueMap > StringValueMapPtr
Definition StringValueMap.h:40

◆ FromStdMap()

template<typename Type>
static StringValueMapPtr FromStdMap ( const std::map< std::string, Type > & map)
inlinestatic

FromStdMap creates a StringValueMap from a std::map<std::string, Type>.

std::map<std::string, std::string> intMap;
intMap["p1"] = 1;
intMap["p2"] = 2;
static StringValueMapPtr FromStdMap(const std::map< std::string, Type > &map)
FromStdMap creates a StringValueMap from a std::map<std::string, Type>.
Definition StringValueMap.h:203

◆ getElement()

template<typename ContainerType>
IceInternal::Handle< ContainerType > getElement ( const std::string & key) const
inline

getElement is the getter-function to retrieve variants from the list.

Parameters
indexis the index of the Element in the list
Exceptions
IndexOutOfBoundsException
Returns
a variant pointer

◆ getElementBase()

VariantContainerBasePtr getElementBase ( const std::string & key,
const Ice::Current & c = Ice::emptyCurrent ) const
override

getElementBase is the slice-interface implementation for getting an Element and only returns a basepointer, so a manual upcast is usually necessary.

This function exists only for completeness and compatibility. Usually you should use the getElement()-function.

Parameters
indexis the index of the Element in the list
cNot needed, leave blank.
Exceptions
IndexOutOfBoundsException
Returns
a base variant pointer

◆ getSize()

int getSize ( const Ice::Current & c = Ice::emptyCurrent) const
override

◆ getStaticType()

VariantTypeId getStaticType ( const Ice::Current & c = Ice::emptyCurrent)
static

◆ getType()

Ice::Int getType ( const Ice::Current & c = Ice::emptyCurrent) const
override

◆ getTypePrefix()

std::string getTypePrefix ( )
static

◆ getVariant()

VariantPtr getVariant ( const std::string & key) const

getVariant returns a pointer to a Variant object associated with key

Parameters
key
Returns

◆ ice_clone()

Ice::ObjectPtr ice_clone ( ) const
override

◆ operator=()

StringValueMap & operator= ( const StringValueMap & source)

◆ serialize()

void serialize ( const ObjectSerializerBasePtr & serializer,
const ::Ice::Current & = Ice::emptyCurrent ) const
override

◆ setElement()

void setElement ( const std::string & key,
const VariantContainerBasePtr & variantContainer,
const Ice::Current & c = Ice::emptyCurrent )
override

◆ setElements() [1/2]

template<typename ValueType>
void setElements ( const std::map< std::string, ValueType > & map)

setElements adds all pairs from map to the current instance using StringValueMap::setElement().

armarx::StringValueMapPtr container = ...;
std::map<std::string, std::string> intMap;
intMap["p1"] = 1;
intMap["p2"] = 2;
container->setElements<int>(intMap);

◆ setElements() [2/2]

template<typename ValueType>
void setElements ( const std::vector< std::string > & keyVec,
const std::vector< ValueType > & values )

setElements adds elements with keyVec as keys and values as associated values using StringValueMap::setElement().

If the vectors sizes do not match, only the minimal amount of pairs is added.

◆ toContainerStdMap()

template<typename Type>
std::map< std::string, Type > toContainerStdMap ( ) const
inline

toContainerStdMap creates a std::map<std::string, Type> from this container.

Type must be a subclass of VariantContainer. Use this for nested VariantContainers.

◆ toStdMap()

template<class ValueType>
std::map< std::string, ValueType > toStdMap ( )
inline

toStdMap creates a std::map<std::string, ValueType> from this container.

ValueType must be of a type that can be stored in a Variant.

◆ toString()

std::string toString ( const Ice::Current & = Ice::emptyCurrent) const
override

◆ validateElements()

bool validateElements ( const Ice::Current & c = Ice::emptyCurrent)
override

Member Data Documentation

◆ forceSingleTypeMap

bool forceSingleTypeMap = true
protected

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