Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
8ec86488b886491f20dc03ba2f96072d5fa20d71
[simgrid.git] / src / instr / instr_paje_types.hpp
1 /* Copyright (c) 2010-2017. 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_TYPES_HPP
7 #define INSTR_PAJE_TYPES_HPP
8
9 #include "src/instr/instr_private.hpp"
10 #include <string>
11 #include <vector>
12
13 namespace simgrid {
14 namespace instr {
15 enum e_event_type : unsigned int;
16 class EntityValue;
17 class ContainerType;
18 class EventType;
19 class LinkType;
20 class StateType;
21 class VariableType;
22 class StateEvent;
23 class VariableEvent;
24
25 class Type {
26   long long int id_;
27   std::string name_;
28   std::string color_;
29   Type* father_;
30
31 public:
32   std::map<std::string, Type*> children_;
33
34   Type(std::string name, std::string alias, std::string color, Type* father);
35   virtual ~Type();
36
37   std::string getName() { return name_; }
38   const char* getCname() { return name_.c_str(); }
39   long long int getId() { return id_; }
40   bool isColored() { return not color_.empty(); }
41
42   Type* byName(std::string name);
43
44   ContainerType* getOrCreateContainerType(std::string name);
45   EventType* getOrCreateEventType(std::string name);
46   LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
47   StateType* getOrCreateStateType(std::string name);
48   VariableType* getOrCreateVariableType(std::string name, std::string color);
49
50   void logDefinition(e_event_type event_type);
51   void logDefinition(Type* source, Type* dest);
52
53   static ContainerType* createRootType();
54   static ContainerType* getRootType();
55 };
56
57 class ContainerType : public Type {
58 public:
59   ContainerType(std::string name, Type* father);
60 };
61
62 class VariableType : public Type {
63   std::vector<VariableEvent*> events_;
64
65 public:
66   VariableType(std::string name, std::string color, Type* father);
67   ~VariableType();
68   void setEvent(double timestamp, Container* container, double value);
69   void addEvent(double timestamp, Container* container, double value);
70   void subEvent(double timestamp, Container* container, double value);
71 };
72
73 class ValueType : public Type {
74 public:
75   std::map<std::string, EntityValue*> values_;
76   ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
77   ValueType(std::string name, Type* father) : Type(name, name, "", father){};
78   virtual ~ValueType();
79   void addEntityValue(std::string name, std::string color);
80   void addEntityValue(std::string name);
81   EntityValue* getEntityValue(std::string name);
82 };
83
84 class LinkType : public ValueType {
85 public:
86   LinkType(std::string name, std::string alias, Type* father);
87 };
88
89 class EventType : public ValueType {
90 public:
91   EventType(std::string name, Type* father);
92 };
93
94 class StateType : public ValueType {
95   std::vector<StateEvent*> events_;
96
97 public:
98   StateType(std::string name, Type* father);
99   ~StateType();
100   void setEvent(double timestamp, Container* container, std::string value_name);
101   void pushEvent(double timestamp, Container* container, std::string value_name);
102   void pushEvent(double timestamp, Container* container, std::string value_name, void* extra);
103   void popEvent(double timestamp, Container* container);
104 };
105 }
106 }
107 #endif