Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use std::unique_ptr to manage memory.
[simgrid.git] / include / simgrid / jedule / jedule_platform.hpp
1 /* Copyright (c) 2010-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 JED_SIMGRID_PLATFORM_H_
7 #define JED_SIMGRID_PLATFORM_H_
8
9 #include <simgrid/forward.h>
10 #include <xbt/dynar.h>
11
12 #include <memory>
13 #include <string>
14 #include <unordered_map>
15 #include <vector>
16
17 namespace simgrid {
18 namespace jedule{
19 class XBT_PUBLIC Container {
20 public:
21   explicit Container(const std::string& name);
22   Container(const Container&) = delete;
23   Container& operator=(const Container&) = delete;
24
25 private:
26   int last_id_;
27   int is_lowest_ = 0;
28
29 public:
30   std::string name;
31   std::unordered_map<const char*, unsigned int> name2id;
32   Container *parent = nullptr;
33   std::vector<std::unique_ptr<Container>> children;
34   std::vector<sg_host_t> resource_list;
35   void add_child(Container* child);
36   void add_resources(std::vector<sg_host_t> hosts);
37   void create_hierarchy(sg_netzone_t from_as);
38   std::vector<int> get_hierarchy();
39   std::string get_hierarchy_as_string();
40   void print(FILE *file);
41   void print_resources(FILE* file);
42 };
43
44 class XBT_PUBLIC Subset {
45 public:
46   Subset(int s, int n, Container* p);
47   int start_idx; // start idx in resource_list of container
48   int nres;      // number of resources spanning starting at start_idx
49   Container *parent;
50 };
51
52 }
53 }
54 typedef simgrid::jedule::Container * jed_container_t;
55 void get_resource_selection_by_hosts(std::vector<simgrid::jedule::Subset>& subset_list,
56                                      const std::vector<sg_host_t>& host_list);
57
58 #endif /* JED_SIMGRID_PLATFORM_H_ */