1 /* Copyright (c) 2015. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "xbt/sysdep.h"
7 #include "PropertyHolder.hpp"
12 PropertyHolder::PropertyHolder() = default;
14 PropertyHolder::~PropertyHolder() {
15 xbt_dict_free(&properties_);
18 /** @brief Return the property associated to the provided key (or nullptr if not existing) */
19 const char *PropertyHolder::getProperty(const char*key) {
20 if (properties_ == nullptr)
22 return static_cast<const char*>(xbt_dict_get_or_null(properties_,key));
25 /** @brief Change the value of a given key in the property set */
26 void PropertyHolder::setProperty(const char*key, const char*value) {
28 properties_ = xbt_dict_new_homogeneous(xbt_free_f);
29 xbt_dict_set(properties_, key, xbt_strdup(value), nullptr);
32 /** @brief Return the whole set of properties. Don't mess with it, dude! */
33 xbt_dict_t PropertyHolder::getProperties() {
35 properties_ = xbt_dict_new_homogeneous(xbt_free_f);
39 } /* namespace surf */
40 } /* namespace simgrid */