X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/aca4da8cb1bb25e12e60da1d20be4d0882e5ee8e..d1a82dae27086cc6f9ea4e0163d2941c74135c94:/src/surf/PropertyHolder.cpp diff --git a/src/surf/PropertyHolder.cpp b/src/surf/PropertyHolder.cpp index 2eda708ce0..03210a7ce2 100644 --- a/src/surf/PropertyHolder.cpp +++ b/src/surf/PropertyHolder.cpp @@ -3,7 +3,6 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "xbt/sysdep.h" #include "PropertyHolder.hpp" namespace simgrid { @@ -12,27 +11,32 @@ namespace surf { PropertyHolder::PropertyHolder() = default; PropertyHolder::~PropertyHolder() { - xbt_dict_free(&properties_); + delete properties_; } /** @brief Return the property associated to the provided key (or nullptr if not existing) */ const char *PropertyHolder::getProperty(const char*key) { if (properties_ == nullptr) return nullptr; - return static_cast(xbt_dict_get_or_null(properties_,key)); + try { + return properties_->at(key).c_str(); + } catch (std::out_of_range& unfound) { + return nullptr; + } } /** @brief Change the value of a given key in the property set */ void PropertyHolder::setProperty(const char*key, const char*value) { if (not properties_) - properties_ = xbt_dict_new_homogeneous(xbt_free_f); - xbt_dict_set(properties_, key, xbt_strdup(value), nullptr); + properties_ = new std::unordered_map; + (*properties_)[key] = value; } /** @brief Return the whole set of properties. Don't mess with it, dude! */ -xbt_dict_t PropertyHolder::getProperties() { +std::unordered_map* PropertyHolder::getProperties() +{ if (not properties_) - properties_ = xbt_dict_new_homogeneous(xbt_free_f); + properties_ = new std::unordered_map; return properties_; }