Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memory leaks.
[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 class ContainerType;
16 class EventType;
17
18 class Type {
19   long long int id_;
20   std::string name_;
21   std::string color_;
22   Type* father_;
23
24 public:
25   std::map<std::string, Type*> children_;
26
27   Type(std::string name, std::string alias, std::string color, Type* father);
28   virtual ~Type();
29
30   std::string getName() { return name_; }
31   const char* getCname() { return name_.c_str(); }
32   long long int getId() { return id_; }
33   bool isColored() { return not color_.empty(); }
34
35   Type* byName(std::string name);
36   ContainerType* getOrCreateContainerType(std::string name);
37   EventType* getOrCreateEventType(std::string name);
38   LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
39   StateType* getOrCreateStateType(std::string name);
40   VariableType* getOrCreateVariableType(std::string name, std::string color);
41
42   void logDefinition(e_event_type event_type);
43   void logDefinition(Type* source, Type* dest);
44 };
45
46 class ContainerType : public Type {
47 public:
48   explicit ContainerType(std::string name) : Type(name, name, "", nullptr){};
49   ContainerType(std::string name, Type* father);
50 };
51
52 class VariableType : public Type {
53   std::vector<VariableEvent*> events_;
54   Container* issuer_ = nullptr;
55
56 public:
57   VariableType(std::string name, std::string color, Type* father);
58   ~VariableType();
59   void setCallingContainer(Container* container) { issuer_ = container; }
60   void setEvent(double timestamp, double value);
61   void addEvent(double timestamp, double value);
62   void subEvent(double timestamp, double value);
63 };
64
65 class ValueType : public Type {
66 public:
67   std::map<std::string, EntityValue*> values_;
68   ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
69   ValueType(std::string name, Type* father) : Type(name, name, "", father){};
70   virtual ~ValueType();
71   void addEntityValue(std::string name, std::string color);
72   void addEntityValue(std::string name);
73   EntityValue* getEntityValue(std::string name);
74 };
75
76 class LinkType : public ValueType {
77 public:
78   LinkType(std::string name, std::string alias, Type* father);
79   void startEvent(Container* source_container, Container* sourceContainer, std::string value, std::string key);
80   void startEvent(Container* source_container, Container* sourceContainer, std::string value, std::string key,
81                   int size);
82   void endEvent(Container* source_container, Container* destContainer, std::string value, std::string key);
83 };
84
85 class EventType : public ValueType {
86 public:
87   EventType(std::string name, Type* father);
88 };
89
90 class StateType : public ValueType {
91   std::vector<StateEvent*> events_;
92   Container* issuer_ = nullptr;
93
94 public:
95   StateType(std::string name, Type* father);
96   ~StateType();
97   void setCallingContainer(Container* container) { issuer_ = container; }
98   void setEvent(std::string value_name);
99   void pushEvent(std::string value_name);
100   void pushEvent(std::string value_name, void* extra);
101   void popEvent();
102 };
103 }
104 }
105 #endif