28#include <SimoxUtility/algorithm/string/string_conversion.h>
50 for (
const auto& [key, dataPtr] : this->
aron->elements)
52 childrenNavigators[key] = Variant::FromAronDTO(dataPtr, path.withElement(key));
58 for (
const auto& [key, dataPtr] : m)
68 for (
const auto& [key,
nav] : childrenNavigators)
93 return *
this == *other;
106 this->childrenNavigators = other.childrenNavigators;
119 ret->addElement(key, val->cloneAsVariant());
123 ret->addElement(key,
nullptr);
137 return std::make_shared<Dict>(
aron);
143 return navigator ? navigator->toAronDictDTO() :
nullptr;
153 std::vector<std::string>
156 std::vector<std::string> ret;
157 for (
const auto& [key, _] : childrenNavigators)
167 return simox::alg::to_string(
getAllKeys(),
", ");
179 "The key '" + key +
"' already exists in a aron dict.");
193 "The key '" + key +
"' already exists in a aron dict.");
207 for (
const auto& [k, v] : d->getElements())
222 for (
const auto& [k, v] : d->getElements())
231 return childrenNavigators.count(key) > 0;
237 auto it = childrenNavigators.find(key);
238 if (it == childrenNavigators.end())
242 "Could not find key '" + key +
243 "'. But I found the following keys: [" +
244 simox::alg::join(this->
getAllKeys(),
", ") +
"]",
250 std::map<std::string, VariantPtr>
253 return childrenNavigators;
263 const auto& p =
data->getPath();
264 if (not p.hasDirectPrefix(this->getPath()))
267 <<
"An element added to a dict does not have a correct path set. This "
268 "may cause errors. Please use setElemetCopy() instead.";
272 this->childrenNavigators[key] =
data;
275 this->
aron->elements[key] =
data->toAronDTO();
279 this->
aron->elements[key] =
nullptr;
292 copy =
data->cloneAsVariant(newPath);
300 childrenNavigators.erase(key);
301 aron->elements.erase(key);
307 childrenNavigators.clear();
308 aron->elements.clear();
327 return "armarx::aron::data::Dict";
355 for (
const auto& [key, childTypeNav] : objectTypeNav->getMemberTypes())
370 if (not childNav->fullfillsType(childTypeNav))
379 if (childTypeNav->getMaybe() == type::Maybe::NONE)
393 for (
const auto& [key, childNav] : childrenNavigators)
396 auto childTypeNav = dictTypeNav->getAcceptedType();
399 if (childTypeNav && childTypeNav->getMaybe() == type::Maybe::NONE)
406 if (!childNav->fullfillsType(childTypeNav))
418 std::vector<VariantPtr>
421 std::vector<VariantPtr> ret(childrenNavigators.size());
422 for (
const auto& [key,
nav] : childrenNavigators)
432 return childrenNavigators.size();
438 if (!
path.hasElement())
442 __PRETTY_FUNCTION__,
"Could not navigate without a valid path",
path);
444 std::string el =
path.getFirstElement();
449 __PRETTY_FUNCTION__,
"Could not find an element of a path.", el,
path);
452 if (
path.size() == 1)
454 return childrenNavigators.at(el);
458 Path next =
path.withDetachedFirstElement();
459 if (!childrenNavigators.at(el))
463 "Could not navigate into a NULL member. Seems like the "
464 "member is optional and not set.",
467 return childrenNavigators.at(el)->navigateAbsolute(next);
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
Path withElement(const std::string &, bool escape=false) const
size_t childrenSize() const override
get the children size of a data variant
void addElement(const std::string &key, const VariantPtr &=nullptr)
void removeElement(const std::string &key)
VariantPtr at(const std::string &) const
std::string getShortName() const override
get a short str representation of this variant
void setElement(const std::string &, const VariantPtr &=nullptr)
data::dto::DictPtr toAronDictDTO() const
VariantPtr operator[](const std::string &) const
type::VariantPtr recalculateType() const override
recalculate the type of a data variant. Please not tha the mapping ist NOT bijective,...
std::string getAllKeysAsString() const
std::string getFullName() const override
get the full str representation of this variant
void mergeAndReplace(const DictPtr &d)
void mergeAndReplaceCopy(const DictPtr &d)
static data::dto::DictPtr ToAronDictDTO(const PointerType &navigator)
Dict & operator=(const Dict &)
bool operator==(const Dict &) const override
Dict(const Path &path=Path())
void addElementCopy(const std::string &key, const VariantPtr &=nullptr)
std::map< std::string, VariantPtr > getElements() const
std::vector< std::string > getAllKeys() const
void setElementCopy(const std::string &, const VariantPtr &=nullptr)
VariantPtr navigateAbsolute(const Path &path) const override
naviate absolute
static PointerType FromAronDictDTO(const data::dto::DictPtr &aron)
bool fullfillsType(const type::VariantPtr &) const override
checks, if the current data variant fullfills the given type
std::vector< VariantPtr > getChildren() const override
get the children of a data variant
bool hasElement(const std::string &) const
VariantPtr getElement(const std::string &) const
Path getPath() const
get the path
std::optional< float > getImportance() const override
AronDataType::PointerType aron
virtual PointerType clone() const
A base class for aron exceptions.
The NotImplementedYetException class.
The ValueNotValidException class.
static std::shared_ptr< Object > DynamicCastAndCheck(const VariantPtr &n)
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
::IceInternal::Handle< Dict > DictPtr
A convenience header to include all aron files (full include, not forward declared)
std::shared_ptr< Dict > DictPtr
std::shared_ptr< Variant > VariantPtr
A convenience header to include all aron files (full include, not forward declared)
std::shared_ptr< Variant > VariantPtr