Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
8306af0d3500fafbaecdb0da6ca6aec450c2afc8
[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(name, name, "", nullptr){};
60   ContainerType(std::string name, Type* father);
61 };
62
63 class VariableType : public Type {
64   std::vector<VariableEvent*> events_;
65
66 public:
67   VariableType(std::string name, std::string color, Type* father);
68   ~VariableType();
69   void setEvent(double timestamp, Container* container, double value);
70   void addEvent(double timestamp, Container* container, double value);
71   void subEvent(double timestamp, Container* container, double value);
72 };
73
74 class ValueType : public Type {
75 public:
76   std::map<std::string, EntityValue*> values_;
77   ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
78   ValueType(std::string name, Type* father) : Type(name, name, "", father){};
79   virtual ~ValueType();
80   void addEntityValue(std::string name, std::string color);
81   void addEntityValue(std::string name);
82   EntityValue* getEntityValue(std::string name);
83 };
84
85 class LinkType : public ValueType {
86 public:
87   LinkType(std::string name, std::string alias, Type* father);
88 };
89
90 class EventType : public ValueType {
91 public:
92   EventType(std::string name, Type* father);
93 };
94
95 class StateType : public ValueType {
96   std::vector<StateEvent*> events_;
97
98 public:
99   StateType(std::string name, Type* father);
100   ~StateType();
101   void setEvent(double timestamp, Container* container, std::string value_name);
102   void pushEvent(double timestamp, Container* container, std::string value_name);
103   void pushEvent(double timestamp, Container* container, std::string value_name, void* extra);
104   void popEvent(double timestamp, Container* container);
105 };
106 }
107 }
108 #endif