Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #237 from oar-team/upstream
[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   Container* issuer_ = nullptr;
27
28   Type(std::string name, std::string alias, std::string color, Type* father);
29   virtual ~Type();
30
31   std::string getName() { return name_; }
32   const char* getCname() { return name_.c_str(); }
33   long long int getId() { return id_; }
34   bool isColored() { return not color_.empty(); }
35
36   Type* byName(std::string name);
37   ContainerType* getOrCreateContainerType(std::string name);
38   EventType* getOrCreateEventType(std::string name);
39   LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
40   StateType* getOrCreateStateType(std::string name);
41   VariableType* getOrCreateVariableType(std::string name, std::string color);
42
43   void setCallingContainer(Container* container) { issuer_ = container; }
44
45   void logDefinition(e_event_type event_type);
46   void logDefinition(Type* source, Type* dest);
47 };
48
49 class ContainerType : public Type {
50 public:
51   explicit ContainerType(std::string name) : Type(name, name, "", nullptr){};
52   ContainerType(std::string name, Type* father);
53 };
54
55 class VariableType : public Type {
56   std::vector<VariableEvent*> events_;
57 public:
58   VariableType(std::string name, std::string color, Type* father);
59   ~VariableType();
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* startContainer, std::string value, std::string key);
80   void startEvent(Container* startContainer, std::string value, std::string key, int size);
81   void endEvent(Container* endContainer, std::string value, std::string key);
82 };
83
84 class EventType : public ValueType {
85 public:
86   EventType(std::string name, Type* father);
87 };
88
89 class StateType : public ValueType {
90   std::vector<StateEvent*> events_;
91 public:
92   StateType(std::string name, Type* father);
93   ~StateType();
94   void setEvent(std::string value_name);
95   void pushEvent(std::string value_name);
96   void pushEvent(std::string value_name, TIData* extra);
97   void popEvent();
98 };
99 }
100 }
101 #endif