X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/4dbb8aa24d54e0a4091b1f01017032702d0376f7..2bdebbaf8391c3b5dc1cd193491504f83bb2ea3e:/include/simgrid/s4u/host.hpp diff --git a/include/simgrid/s4u/host.hpp b/include/simgrid/s4u/host.hpp index 6998b87429..3d32534415 100644 --- a/include/simgrid/s4u/host.hpp +++ b/include/simgrid/s4u/host.hpp @@ -7,13 +7,22 @@ #define SIMGRID_S4U_HOST_HPP #include +#include -#include "simgrid/simix.h" +#include +#include +#include +#include + +#include +#include namespace simgrid { namespace s4u { class Actor; +class Storage; +class File; /** @brief Simulated machine that can host some actors * @@ -26,16 +35,25 @@ class Actor; * 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 { +XBT_PUBLIC_CLASS Host : + public simgrid::xbt::Extendable { + + // friend Actor; + // friend File; private: Host(const char *name); +public: // TODO, make me private + ~Host(); public: /** Retrieves an host from its name. */ static s4u::Host *byName(std::string name); /** Retrieves the host on which the current actor is running */ static s4u::Host *current(); - const char* getName(); + static Host* by_name_or_null(const char* name); + static Host* by_name_or_create(const char* name); + + simgrid::xbt::string const& name() const { return name_; } /** Turns that host on if it was previously off * @@ -47,24 +65,65 @@ public: void turnOff(); /** Returns if that host is currently up and running */ bool isOn(); - + bool isOff() { return !isOn(); } + + double getSpeed(); + int getCoreAmount(); + xbt_dict_t getProperties(); + xbt_swag_t getProcessList(); + double getCurrentPowerPeak(); + double getPowerPeakAt(int pstate_index); + void setPState(int pstate_index); + int getNbPStates() const; + int getPState(); + void getParams(vm_params_t params); + void setParams(vm_params_t params); + xbt_dict_t getMountedStorageList(); + xbt_dynar_t getAttachedStorageList(); /** Allows to store user data on that host */ - void setData(void *data) {p_userdata = data;} + // TODO, use the extension stuff instead + void set_userdata(void *data) {p_userdata = data;} /** Retrieves the previously stored data */ - void* getData() {return p_userdata;} + void* userdata() {return p_userdata;} + + /** 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. + */ + // TODO, do not use Storage&, this looks dangerous! + boost::unordered_map &mountedStorages(); -protected: - friend Actor; - sg_host_t getInferior() {return p_sghost;} private: - void*p_userdata=NULL; - sg_host_t p_sghost; - static boost::unordered_map *hosts; + simgrid::xbt::string name_ = "noname"; + boost::unordered_map *mounts = NULL; // caching + void* p_userdata = NULL; + +public: + // FIXME: these should be protected, but it leads to many errors + // Use the extensions stuff for this? Go through simgrid::surf::Host? + 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 @@ -149,11 +208,6 @@ public class Host { */ public native void setProperty(String name, String value); - /** This methods returns the list of mount point names on an host - * @return An array containing all mounted storages on the host - */ - public native Storage[] getMountedStorage(); - /** This methods returns the list of storages attached to an host * @return An array containing all storages (name) attached to the host */