Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Refactor Host and HostImpl
[simgrid.git] / include / simgrid / s4u / Host.hpp
index 7ebb16d..b23efc3 100644 (file)
@@ -40,9 +40,13 @@ class XBT_PUBLIC Host : public xbt::Extendable<Host> {
   friend vm::VMModel;            // Use the pimpl_cpu to compute the VM sharing
   friend vm::VirtualMachineImpl; // creates the the pimpl_cpu
   friend kernel::routing::NetZoneImpl;
+  friend surf::HostImpl; // call destructor from private implementation
+
+  // The private implementation, that never changes
+  surf::HostImpl* const pimpl_;
 
 public:
-  explicit Host(const std::string& name);
+  explicit Host(surf::HostImpl* pimpl) : pimpl_(pimpl) {}
 
 protected:
   virtual ~Host(); // Call destroy() instead of manually deleting it.
@@ -75,9 +79,9 @@ public:
   static Host* current();
 
   /** Retrieves the name of that host as a C++ string */
-  xbt::string const& get_name() const { return name_; }
+  xbt::string const& get_name() const;
   /** Retrieves the name of that host as a C string */
-  const char* get_cname() const { return name_.c_str(); }
+  const char* get_cname() const;
 
   kernel::routing::NetPoint* get_netpoint() const { return pimpl_netpoint_; }
 
@@ -183,17 +187,15 @@ public:
 
   /** Block the calling actor on an execution located on the called host (with explicit priority) */
   void execute(double flops, double priority) const;
+  surf::HostImpl* get_impl() const { return pimpl_; }
 
 private:
-  xbt::string name_{"noname"};
   kernel::routing::NetPoint* pimpl_netpoint_ = nullptr;
 
 public:
 #ifndef DOXYGEN
   /** DO NOT USE DIRECTLY (@todo: these should be protected, once our code is clean) */
   kernel::resource::Cpu* pimpl_cpu = nullptr;
-  // TODO, this could be a unique_ptr
-  surf::HostImpl* pimpl_ = nullptr;
 #endif
 };
 } // namespace s4u