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 void set_calling_container(Container* container) { issuer_ = container; }
51 void log_definition(e_event_type event_type);
52 void log_definition(Type* source, Type* dest);
55 class ContainerType : public Type {
57 explicit ContainerType(const std::string& name) : Type(name, name, "", nullptr){};
58 ContainerType(const std::string& name, Type* father);
61 class VariableType : public Type {
62 std::vector<VariableEvent*> events_;
64 VariableType(const std::string& name, const std::string& color, Type* father);
65 void instr_event(double now, double delta, const char* resource, double value);
66 void set_event(double timestamp, double value);
67 void add_event(double timestamp, double value);
68 void sub_event(double timestamp, double value);
71 class ValueType : public Type {
73 std::map<std::string, EntityValue> values_;
74 ValueType(const std::string& name, const std::string& alias, Type* father) : Type(name, alias, "", father){};
75 ValueType(const std::string& name, Type* father) : Type(name, name, "", father){};
76 virtual ~ValueType() = default;
77 void add_entity_value(const std::string& name, const std::string& color);
78 void add_entity_value(const std::string& name);
79 EntityValue* get_entity_value(const std::string& name);
82 class LinkType : public ValueType {
84 LinkType(const std::string& name, const std::string& alias, Type* father);
85 void start_event(Container* startContainer, const std::string& value, const std::string& key);
86 void start_event(Container* startContainer, const std::string& value, const std::string& key, int size);
87 void end_event(Container* endContainer, const std::string& value, const std::string& key);
90 class EventType : public ValueType {
92 EventType(const std::string& name, Type* father);
95 class StateType : public ValueType {
96 std::vector<StateEvent*> events_;
98 StateType(const std::string& name, Type* father);
99 void set_event(const std::string& value_name);
100 void push_event(const std::string& value_name);
101 void push_event(const std::string& value_name, TIData* extra);
103 void pop_event(TIData* extra);