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(xbt_dict_t props)
17 PropertyHolder::~PropertyHolder() {
18 xbt_dict_free(&properties_);
21 /** @brief Return the property associated to the provided key (or NULL if not existing) */
22 const char *PropertyHolder::getProperty(const char*key) {
23 if (properties_ == NULL)
25 return (const char*) xbt_dict_get_or_null(properties_,key);
28 /** @brief Change the value of a given key in the property set */
29 void PropertyHolder::setProperty(const char*key, const char*value) {
31 properties_ = xbt_dict_new();
32 xbt_dict_set(properties_, key, xbt_strdup(value), &xbt_free_f);
35 /** @brief Return the whole set of properties. Don't mess with it, dude! */
36 xbt_dict_t PropertyHolder::getProperties() {
38 properties_ = xbt_dict_new();
42 } /* namespace surf */
43 } /* namespace simgrid */