1 /* Copyright (c) 2015-2018. 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 "PropertyHolder.hpp"
11 PropertyHolder::~PropertyHolder() {
15 /** @brief Return the property associated to the provided key (or nullptr if not existing) */
16 const char* PropertyHolder::get_property(std::string key)
18 if (properties_ == nullptr)
20 auto prop = properties_->find(key);
21 return prop == properties_->end() ? nullptr : prop->second.c_str();
24 /** @brief Change the value of a given key in the property set */
25 void PropertyHolder::set_property(std::string key, std::string value)
28 properties_ = new std::unordered_map<std::string, std::string>;
29 (*properties_)[key] = value;
32 /** @brief Return the whole set of properties. Don't mess with it, dude! */
33 std::unordered_map<std::string, std::string>* PropertyHolder::get_properties()
36 properties_ = new std::unordered_map<std::string, std::string>;
40 } /* namespace surf */
41 } /* namespace simgrid */