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 More...
 
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. More...
 
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. More...
 
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 More...
 
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(). More...
 
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(). More...
 
 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. More...
 
template<class ValueType >
std::map< std::string, ValueType > toStdMap ()
 toStdMap creates a std::map<std::string, ValueType> from this container. More...
 
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>. More...
 
template<typename Type >
static StringValueMapPtr FromStdMap (const std::map< std::string, Type > &map)
 FromStdMap creates a StringValueMap from a std::map<std::string, Type>. More...
 
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 49 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 55 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ StringValueMap() [3/4]

StringValueMap ( const ContainerType &  subType)
explicit

Definition at line 50 of file StringValueMap.cpp.

◆ StringValueMap() [4/4]

StringValueMap ( VariantTypeId  subType)
explicit

Definition at line 44 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 92 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 102 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 123 of file StringValueMap.cpp.

◆ cloneContainer()

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

Definition at line 80 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 215 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ FromContainerStdMap()

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();
armarx::StringValueMapPtr container = armarx::StringValueMap::FromContainerStdMap<int>(intMap);

Definition at line 219 of file StringValueMap.h.

◆ FromStdMap()

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;
armarx::StringValueMapPtr container = armarx::StringValueMap::FromStdMap<int>(intMap);

Definition at line 196 of file StringValueMap.h.

+ Here is the caller graph for this function:

◆ getElement()

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 125 of file StringValueMap.h.

◆ 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 155 of file StringValueMap.cpp.

◆ getSize()

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

Definition at line 137 of file StringValueMap.cpp.

◆ getStaticType()

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

Definition at line 130 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 236 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ getTypePrefix()

std::string getTypePrefix ( )
static

Definition at line 179 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 167 of file StringValueMap.cpp.

◆ ice_clone()

Ice::ObjectPtr ice_clone ( ) const
override

Definition at line 87 of file StringValueMap.cpp.

+ Here is the call graph for this function:

◆ operator=()

StringValueMap & operator= ( const StringValueMap source)

Definition at line 65 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 199 of file StringValueMap.cpp.

◆ setElement()

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

Definition at line 107 of file StringValueMap.cpp.

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

◆ setElements() [1/2]

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 262 of file StringValueMap.h.

+ Here is the call graph for this function:

◆ setElements() [2/2]

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 272 of file StringValueMap.h.

+ Here is the call graph for this function:

◆ toContainerStdMap()

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 171 of file StringValueMap.h.

◆ toStdMap()

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 153 of file StringValueMap.h.

◆ toString()

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

Definition at line 185 of file StringValueMap.cpp.

◆ validateElements()

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

Definition at line 142 of file StringValueMap.cpp.

Member Data Documentation

◆ forceSingleTypeMap

bool forceSingleTypeMap = true
protected

Definition at line 241 of file StringValueMap.h.


The documentation for this class was generated from the following files:
armarx::VariantType::VariantContainer
const VariantTypeId VariantContainer
Definition: VariantContainer.h:41
IceInternal::Handle
Definition: forward_declarations.h:8