Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Save a couple of strdup/free.
[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
12 namespace simgrid {
13 namespace instr {
14 enum e_event_type : unsigned int;
15 class EntityValue;
16 class ContainerType;
17 class EventType;
18 class LinkType;
19 class StateType;
20 class VariableType;
21
22 class Type {
23   long long int id_;
24   std::string name_;
25   std::string color_;
26   Type* father_;
27
28 public:
29   std::map<std::string, Type*> children_;
30
31   Type(std::string name, std::string alias, std::string color, Type* father);
32   virtual ~Type();
33
34   std::string getName() { return name_; }
35   const char* getCname() { return name_.c_str(); }
36   long long int getId() { return id_; }
37   bool isColored() { return not color_.empty(); }
38
39   Type* byName(std::string name);
40
41   ContainerType* getOrCreateContainerType(std::string name);
42   EventType* getOrCreateEventType(std::string name);
43   LinkType* getOrCreateLinkType(std::string name, Type* source, Type* dest);
44   StateType* getOrCreateStateType(std::string name);
45   VariableType* getOrCreateVariableType(std::string name, std::string color);
46
47   void logDefinition(e_event_type event_type);
48   void logDefinition(Type* source, Type* dest);
49
50   static ContainerType* createRootType();
51   static ContainerType* getRootType();
52 };
53
54 class ContainerType : public Type {
55 public:
56   ContainerType(std::string name, Type* father);
57 };
58
59 class VariableType : public Type {
60 public:
61   VariableType(std::string name, std::string color, Type* father);
62 };
63
64 class ValueType : public Type {
65 public:
66   std::map<std::string, EntityValue*> values_;
67   ValueType(std::string name, std::string alias, Type* father) : Type(name, alias, "", father){};
68   ValueType(std::string name, Type* father) : Type(name, name, "", father){};
69   virtual ~ValueType();
70   void addEntityValue(std::string name, std::string color);
71   void addEntityValue(std::string name);
72   EntityValue* getEntityValue(std::string name);
73 };
74
75 class LinkType : public ValueType {
76 public:
77   LinkType(std::string name, std::string alias, Type* father);
78 };
79
80 class EventType : public ValueType {
81 public:
82   EventType(std::string name, Type* father);
83 };
84
85 class StateType : public ValueType {
86 public:
87   StateType(std::string name, Type* father);
88 };
89 }
90 }
91 #endif