1 /* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef INSTR_PAJE_TYPES_HPP
7 #define INSTR_PAJE_TYPES_HPP
9 #include "src/instr/instr_private.hpp"
27 std::map<std::string, std::unique_ptr<Type>> children_;
28 Container* issuer_ = nullptr;
29 std::stringstream stream_;
31 Type(const std::string& name, const std::string& alias, const std::string& color, Type* father);
32 virtual ~Type() = default;
34 const std::string& get_name() const { return name_; }
35 const char* get_cname() { return name_.c_str(); }
36 long long int get_id() { return id_; }
37 bool is_colored() { return not color_.empty(); }
39 Type* by_name(const std::string& name);
40 LinkType* by_name_or_create(const std::string& name, Type* source, Type* dest);
41 VariableType* by_name_or_create(const std::string& name, const std::string& color);
43 template <class T> T* by_name_or_create(const std::string& name)
45 auto cont = children_.find(name);
46 return cont == children_.end() ? new T(name, this) : static_cast<T*>(cont->second.get());
49 Type* set_calling_container(Container* container)
55 void log_definition(e_event_type event_type);
56 void log_definition(Type* source, Type* dest);
59 class ContainerType : public Type {
61 explicit ContainerType(const std::string& name) : Type(name, name, "", nullptr){};
62 ContainerType(const std::string& name, Type* father);
65 class VariableType : public Type {
66 std::vector<VariableEvent*> events_;
68 VariableType(const std::string& name, const std::string& color, Type* father);
69 void instr_event(double now, double delta, const char* resource, double value);
70 void set_event(double timestamp, double value);
71 void add_event(double timestamp, double value);
72 void sub_event(double timestamp, double value);
75 class ValueType : public Type {
77 std::map<std::string, EntityValue> values_;
78 ValueType(const std::string& name, const std::string& alias, Type* father) : Type(name, alias, "", father){};
79 ValueType(const std::string& name, Type* father) : Type(name, name, "", father){};
80 virtual ~ValueType() = default;
81 void add_entity_value(const std::string& name, const std::string& color);
82 void add_entity_value(const std::string& name);
83 EntityValue* get_entity_value(const std::string& name);
86 class LinkType : public ValueType {
88 LinkType(const std::string& name, const std::string& alias, Type* father);
89 void start_event(Container* startContainer, const std::string& value, const std::string& key);
90 void start_event(Container* startContainer, const std::string& value, const std::string& key, int size);
91 void end_event(Container* endContainer, const std::string& value, const std::string& key);
94 class EventType : public ValueType {
96 EventType(const std::string& name, Type* father);
99 class StateType : public ValueType {
100 std::vector<StateEvent*> events_;
102 StateType(const std::string& name, Type* father);
103 void set_event(const std::string& value_name);
104 void push_event(const std::string& value_name);
105 void push_event(const std::string& value_name, TIData* extra);
107 void pop_event(TIData* extra);