X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e03ba5e826a3b2422d4bb300fe3949bed0f71712..232df979b87bc271f4fbb61a2059c6539bc23012:/include/simgrid/s4u/host.hpp diff --git a/include/simgrid/s4u/host.hpp b/include/simgrid/s4u/host.hpp index 74b826bb2b..2f5ef50fdc 100644 --- a/include/simgrid/s4u/host.hpp +++ b/include/simgrid/s4u/host.hpp @@ -9,15 +9,18 @@ #include #include -#include "simgrid/simix.h" +#include +#include +#include +#include + +#include +#include +#include namespace simgrid { namespace s4u { -class Actor; -class Storage; -class File; - /** @brief Simulated machine that can host some actors * * It represents some physical resource with computing and networking capabilities. @@ -29,58 +32,86 @@ class File; * You can retrieve a particular host using @link{simgrid::s4u::Host.byName()}, * and actors can retrieve the host on which they run using @link{simgrid::s4u::Host.current()}. */ -class Host { - friend Actor; - friend File; +XBT_PUBLIC_CLASS Host : + public simgrid::xbt::Extendable { + + // friend Actor; + // friend File; private: Host(const char *name); -protected: +public: // TODO, make me private ~Host(); public: + + static Host* by_name_or_null(const char* name); + static Host* by_name_or_create(const char* name); /** Retrieves an host from its name. */ - static s4u::Host *byName(std::string name); + static s4u::Host *by_name(std::string name); /** Retrieves the host on which the current actor is running */ static s4u::Host *current(); - const char* name(); + simgrid::xbt::string const& name() const { return name_; } /** Turns that host on if it was previously off * * All actors on that host which were marked autorestart will be restarted automatically. * This call does nothing if the host is already on. */ - void turnOn(); + void turn_on(); /** Turns that host off. All actors are forcefully stopped. */ - void turnOff(); + void turn_off(); /** Returns if that host is currently up and running */ - bool isOn(); - - - /** Allows to store user data on that host */ - void set_userdata(void *data) {p_userdata = data;} - /** Retrieves the previously stored data */ - void* userdata() {return p_userdata;} + bool is_on(); + bool is_off() { return !is_on(); } + + double speed(); + int core_count(); + xbt_dict_t properties(); + xbt_swag_t processes(); + double current_power_peak(); + double power_peak_at(int pstate_index); + void set_pstate(int pstate_index); + int pstates_count() const; + int pstate(); + void get_parameters(vm_params_t params); + void set_parameters(vm_params_t params); + xbt_dict_t mounted_storages_as_dict(); // HACK + xbt_dynar_t attached_storages(); /** Get an associative list [mount point]->[Storage] off all local mount points. * * This is defined in the platform file, and cannot be modified programatically (yet). - * - * Do not change the returned value in any way. */ - boost::unordered_map &mountedStorages(); -private: - boost::unordered_map *mounts = NULL; // caching + boost::unordered_map const &mounted_storages(); -protected: - sg_host_t inferior() {return p_inferior;} private: - void*p_userdata=NULL; - sg_host_t p_inferior; - static boost::unordered_map *hosts; + simgrid::xbt::string name_ = "noname"; + boost::unordered_map *mounts = NULL; // caching + +public: + // FIXME: these should be protected, but it leads to many errors + // Use the extensions stuff for this? Go through simgrid::surf::Host? + // TODO, this could be a unique_ptr + surf::Cpu *pimpl_cpu = nullptr; + surf::NetCard *pimpl_netcard = nullptr; + +public: + /*** Called on each newly created object */ + static simgrid::xbt::signal onCreation; + /*** Called just before destructing an object */ + static simgrid::xbt::signal onDestruction; + /*** Called when the machine is turned on or off */ + static simgrid::xbt::signal onStateChange; }; }} // namespace simgrid::s4u +extern int MSG_HOST_LEVEL; +extern int SD_HOST_LEVEL; +extern int SIMIX_HOST_LEVEL; +extern int ROUTING_HOST_LEVEL; +extern int USER_HOST_LEVEL; + #endif /* SIMGRID_S4U_HOST_HPP */ #if 0