surf::HostImpl* const pimpl_;
public:
- explicit Host(const std::string& name, surf::HostImpl* pimpl) : pimpl_(pimpl), name_(name) {}
+ explicit Host(surf::HostImpl* pimpl) : pimpl_(pimpl) {}
protected:
virtual ~Host(); // Call destroy() instead of manually deleting it.
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_; }
surf::HostImpl* get_impl() const { return pimpl_; }
private:
- /* Host name must be kept in the s4u side to be accessible by MC process */
- xbt::string name_{"noname"};
kernel::routing::NetPoint* pimpl_netpoint_ = nullptr;
public:
}
VirtualMachine::VirtualMachine(const std::string& name, s4u::Host* physical_host, int core_amount, size_t ramsize)
- : Host(name, new vm::VirtualMachineImpl(name, this, physical_host, core_amount, ramsize))
+ : Host(new vm::VirtualMachineImpl(name, this, physical_host, core_amount, ramsize))
, pimpl_vm_(dynamic_cast<vm::VirtualMachineImpl*>(Host::get_impl()))
{
XBT_DEBUG("Create VM %s", get_cname());
return self->get_host();
}
+xbt::string const& Host::get_name() const
+{
+ return this->pimpl_->get_name();
+}
+
+const char* Host::get_cname() const
+{
+ return this->pimpl_->get_cname();
+}
+
void Host::turn_on()
{
if (not is_on()) {
/************
* Resource *
************/
-HostImpl::HostImpl(const std::string& name, s4u::Host* piface) : piface_(name, this)
+HostImpl::HostImpl(const std::string& name, s4u::Host* piface) : piface_(this), name_(name)
{
- xbt_assert(s4u::Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name.c_str());
- s4u::Engine::get_instance()->host_register(name, piface);
+ xbt_assert(s4u::Host::by_name_or_null(name_) == nullptr, "Refusing to create a second host named '%s'.", get_cname());
+ s4u::Engine::get_instance()->host_register(name_, piface);
}
-HostImpl::HostImpl(const std::string& name) : piface_(name, this)
+HostImpl::HostImpl(const std::string& name) : piface_(this), name_(name)
{
- xbt_assert(s4u::Host::by_name_or_null(name) == nullptr, "Refusing to create a second host named '%s'.", name.c_str());
- s4u::Engine::get_instance()->host_register(name, &piface_);
+ xbt_assert(s4u::Host::by_name_or_null(name_) == nullptr, "Refusing to create a second host named '%s'.", get_cname());
+ s4u::Engine::get_instance()->host_register(name_, &piface_);
}
HostImpl::~HostImpl()
void HostImpl::destroy()
{
s4u::Host::on_destruction(*this->get_iface());
- s4u::Engine::get_instance()->host_unregister(std::string(get_iface()->get_name()));
+ s4u::Engine::get_instance()->host_unregister(std::string(name_));
delete this;
}
std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
s4u::Host piface_;
std::vector<kernel::resource::DiskImpl*> disks_;
+ xbt::string name_{"noname"};
protected:
virtual ~HostImpl(); // Use destroy() instead of this destructor.
virtual const s4u::Host* get_iface() const { return &piface_; }
virtual s4u::Host* get_iface() { return &piface_; }
+ /** Retrieves the name of that host as a C++ string */
+ xbt::string const& get_name() const { return name_; }
+ /** Retrieves the name of that host as a C string */
+ const char* get_cname() const { return name_.c_str(); }
+
void turn_on() const;
void turn_off(const kernel::actor::ActorImpl* issuer);
std::vector<s4u::ActorPtr> get_all_actors();