Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
stringify s4u::Host
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 13 Jul 2018 19:54:53 +0000 (21:54 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 13 Jul 2018 19:54:53 +0000 (21:54 +0200)
include/simgrid/s4u/Host.hpp
src/s4u/s4u_Host.cpp

index cbb9485..f8933b2 100644 (file)
@@ -39,7 +39,7 @@ class XBT_PUBLIC Host : public simgrid::xbt::Extendable<Host> {
   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<std::string, std::string>* get_properties();
   XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_properties()") std::map<std::string, std::string>* getProperties()
index 54ecde3..85840a4 100644 (file)
@@ -28,9 +28,9 @@ simgrid::xbt::signal<void(Host&)> Host::on_destruction;
 simgrid::xbt::signal<void(Host&)> Host::on_state_change;
 simgrid::xbt::signal<void(Host&)> 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<std::string, std::string>* 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);
 }