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;
118 ret->addElement(key, val->cloneAsVariant());
122 ret->addElement(key,
nullptr);
136 return std::make_shared<Dict>(
aron);
142 return navigator ? navigator->toAronDictDTO() :
nullptr;
152 std::vector<std::string>
155 std::vector<std::string> ret;
156 for (
const auto& [key, _] : childrenNavigators)
166 return simox::alg::to_string(
getAllKeys(),
", ");
178 "The key '" + key +
"' already exists in a aron dict.");
192 "The key '" + key +
"' already exists in a aron dict.");
206 for (
const auto& [k, v] : d->getElements())
221 for (
const auto& [k, v] : d->getElements())
230 return childrenNavigators.count(key) > 0;
236 auto it = childrenNavigators.find(key);
237 if (it == childrenNavigators.end())
241 "Could not find key '" + key +
242 "'. But I found the following keys: [" +
243 simox::alg::join(this->
getAllKeys(),
", ") +
"]",
249 std::map<std::string, VariantPtr>
252 return childrenNavigators;
262 const auto& p =
data->getPath();
263 if (not p.hasDirectPrefix(this->getPath()))
266 <<
"An element added to a dict does not have a correct path set. This "
267 "may cause errors. Please use setElemetCopy() instead.";
271 this->childrenNavigators[key] =
data;
274 this->
aron->elements[key] =
data->toAronDTO();
278 this->
aron->elements[key] =
nullptr;
291 copy =
data->cloneAsVariant(newPath);
299 childrenNavigators.erase(key);
300 aron->elements.erase(key);
306 childrenNavigators.clear();
307 aron->elements.clear();
326 return "armarx::aron::data::Dict";
354 for (
const auto& [key, childTypeNav] : objectTypeNav->getMemberTypes())
369 if (not childNav->fullfillsType(childTypeNav))
378 if (childTypeNav->getMaybe() == type::Maybe::NONE)
392 for (
const auto& [key, childNav] : childrenNavigators)
395 auto childTypeNav = dictTypeNav->getAcceptedType();
398 if (childTypeNav && childTypeNav->getMaybe() == type::Maybe::NONE)
405 if (!childNav->fullfillsType(childTypeNav))
417 std::vector<VariantPtr>
420 std::vector<VariantPtr> ret(childrenNavigators.size());
421 for (
const auto& [key,
nav] : childrenNavigators)
431 return childrenNavigators.size();
437 if (!
path.hasElement())
441 __PRETTY_FUNCTION__,
"Could not navigate without a valid path",
path);
443 std::string el =
path.getFirstElement();
448 __PRETTY_FUNCTION__,
"Could not find an element of a path.", el,
path);
451 if (
path.size() == 1)
453 return childrenNavigators.at(el);
457 Path next =
path.withDetachedFirstElement();
458 if (!childrenNavigators.at(el))
462 "Could not navigate into a NULL member. Seems like the "
463 "member is optional and not set.",
466 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
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