From 3f20736620afa2ecf5ef7bbda4e3a55bcd9a1cd3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Fri, 13 Jul 2018 21:54:53 +0200 Subject: [PATCH] stringify s4u::Host --- include/simgrid/s4u/Host.hpp | 8 ++------ src/s4u/s4u_Host.cpp | 14 +++----------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index cbb94851d1..f8933b275f 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -39,7 +39,7 @@ class XBT_PUBLIC Host : public simgrid::xbt::Extendable { friend simgrid::vm::VirtualMachineImpl; // creates the the pimpl_cpu public: - explicit Host(const char* name); + explicit Host(std::string name); /** Host destruction logic */ protected: @@ -64,13 +64,9 @@ public: Host(Host const&) = delete; Host& operator=(Host const&) = delete; - /** Retrieves an host from its name, or return nullptr */ - static Host* by_name_or_null(const char* name); /** Retrieves an host from its name, or return nullptr */ static Host* by_name_or_null(std::string name); /** Retrieves an host from its name, or die */ - static s4u::Host* by_name(const char* name); - /** Retrieves an host from its name, or die */ static s4u::Host* by_name(std::string name); /** Retrieves the host on which the current actor is running */ static s4u::Host* current(); @@ -96,7 +92,7 @@ public: /** Returns if that host is currently down and offline */ bool is_off() const { return not is_on(); } - const char* get_property(const char* key) const; + const char* get_property(std::string key) const; void set_property(std::string key, std::string value); std::unordered_map* get_properties(); XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_properties()") std::map* getProperties() diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 54ecde3254..85840a4194 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -28,9 +28,9 @@ simgrid::xbt::signal Host::on_destruction; simgrid::xbt::signal Host::on_state_change; simgrid::xbt::signal Host::on_speed_change; -Host::Host(const char* name) : name_(name) +Host::Host(std::string name) : name_(name) { - xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name); + xbt_assert(Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name.c_str()); Engine::get_instance()->host_register(std::string(name_), this); new simgrid::surf::HostImpl(this); } @@ -68,14 +68,6 @@ Host* Host::by_name(std::string name) { return Engine::get_instance()->host_by_name(name); } -Host* Host::by_name(const char* name) -{ - return Engine::get_instance()->host_by_name(std::string(name)); -} -Host* Host::by_name_or_null(const char* name) -{ - return Engine::get_instance()->host_by_name_or_null(std::string(name)); -} Host* Host::by_name_or_null(std::string name) { return Engine::get_instance()->host_by_name_or_null(name); @@ -194,7 +186,7 @@ std::unordered_map* Host::get_properties() } /** Retrieve the property value (or nullptr if not set) */ -const char* Host::get_property(const char* key) const +const char* Host::get_property(std::string key) const { return this->pimpl_->get_property(key); } -- 2.20.1