Go to the documentation of this file.
26 #include <boost/regex.hpp>
28 #include <Ice/ObjectAdapter.h>
29 #include <Ice/ValueFactory.h>
30 #include <IceUtil/UUID.h>
38 template class ::IceInternal::Handle<::armarx::SingleVariant>;
39 template class ::IceInternal::Handle<::armarx::ContainerTypeI>;
43 SingleVariant::SingleVariant()
48 typeContainer->typeId = Variant::typeToString(
52 SingleVariant::SingleVariant(
const Variant& variant)
57 typeContainer->typeId = Variant::typeToString(
63 VariantContainerBase(
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))
294 result->typeId = typeStr;
309 while (type->subType)
311 type = type->subType;
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);
The Variant class is described here: Variants.
std::string toString(const Ice::Current &c) const override
void serialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
SingleVariant & operator=(const SingleVariant &source)
static std::string GetInnerType(const std::string &typeStr)
std::string toString(const Ice::Current &c) const override
VariantTypeId getType(const Ice::Current &c=Ice::emptyCurrent) const override
Return the Variant's internal type.
static std::string getTypePrefix()
const VariantTypeId VariantContainer
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &c=Ice::emptyCurrent) override
bool validateElements(const ::Ice::Current &=Ice::emptyCurrent) override
ContainerTypePtr getContainerType(const Ice::Current &=Ice::emptyCurrent) const override
std::string output(const Ice::Current &c=Ice::emptyCurrent) const override
int getSize(const Ice::Current &=Ice::emptyCurrent) const override
VariantContainerBasePtr cloneContainer(const ::Ice::Current &=Ice::emptyCurrent) const override
Ice::ObjectPtr ice_clone() const override
static VariantTypeId getStaticType(const Ice::Current &c=Ice::emptyCurrent)
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &=Ice::emptyCurrent) override
VariantContainerType(std::string containerType)
VariantBasePtr getElementBase(const Ice::Current &=Ice::emptyCurrent) const override
ContainerTypePtr clone(const Ice::Current &=Ice::emptyCurrent) const override
The SingleVariant class is required to store single Variant instances in VariantContainer subclasses.
void deserialize(const ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
static bool compare(const ContainerTypePtr &type1, const ContainerTypePtr &secondType)
const ContainerTypeI operator()(VariantTypeId typeId) const
const VariantTypeId Invalid
static std::string typeToString(VariantTypeId typeId)
Return the name of the registered type typeId.
Vertex source(const detail::edge_base< Directed, Vertex > &e, const PCG &)
int getSize(const ::Ice::Current &=Ice::emptyCurrent) const override
VariantContainer is the base class of all other Variant container classes.
bool validate(const Ice::Current &c=Ice::emptyCurrent) override
Ice::ObjectPtr ice_clone() const override
Ice::Int getType(const Ice::Current &c=Ice::emptyCurrent) const override
bool matches(std::string skillName, std::vector< std::string > &searches)
const char * toString(InteractionFeedbackType type)
VariantDataClassPtr clone(const Ice::Current &c=Ice::emptyCurrent) const override
VariantContainerBasePtr cloneContainer(const Ice::Current &=Ice::emptyCurrent) const override
std::shared_ptr< Object > ObjectPtr
void setVariant(const VariantPtr &variant)
ContainerTypePtr getContainerType(const Ice::Current &c=Ice::emptyCurrent) const override
static ContainerTypePtr FromString(const std::string &typeStr)
bool validateElements(const Ice::Current &=Ice::emptyCurrent) override
void setContainerType(const ContainerTypePtr &containerType, const Ice::Current &c=Ice::emptyCurrent) override
This file offers overloads of toIce() and fromIce() functions for STL container types.
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
ContainerTypePtr getContainerType(const Ice::Current &c=Ice::emptyCurrent) const override
static std::string allTypesToString(const ContainerTypePtr &type)