29#include <IceUtil/Handle.h>
33#include <ArmarXCore/interface/observers/VariantContainers.h>
49 virtual public StringValueMapBase
57 VariantContainerBasePtr
58 cloneContainer(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
59 Ice::ObjectPtr
ice_clone()
const override;
64 const VariantContainerBasePtr& variantContainer,
65 const Ice::Current&
c = Ice::emptyCurrent)
override;
68 const VariantContainerBasePtr& variantContainer,
69 const Ice::Current&
c = Ice::emptyCurrent)
override;
81 template <
typename ValueType>
82 void setElements(
const std::map<std::string, ValueType>& map);
87 template <
typename ValueType>
88 void setElements(
const std::vector<std::string>& keyVec,
89 const std::vector<ValueType>& values);
94 void clear(
const Ice::Current&
c = Ice::emptyCurrent)
override;
97 Ice::Int
getType(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
101 int getSize(
const Ice::Current&
c = Ice::emptyCurrent)
const override;
117 VariantContainerBasePtr
119 const Ice::Current&
c = Ice::emptyCurrent)
const override;
130 template <
typename ContainerType>
139 throw InvalidTypeException();
150 VariantPtr getVariant(
const std::string& key)
const;
156 template <
class ValueType>
157 std::map<std::string, ValueType>
160 std::map<std::string, ValueType> map;
161 StringVariantContainerBaseMap::const_iterator it = elements.begin();
163 for (; it != elements.end(); it++)
165 const std::string& key = it->first;
175 template <
typename Type>
176 std::map<std::string, Type>
179 std::map<std::string, Type> map;
180 StringVariantContainerBaseMap::const_iterator it = elements.begin();
182 for (; it != elements.end(); it++)
184 const std::string& key = it->first;
201 template <
typename Type>
207 for (
typename std::map<std::string, Type>::const_iterator it = map.begin();
211 result->addVariant(it->first, it->second);
227 template <
typename Type>
233 for (
typename std::map<std::string, Type>::const_iterator it = map.begin();
237 result->addElement(it->first, it->second);
243 static std::string getTypePrefix();
246 void serialize(
const ObjectSerializerBasePtr& serializer,
247 const ::Ice::Current& = Ice::emptyCurrent)
const override;
248 void deserialize(
const ObjectSerializerBasePtr& serializer,
249 const ::Ice::Current& = Ice::emptyCurrent)
override;
253 std::string toString(
const Ice::Current& = Ice::emptyCurrent)
const override;
275 template <
typename ValueType>
279 typename std::map<std::string, ValueType>::const_iterator it = map.begin();
281 for (; it != map.end(); it++)
287 template <
typename ValueType>
290 const std::vector<ValueType>& values)
293 int size = std::min(keyVec.size(), values.size());
295 if (keyVec.size() != values.size())
297 ARMARX_WARNING_S <<
"Size of keys vector does not match values vector size:"
298 << keyVec.size() <<
" vs. " << values.size();
301 for (
int i = 0; i < size; i++)
#define ARMARXCORE_IMPORT_EXPORT
The StringValueMap class is a subclass of VariantContainer and is comparable to a std::map<std::strin...
std::map< std::string, Type > toContainerStdMap() const
toContainerStdMap creates a std::map<std::string, Type> from this container.
static StringValueMapPtr FromContainerStdMap(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)
StringValueMap(bool forceSingleTypeMap=true)
void addElement(const std::string &key, const VariantContainerBasePtr &variantContainer, const Ice::Current &c=Ice::emptyCurrent) override
void setElements(const std::map< std::string, ValueType > &map)
setElements adds all pairs from map to the current instance using StringValueMap::setElement().
std::map< std::string, ValueType > toStdMap()
toStdMap creates a std::map<std::string, ValueType> from this container.
void setElement(const std::string &key, const VariantContainerBasePtr &variantContainer, const Ice::Current &c=Ice::emptyCurrent) override
VariantContainerBasePtr cloneContainer(const Ice::Current &c=Ice::emptyCurrent) const override
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 basepo...
bool validateElements(const Ice::Current &c=Ice::emptyCurrent) override
void addVariant(const std::string &key, const Variant &variant)
int getSize(const Ice::Current &c=Ice::emptyCurrent) const override
Ice::Int getType(const Ice::Current &c=Ice::emptyCurrent) const override
IceInternal::Handle< ContainerType > getElement(const std::string &key) const
getElement is the getter-function to retrieve variants from the list.
Ice::ObjectPtr ice_clone() const override
VariantPtr getVariant(const std::string &key) const
getVariant returns a pointer to a Variant object associated with key
void clear(const Ice::Current &c=Ice::emptyCurrent) override
clear calls clear() on the internal StringValueMap::elements container
StringValueMap & operator=(const StringValueMap &source)
static StringValueMapPtr FromStdMap(const std::map< std::string, Type > &map)
FromStdMap creates a StringValueMap from a std::map<std::string, Type>.
static std::string getTypePrefix()
VariantContainer is the base class of all other Variant container classes.
The Variant class is described here: Variants.
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
const VariantTypeId StringValueMap
const VariantContainerType Map
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Variant > VariantPtr
IceInternal::Handle< StringValueMap > StringValueMapPtr