Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into disk
[simgrid.git] / src / surf / HostImpl.hpp
1 /* Copyright (c) 2004-2019. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SURF_HOST_INTERFACE_HPP_
7 #define SURF_HOST_INTERFACE_HPP_
8
9 #include "src/kernel/actor/ActorImpl.hpp"
10 #include "src/kernel/resource/DiskImpl.hpp"
11 #include "src/surf/PropertyHolder.hpp"
12 #include "src/surf/StorageImpl.hpp"
13 #include "src/surf/cpu_interface.hpp"
14 #include "src/surf/network_interface.hpp"
15
16 #include <vector>
17
18 namespace simgrid {
19 namespace surf {
20
21 /*********
22  * Model *
23  *********/
24
25 /** @ingroup SURF_host_interface
26  * @brief SURF Host model interface class
27  * @details A model is an object which handle the interactions between its Resources and its Actions
28  */
29 class XBT_PRIVATE HostModel : public kernel::resource::Model {
30 public:
31   HostModel() : Model(Model::UpdateAlgo::FULL) {}
32
33   virtual kernel::resource::Action* execute_parallel(const std::vector<s4u::Host*>& host_list,
34                                                      const double* flops_amount, const double* bytes_amount,
35                                                      double rate);
36 };
37
38 /************
39  * Resource *
40  ************/
41 /** @ingroup SURF_host_interface
42  * @brief SURF Host interface class
43  * @details An host represents a machine with a aggregation of a Cpu, a RoutingEdge and a Storage
44  */
45 class XBT_PRIVATE HostImpl : public simgrid::surf::PropertyHolder {
46
47 public:
48   explicit HostImpl(s4u::Host* host);
49   virtual ~HostImpl();
50
51   std::vector<s4u::Disk*> get_disks();
52   /** @brief Get the vector of storages (by names) attached to the Host */
53   virtual std::vector<const char*> get_attached_storages();
54
55   std::map<std::string, kernel::resource::StorageImpl*> storage_;
56   std::vector<kernel::resource::DiskImpl*> disks_;
57
58   s4u::Host* piface_ = nullptr;
59
60   void turn_on();
61   void turn_off();
62   std::vector<s4u::ActorPtr> get_all_actors();
63   size_t get_actor_count();
64
65   typedef boost::intrusive::list<
66       kernel::actor::ActorImpl,
67       boost::intrusive::member_hook<kernel::actor::ActorImpl, boost::intrusive::list_member_hook<>,
68                                     &kernel::actor::ActorImpl::host_process_list_hook>>
69       ActorList;
70
71   // FIXME: make these private
72   ActorList process_list_;
73   std::vector<kernel::actor::ProcessArg*> actors_at_boot_;
74 };
75 }
76 }
77
78 XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model;
79
80 #endif /* SURF_Host_INTERFACE_HPP_ */