Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / instr / instr_paje_containers.hpp
1 /* Copyright (c) 2010-2021. 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 INSTR_PAJE_CONTAINERS_HPP
7 #define INSTR_PAJE_CONTAINERS_HPP
8
9 #include "src/instr/instr_private.hpp"
10 #include <string>
11
12 namespace simgrid {
13 namespace instr {
14 class Type;
15 class LinkType;
16 class StateType;
17 class VariableType;
18
19 class Container {
20   static Container* root_container_;
21   static std::map<std::string, Container*, std::less<>> all_containers_;
22
23   long long int id_;
24   std::string name_; /* Unique name of this container */
25
26 protected:
27   static void set_root(Container* root) { root_container_ = root; }
28
29 public:
30   static xbt::signal<void(Container const&)> on_creation;
31   static xbt::signal<void(Container const&)> on_destruction;
32
33   explicit Container(const std::string& name, const std::string& type_name, Container* father);
34   Container(const Container&) = delete;
35   Container& operator=(const Container&) = delete;
36   virtual ~Container();
37
38   Type* type_; /* Type of this container */
39   Container* father_;
40   std::map<std::string, Container*, std::less<>> children_;
41
42   static Container* by_name_or_null(const std::string& name);
43   static Container* by_name(const std::string& name);
44   const std::string& get_name() const { return name_; }
45   const char* get_cname() const { return name_.c_str(); }
46   long long int get_id() const { return id_; }
47   void remove_from_parent();
48
49   StateType* get_state(const std::string& name);
50   LinkType* get_link(const std::string& name);
51   VariableType* get_variable(const std::string& name);
52   void create_child(const std::string& name, const std::string& type_name);
53   static Container* get_root() { return root_container_; }
54 };
55
56 class NetZoneContainer : public Container {
57 public:
58   NetZoneContainer(const std::string& name, unsigned int level, NetZoneContainer* father);
59 };
60
61 class RouterContainer : public Container {
62 public:
63   RouterContainer(const std::string& name, Container* father);
64 };
65
66 class HostContainer : public Container {
67 public:
68   HostContainer(s4u::Host const& host, NetZoneContainer* father);
69 };
70 } // namespace instr
71 } // namespace simgrid
72 #endif