Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add and use callback instr_actor_on_creation
[simgrid.git] / src / instr / instr_paje_types.hpp
1 /* Copyright (c) 2010-2018. 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 <sstream>
11 #include <string>
12 #include <vector>
13
14 namespace simgrid {
15 namespace instr {
16 class ContainerType;
17 class EventType;
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   std::stringstream stream_;
29
30   Type(std::string name, std::string alias, std::string color, Type* father);
31   virtual ~Type();
32
33   std::string get_name() { return name_; }
34   const char* get_cname() { return name_.c_str(); }
35   long long int get_id() { return id_; }
36   bool isColored() { return not color_.empty(); }
37
38   Type* byName(std::string name);
39   ContainerType* getOrCreateContainerType(std::string name);
40   EventType* getOrCreateEventType(std::string name);
41   LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
42   StateType* getOrCreateStateType(std::string name);
43   VariableType* getOrCreateVariableType(std::string name, std::string color);
44
45   void setCallingContainer(Container* container) { issuer_ = container; }
46
47   void logDefinition(e_event_type event_type);
48   void logDefinition(Type* source, Type* dest);
49 };
50
51 class ContainerType : public Type {
52 public:
53   explicit ContainerType(std::string name) : Type(name, name, "", nullptr){};
54   ContainerType(std::string name, Type* father);
55 };
56
57 class VariableType : public Type {
58   std::vector<VariableEvent*> events_;
59 public:
60   VariableType(std::string name, std::string color, Type* father);
61   ~VariableType();
62   void setEvent(double timestamp, double value);
63   void addEvent(double timestamp, double value);
64   void subEvent(double timestamp, double value);
65 };
66
67 class ValueType : public Type {
68 public:
69   std::map<std::string, EntityValue*> values_;
70   ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
71   ValueType(std::string name, Type* father) : Type(name, name, "", father){};
72   virtual ~ValueType();
73   void addEntityValue(std::string name, std::string color);
74   void addEntityValue(std::string name);
75   EntityValue* getEntityValue(std::string name);
76 };
77
78 class LinkType : public ValueType {
79 public:
80   LinkType(std::string name, std::string alias, Type* father);
81   void startEvent(Container* startContainer, std::string value, std::string key);
82   void startEvent(Container* startContainer, std::string value, std::string key, int size);
83   void endEvent(Container* endContainer, std::string value, std::string key);
84 };
85
86 class EventType : public ValueType {
87 public:
88   EventType(std::string name, Type* father);
89 };
90
91 class StateType : public ValueType {
92   std::vector<StateEvent*> events_;
93 public:
94   StateType(std::string name, Type* father);
95   ~StateType();
96   void setEvent(std::string value_name);
97   void pushEvent(std::string value_name);
98   void pushEvent(std::string value_name, TIData* extra);
99   void popEvent();
100   void popEvent(TIData* extra);
101 };
102 }
103 }
104 #endif