Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Move the signals from simgrid::surf::Host to simgrid::Host
[simgrid.git] / include / simgrid / Host.hpp
1 /* Copyright (c) 2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_HOST_HPP
8 #define SIMGRID_HOST_HPP
9
10 #include <cstddef>
11 #include <memory>
12 #include <string>
13 #include <vector>
14
15 #include <xbt/base.h>
16 #include <xbt/dict.h>
17 #include <xbt/swag.h>
18 #include <xbt/string.hpp>
19 #include <xbt/signal.hpp>
20 #include <xbt/Extendable.hpp>
21
22 #include <simgrid/datatypes.h>
23
24 namespace simgrid {
25
26 XBT_PUBLIC_CLASS Host :
27 public simgrid::xbt::Extendable<Host> {
28
29 public:
30         double getSpeed();
31         int getCoreAmount();
32
33         /* FIXME: these should be protected, but it leads to many errors */
34         surf::Cpu     *pimpl_cpu = nullptr;
35         surf::NetCard *pimpl_netcard = nullptr;
36 private:
37   simgrid::xbt::string name_ = "noname";
38 public:
39   Host(std::string const& name);
40   ~Host();
41   simgrid::xbt::string const& getName() const { return name_; }
42   void turnOn();
43   void turnOff();
44   bool isOn();
45   bool isOff();
46   xbt_dict_t getProperties();
47   xbt_swag_t getProcessList();
48   double getCurrentPowerPeak();
49   double getPowerPeakAt(int pstate_index);
50   void setPState(int pstate_index);
51   int getPState();
52   void getParams(vm_params_t params);
53   void setParams(vm_params_t params);
54   xbt_dict_t getMountedStorageList();
55   xbt_dynar_t getAttachedStorageList();
56
57   static Host* by_name_or_null(const char* name);
58   static Host* by_name_or_create(const char* name);
59
60   /*** Called on each newly created object */
61   static simgrid::xbt::signal<void(Host&)> onCreation;
62   /*** Called just before destructing an object */
63   static simgrid::xbt::signal<void(Host&)> onDestruction;
64   /*** Called when the machine is turned on or off */
65   static simgrid::xbt::signal<void(Host&)> onStateChange;
66 };
67
68 }
69
70 #endif