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 "PropertyHolder.hpp"
11 PropertyHolder::PropertyHolder() = default;
13 PropertyHolder::~PropertyHolder() {
17 /** @brief Return the property associated to the provided key (or nullptr if not existing) */
18 const char *PropertyHolder::getProperty(const char*key) {
19 if (properties_ == nullptr)
22 return properties_->at(key).c_str();
23 } catch (std::out_of_range& unfound) {
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_ = new std::unordered_map<std::string, std::string>;
32 (*properties_)[key] = value;
35 /** @brief Return the whole set of properties. Don't mess with it, dude! */
36 std::unordered_map<std::string, std::string>* PropertyHolder::getProperties()
39 properties_ = new std::unordered_map<std::string, std::string>;
43 } /* namespace surf */
44 } /* namespace simgrid */