+#include "simgrid/s4u/storage.hpp"
+
+int MSG_HOST_LEVEL;
+int SIMIX_HOST_LEVEL;
+int USER_HOST_LEVEL;
+
+namespace simgrid {
+
+namespace xbt {
+template class Extendable<simgrid::s4u::Host>;
+}
+
+namespace s4u {
+
+simgrid::xbt::signal<void(Host&)> Host::onCreation;
+simgrid::xbt::signal<void(Host&)> Host::onDestruction;
+simgrid::xbt::signal<void(Host&)> Host::onStateChange;
+
+Host::Host(const char* name)
+ : name_(name)
+{
+}
+
+Host::~Host() {
+ delete pimpl_cpu;
+ delete mounts;
+}
+
+Host *Host::by_name(std::string name) {
+ Host* host = Host::by_name_or_null(name.c_str());
+ // TODO, raise an exception instead?
+ if (host == nullptr)
+ xbt_die("No such host: %s", name.c_str());
+ return host;
+}
+Host* Host::by_name_or_null(const char* name)
+{
+ return (Host*) xbt_dict_get_or_null(host_list, name);
+}
+Host* Host::by_name_or_create(const char* name)
+{
+ Host* host = by_name_or_null(name);
+ if (host == nullptr) {
+ host = new Host(name);
+ xbt_dict_set(host_list, name, host, NULL);
+ }
+ return host;
+}
+
+Host *Host::current(){
+ smx_process_t smx_proc = SIMIX_process_self();
+ if (smx_proc == NULL)
+ xbt_die("Cannot call Host::current() from the maestro context");
+ return SIMIX_process_get_host(smx_proc);
+}
+
+void Host::turnOn() {
+ simgrid::simix::kernel(std::bind(SIMIX_host_on, this));
+}
+
+void Host::turnOff() {
+ simgrid::simix::kernel(std::bind(SIMIX_host_off, this, SIMIX_process_self()));
+}
+
+bool Host::isOn() {
+ return this->pimpl_cpu->isOn();
+}
+
+int Host::pstatesCount() const {
+ return this->pimpl_cpu->getNbPStates();
+}
+
+boost::unordered_map<std::string, Storage*> const& Host::mountedStorages() {
+ if (mounts == NULL) {
+ mounts = new boost::unordered_map<std::string, Storage*> ();
+
+ xbt_dict_t dict = this->mountedStoragesAsDict();
+
+ xbt_dict_cursor_t cursor;
+ char *mountname;
+ char *storagename;
+ xbt_dict_foreach(dict, cursor, mountname, storagename) {
+ mounts->insert({mountname, &Storage::byName(storagename)});
+ }
+ xbt_dict_free(&dict);
+ }