32#include <Ice/ObjectAdapter.h>
33#include <Ice/ValueFactory.h>
34#include <IceUtil/UUID.h>
55 IceUtil::Shared(source), VariantContainerBase(source), StringValueMapBase(source)
64 this->typeContainer = ContainerTypePtr::dynamicCast(source.typeContainer->clone());
66 auto it = source.elements.begin();
68 for (; it != source.elements.end(); it++)
70 elements[it->first] = it->second->cloneContainer();
76 VariantContainerBasePtr
92 const VariantContainerBasePtr& variantContainer,
93 const Ice::Current&
c)
95 if (elements.find(key) != elements.end())
97 throw KeyAlreadyExistsException();
100 setElement(key, variantContainer->cloneContainer());
111 const VariantContainerBasePtr& variantContainer,
112 const Ice::Current&
c)
120 getContainerType()->subType->typeId, variantContainer->getContainerType()->typeId);
125 getContainerType()->subType = variantContainer->getContainerType()->clone();
128 elements[key] = (variantContainer->cloneContainer());
146 return int(elements.size());
152 auto it = elements.begin();
155 for (; it != elements.end(); it++)
157 result = result && it->second->validateElements();
163 VariantContainerBasePtr
166 auto it = elements.find(key);
168 if (it == elements.end())
170 throw IndexOutOfBoundsException();
183 throw InvalidTypeException();
192 return "::armarx::StringValueMapBase";
198 std::stringstream ss;
200 for (
const auto& element : elements)
202 ss << element.first <<
": " << element.second->toString() <<
"\n";
214 StringVariantContainerBaseMap::const_iterator it = elements.begin();
216 for (; it != elements.end(); it++)
218 newObj->setIceObject(it->first, it->second);
222 obj->setElement(
"map", newObj);
230 Ice::StringSeq keys = map->getElementNames();
232 for (Ice::StringSeq::iterator it = keys.begin(); it != keys.end(); it++)
234 VariantContainerBasePtr
c =
235 VariantContainerBasePtr::dynamicCast(map->getIceObject(*it));
243 throw LocalException(
"Could not cast to VariantContainerBasePtr");
The SingleVariant class is required to store single Variant instances in VariantContainer subclasses.
The StringValueMap class is a subclass of VariantContainer and is comparable to a std::map<std::strin...
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
std::string toString(const Ice::Current &=Ice::emptyCurrent) const override
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)
void deserialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
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
void serialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) 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 std::string getTypePrefix()
static bool compare(const ContainerTypePtr &type1, const ContainerTypePtr &secondType)
VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
ContainerTypePtr getContainerType(const Ice::Current &c=Ice::emptyCurrent) const override
The Variant class is described here: Variants.
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
const VariantTypeId Invalid
const VariantContainerType Map
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Variant > VariantPtr
IceInternal::Handle< AbstractObjectSerializer > AbstractObjectSerializerPtr