Logo AND Algorithmique Numérique Distribuée

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