47 IceUtil::Shared(other), EntityAttributeBase()
50 this->name = other.name;
54 this->values.reserve(
size);
56 for (
size_t i = 0; i <
size; ++i)
58 AttributeElement elem;
59 const AttributeElement& origElem = other.values.at(i);
61 ProbabilityMeasureBasePtr uncertainty = origElem.uncertainty;
65 elem.uncertainty = ProbabilityMeasureBasePtr::dynamicCast(uncertainty->clone());
68 elem.value = var->clone();
69 values.push_back(elem);
106 const ProbabilityMeasureBasePtr& uncertainty,
107 const ::Ice::Current&)
119 AttributeElement elem;
120 elem.value = armarx::VariantPtr::dynamicCast(val)->clone();
124 elem.uncertainty = ProbabilityMeasureBasePtr::dynamicCast(uncertainty->ice_clone());
142 const ProbabilityMeasureBasePtr& uncertainty,
143 const ::Ice::Current&)
145 AttributeElement elem;
146 elem.value = armarx::VariantPtr::dynamicCast(val)->clone();
150 elem.uncertainty = ProbabilityMeasureBasePtr::dynamicCast(uncertainty->ice_clone());
155 values.push_back(elem);
165 throw armarx::NotImplementedYetException();
168 const std::string valStr = val->getString();
172 for (AttributeElementList::const_iterator it = values.begin(); it != values.end(); ++it)
175 it->value->getString() == valStr)
190 ProbabilityMeasureBasePtr
203 ProbabilityMeasureBasePtr
207 return values.size() > (size_t)
index ? values.at(
index).uncertainty
208 : ProbabilityMeasureBasePtr();
216 if (values.size() > (
size_t)
index)
218 values.erase(values.begin() +
index);
246 return (values.size() > (
size_t)
index) ? values.at(
index) : AttributeElement();
253 return values.size();
266 return this->
clone();
280 EntityAttribute::output(std::ostream& stream)
const
284 for (AttributeElementList::const_iterator it = values.begin(); it != values.end(); ++it)
286 stream <<
"value: " << armarx::VariantPtr::dynamicCast(it->value);
290 stream <<
", uncertainty: "
291 << ProbabilityMeasureBasePtr::dynamicCast(it->uncertainty)->output();
300 const ::Ice::Current&
c)
const
303 armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
308 for (AttributeElementList::const_iterator it = values.begin(); it != values.end(); ++it)
311 armarx::AbstractObjectSerializerPtr::dynamicCast(serializer)->createElement();
312 objValue->setVariant(
"value", armarx::VariantPtr::dynamicCast(it->value));
317 new armarx::Variant(armarx::VariantDataClassPtr::dynamicCast(it->uncertainty));
318 objValue->setVariant(
"uncertainty", uncertaintyVar);
321 obj->append(objValue);
327 const ::Ice::Current&
c)
330 armarx::AbstractObjectSerializerPtr::dynamicCast(serializer);
336 for (
unsigned int i = 0; i < obj->size(); ++i)
339 AttributeElement elem;
343 elem.value = objValue->getVariant(
"value");
345 catch (std::exception& e)
348 <<
"Could not get variant for: " << objValue->toString().substr(0, 2000) <<
": "
349 << e.what() <<
"\n Backtrace: \n"
355 <<
"Could not get variant for: " << objValue->toString().substr(0, 2000)
356 <<
"\n Backtrace: \n"
360 if (objValue->hasElement(
"uncertainty"))
363 elem.uncertainty = uncertaintyVar->getClass<ProbabilityMeasureBase>();
366 values.push_back(elem);
static std::string CreateBackTrace(int linesToSkip=1)
The Variant class is described here: Variants.
void setValueWithUncertainty(const ::armarx::VariantBasePtr &val, const ::memoryx::ProbabilityMeasureBasePtr &uncertainty, const ::Ice::Current &=Ice::emptyCurrent) override
Sets (single) value of the attribute along with the corresponding uncertainty.
void removeValueAt(::Ice::Int index, const ::Ice::Current &=Ice::emptyCurrent) override
Removes the value at a given index from the list of values stored in the attribute.
void clear(const ::Ice::Current &=Ice::emptyCurrent) override
Clears all values.
bool hasValue(const ::armarx::VariantBasePtr &val, const ::Ice::Current &=Ice::emptyCurrent) const override
Checks whether the value val is currently stored in the attribute.
void setValue(const ::armarx::VariantBasePtr &val, const ::Ice::Current &=Ice::emptyCurrent) override
Sets (single) value of the attribute.
std::recursive_mutex valuesMutex
~EntityAttribute() override
::memoryx::AttributeElement getElement(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieves the attribute element (=value+uncertainty).
void deserialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) override
void addValue(const ::armarx::VariantBasePtr &val, const ::Ice::Current &=Ice::emptyCurrent) override
Adds value to the end of attribute values list.
::armarx::VariantBasePtr getValue(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieves the value of the attribute.
Ice::ObjectPtr ice_clone() const override
::memoryx::ProbabilityMeasureBasePtr getUncertaintyAt(::Ice::Int index, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve the uncertainty of the value at a given index from the list of values stored in the attribut...
void setElement(const ::memoryx::AttributeElement &elem, const ::Ice::Current &=Ice::emptyCurrent) override
Sets (single) attribute element (=value+uncertainty) to the attribute.
EntityAttributePtr clone(const Ice::Current &c=Ice::emptyCurrent) const
::memoryx::AttributeElement getElementAt(::Ice::Int index, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieves an attribute element (=value+uncertainty) with a given index.
void addValueWithUncertainty(const ::armarx::VariantBasePtr &val, const ::memoryx::ProbabilityMeasureBasePtr &uncertainty, const ::Ice::Current &=Ice::emptyCurrent) override
Adds value along with the corresponding uncertainty to the end of attribute values list.
::memoryx::ProbabilityMeasureBasePtr getUncertainty(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieves the uncertainty of the attribute value.
void serialize(const armarx::ObjectSerializerBasePtr &serializer, const ::Ice::Current &=Ice::emptyCurrent) const override
::armarx::VariantBasePtr getValueAt(::Ice::Int index, const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve the value at a given index from the list of values stored in the attribute.
::Ice::Int size(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve number of values stored with the attribute.
void addElement(const ::memoryx::AttributeElement &elem, const ::Ice::Current &=Ice::emptyCurrent) override
Adds attribute element (=value+uncertainty) to the attribute.
EntityAttribute(const std::string &name)
Constructs a new EntityAttribute.
::std::string getName(const ::Ice::Current &=Ice::emptyCurrent) const override
Retrieve name of the attribute.
#define ARMARX_IMPORTANT_S
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
const VariantTypeId String
IceInternal::Handle< Variant > VariantPtr
IceInternal::Handle< AbstractObjectSerializer > AbstractObjectSerializerPtr
::IceInternal::Handle<::armarx::VariantBase > VariantBasePtr
IceInternal::Handle< EntityAttribute > EntityAttributePtr
Typedef of EntityAttributePtr as IceInternal::Handle<EntityAttribute> for convenience.