Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e5d5f6407c079426663792228336b8e03aafe2b6
[simgrid.git] / include / simgrid / jedule / jedule_platform.hpp
1 /* Copyright (c) 2010-2018. 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 <unordered_map>
13 #include <vector>
14 #include <string>
15
16 namespace simgrid {
17 namespace jedule{
18 class XBT_PUBLIC Container {
19 public:
20   explicit Container(std::string name);
21   virtual ~Container();
22 private:
23   int last_id;
24   int is_lowest = 0;
25 public:
26   std::string name;
27   std::unordered_map<const char*, unsigned int> name2id;
28   Container *parent = nullptr;
29   std::vector<Container*> children;
30   std::vector<sg_host_t> resource_list;
31   void add_child(Container* child);
32   void add_resources(std::vector<sg_host_t> hosts);
33   void create_hierarchy(sg_netzone_t from_as);
34   std::vector<int> get_hierarchy();
35   std::string get_hierarchy_as_string();
36   void print(FILE *file);
37   void print_resources(FILE* file);
38
39   // deprecated
40   XBT_ATTRIB_DEPRECATED_v323("Please use Container::add_child()") void addChild(Container* child) { add_child(child); }
41   XBT_ATTRIB_DEPRECATED_v323("Please use Container::add_resources()") void addResources(std::vector<sg_host_t> hosts)
42   {
43     add_resources(hosts);
44   }
45   XBT_ATTRIB_DEPRECATED_v323("Please use Container::create_hierarchy()") void createHierarchy(sg_netzone_t from_as)
46   {
47     create_hierarchy(from_as);
48   }
49   XBT_ATTRIB_DEPRECATED_v323("Please use Container::get_hierarchy()") std::vector<int> getHierarchy()
50   {
51     return get_hierarchy();
52   }
53   XBT_ATTRIB_DEPRECATED_v323("Please use Container::get_hierarchy_as_string()") std::string getHierarchyAsString()
54   {
55     return get_hierarchy_as_string();
56   }
57   XBT_ATTRIB_DEPRECATED_v323("Please use Container::print_resources()") void printResources(FILE* file)
58   {
59     print_resources(file);
60   }
61 };
62
63 class XBT_PUBLIC Subset {
64 public:
65   Subset(int s, int n, Container* p);
66   virtual ~Subset()=default;
67   int start_idx; // start idx in resource_list of container
68   int nres;      // number of resources spanning starting at start_idx
69   Container *parent;
70 };
71
72 }
73 }
74 typedef simgrid::jedule::Container * jed_container_t;
75 typedef simgrid::jedule::Subset * jed_subset_t;
76 void get_resource_selection_by_hosts(std::vector<jed_subset_t>* subset_list, std::vector<sg_host_t> *host_list);
77
78 #endif /* JED_SIMGRID_PLATFORM_H_ */