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
 
StringValueMapoperator= (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.

Definition at line 47 of file StringValueMap.h.

Constructor & Destructor Documentation

◆ StringValueMap() [1/4]

StringValueMap ( bool forceSingleTypeMap = true)

Definition at line 38 of file StringValueMap.cpp.

+ Here is the caller graph for this function:

◆ StringValueMap() [2/4]

StringValueMap ( const StringValueMap & source)

Definition at line 54 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ StringValueMap() [3/4]

StringValueMap ( const ContainerType & subType)
explicit

Definition at line 49 of file StringValueMap.cpp.

◆ StringValueMap() [4/4]

StringValueMap ( VariantTypeId subType)
explicit

Definition at line 43 of file StringValueMap.cpp.

Member Function Documentation

◆ addElement()

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

Definition at line 91 of file StringValueMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addVariant()

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

Definition at line 104 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ clear()

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

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

Parameters
c

Definition at line 132 of file StringValueMap.cpp.

◆ cloneContainer()

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

Definition at line 77 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ deserialize()

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

Definition at line 226 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ 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>.
VariantContainer is the base class of all other Variant container classes.
IceInternal::Handle< StringValueMap > StringValueMapPtr

Definition at line 229 of file StringValueMap.h.

+ Here is the call graph for this function:

◆ 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 at line 203 of file StringValueMap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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

Definition at line 132 of file StringValueMap.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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

Definition at line 164 of file StringValueMap.cpp.

+ Here is the caller graph for this function:

◆ getSize()

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

Definition at line 144 of file StringValueMap.cpp.

◆ getStaticType()

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

Definition at line 138 of file StringValueMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getType()

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

Definition at line 249 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ getTypePrefix()

std::string getTypePrefix ( )
static

Definition at line 190 of file StringValueMap.cpp.

+ Here is the caller graph for this function:

◆ getVariant()

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

getVariant returns a pointer to a Variant object associated with key

Parameters
key
Returns

Definition at line 177 of file StringValueMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ice_clone()

Ice::ObjectPtr ice_clone ( ) const
override

Definition at line 85 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ operator=()

StringValueMap & operator= ( const StringValueMap & source)

Definition at line 61 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ serialize()

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

Definition at line 209 of file StringValueMap.cpp.

◆ setElement()

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

Definition at line 110 of file StringValueMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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);

Definition at line 277 of file StringValueMap.h.

+ Here is the call graph for this function:

◆ 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.

Definition at line 289 of file StringValueMap.h.

+ Here is the call graph for this function:

◆ 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.

Definition at line 177 of file StringValueMap.h.

+ Here is the call graph for this function:

◆ 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.

Definition at line 158 of file StringValueMap.h.

+ Here is the call graph for this function:

◆ toString()

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

Definition at line 196 of file StringValueMap.cpp.

◆ validateElements()

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

Definition at line 150 of file StringValueMap.cpp.

Member Data Documentation

◆ forceSingleTypeMap

bool forceSingleTypeMap = true
protected

Definition at line 256 of file StringValueMap.h.


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