Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6d9a9bffcbdb0b7b40a40b07543589f0de93832e
[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   ContainerType* getOrCreateContainerType(std::string name);
44   EventType* getOrCreateEventType(std::string name);
45   LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
46
47   StateType* getOrCreateStateType(std::string name);
48   StateType* getState(std::string name);
49
50   VariableType* getOrCreateVariableType(std::string name, std::string color);
51
52   void logDefinition(e_event_type event_type);
53   void logDefinition(Type* source, Type* dest);
54
55   static ContainerType* createRootType();
56   static ContainerType* getRootType();
57 };
58
59 class ContainerType : public Type {
60 public:
61   explicit ContainerType(std::string name) : Type(name, name, "", nullptr){};
62   ContainerType(std::string name, Type* father);
63 };
64
65 class VariableType : public Type {
66   std::vector<VariableEvent*> events_;
67
68 public:
69   VariableType(std::string name, std::string color, Type* father);
70   ~VariableType();
71   void setEvent(double timestamp, Container* container, double value);
72   void addEvent(double timestamp, Container* container, double value);
73   void subEvent(double timestamp, Container* container, double value);
74 };
75
76 class ValueType : public Type {
77 public:
78   std::map<std::string, EntityValue*> values_;
79   ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
80   ValueType(std::string name, Type* father) : Type(name, name, "", father){};
81   virtual ~ValueType();
82   void addEntityValue(std::string name, std::string color);
83   void addEntityValue(std::string name);
84   EntityValue* getEntityValue(std::string name);
85 };
86
87 class LinkType : public ValueType {
88 public:
89   LinkType(std::string name, std::string alias, Type* father);
90   void startEvent(Container* source_container, Container* sourceContainer, std::string value, std::string key);
91   void startEvent(Container* source_container, Container* sourceContainer, std::string value, std::string key,
92                   int size);
93   void endEvent(Container* source_container, Container* destContainer, std::string value, std::string key);
94 };
95
96 class EventType : public ValueType {
97 public:
98   EventType(std::string name, Type* father);
99 };
100
101 class StateType : public ValueType {
102   std::vector<StateEvent*> events_;
103   Container* issuer_ = nullptr;
104
105 public:
106   StateType(std::string name, Type* father);
107   ~StateType();
108   void setCallingContainer(Container* container) { issuer_ = container; }
109   void setEvent(std::string value_name);
110   void pushEvent(std::string value_name);
111   void pushEvent(std::string value_name, void* extra);
112   void popEvent();
113 };
114 }
115 }
116 #endif