26#include <boost/regex.hpp>
28#include <Ice/ObjectAdapter.h>
29#include <Ice/ValueFactory.h>
30#include <IceUtil/UUID.h>
38template class ::IceInternal::Handle<::armarx::SingleVariant>;
39template class ::IceInternal::Handle<::armarx::ContainerTypeI>;
63 VariantContainerBase(source),
65 SingleVariantBase(source)
75 element = VariantPtr::dynamicCast(source.element)->
clone();
77 typeContainer = source.typeContainer->clone();
81 VariantContainerBasePtr
108 element = variant->clone();
123 return typeContainer;
129 this->typeContainer = containerType->clone();
141 return element->validate();
148 obj->setVariant(
"variant",
get());
161 return "::armarx::SingleVariantBase";
167 VariantPtr variant = VariantPtr::dynamicCast(element);
168 std::string variantString = variant->getOutputValueOnly();
169 return variantString;
181 newType->typeId = this->typeId;
185 newType->subType = subType->clone();
193 this->containerType = containerType;
195 thisType->typeId = containerType;
202 ContainerTypeI result = *(ContainerTypeIPtr::dynamicCast(thisType->clone()));
213 ContainerTypeI result = *(ContainerTypeIPtr::dynamicCast(thisType->clone()));
214 result.subType = subType.clone();
220 const ContainerTypePtr& secondType)
222 ContainerTypePtr type1 = firstType;
223 ContainerTypePtr type2 = secondType;
225 if (!type1 && !type2)
230 while (type1 || type2)
232 if ((type1 && !type2) || (!type1 && type2))
237 if (type1->typeId != type2->typeId)
242 type1 = type1->subType;
243 type2 = type2->subType;
253 ContainerTypePtr curType = type;
254 std::vector<std::string> typeStrings;
259 typeStrings.push_back(curType->typeId);
260 curType = curType->subType;
263 std::vector<std::string>::reverse_iterator rit = typeStrings.rbegin();
265 for (; rit != typeStrings.rend(); rit++)
273 result = *rit +
"(" + result +
")";
283 boost::regex exp(
"([a-zA-Z:0-9_\\-]+?)\\(([a-zA-Z:0-9_\\-()]+)\\)");
284 boost::match_results<std::string::const_iterator> matches;
287 if (boost::regex_search(typeStr, matches, exp))
290 result->typeId = matches[1];
294 result->typeId = typeStr;
309 while (type->subType)
311 type = type->subType;
324 Shared(source), VariantContainerBase(source)
326 typeContainer = source.typeContainer->clone();
329 VariantContainerBasePtr
338 return this->
clone();
344 return typeContainer;
350 typeContainer = containerType;
374 return typeContainer;
380 typeContainer = containerType;
386 return cloneContainer(
c);
404 return validateElements(
c);
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &=Ice::emptyCurrent) override
VariantContainerBasePtr cloneContainer(const Ice::Current &=Ice::emptyCurrent) const override
int getSize(const Ice::Current &=Ice::emptyCurrent) const override
Ice::ObjectPtr ice_clone() const override
std::string toString(const Ice::Current &c) const override
ContainerTypePtr getContainerType(const Ice::Current &=Ice::emptyCurrent) const override
bool validateElements(const Ice::Current &=Ice::emptyCurrent) override
ContainerTypePtr clone(const Ice::Current &=Ice::emptyCurrent) const override
The SingleVariant class is required to store single Variant instances in VariantContainer subclasses.
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &c=Ice::emptyCurrent) override
VariantContainerBasePtr cloneContainer(const ::Ice::Current &=Ice::emptyCurrent) const override
VariantBasePtr getElementBase(const Ice::Current &=Ice::emptyCurrent) const override
static VariantTypeId getStaticType(const Ice::Current &c=Ice::emptyCurrent)
SingleVariant & operator=(const SingleVariant &source)
int getSize(const ::Ice::Current &=Ice::emptyCurrent) const override
void setVariant(const VariantPtr &variant)
void deserialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
Ice::ObjectPtr ice_clone() const override
void serialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
bool validateElements(const ::Ice::Current &=Ice::emptyCurrent) override
ContainerTypePtr getContainerType(const Ice::Current &c=Ice::emptyCurrent) const override
std::string toString(const Ice::Current &c) const override
static std::string getTypePrefix()
VariantContainerType(std::string containerType)
static std::string allTypesToString(const ContainerTypePtr &type)
const ContainerTypeI operator()(VariantTypeId typeId) const
static bool compare(const ContainerTypePtr &type1, const ContainerTypePtr &secondType)
static ContainerTypePtr FromString(const std::string &typeStr)
static std::string GetInnerType(const std::string &typeStr)
VariantContainer is the base class of all other Variant container classes.
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &c=Ice::emptyCurrent) override
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
bool validate(const Ice::Current &c=Ice::emptyCurrent) override
Ice::Int getType(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.
VariantTypeId getType(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's internal type.
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 VariantContainer
const VariantTypeId Invalid
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< Variant > VariantPtr
IceInternal::Handle< AbstractObjectSerializer > AbstractObjectSerializerPtr
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr