1 /* Copyright (c) 2010-2019. 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"
26 std::map<std::string, Type*> children_;
27 Container* issuer_ = nullptr;
28 std::stringstream stream_;
30 Type(const std::string& name, const std::string& alias, const std::string& color, Type* father);
33 const std::string& get_name() const { return name_; }
34 const char* get_cname() { return name_.c_str(); }
35 long long int get_id() { return id_; }
36 bool is_colored() { return not color_.empty(); }
38 Type* by_name(const std::string& name);
39 LinkType* by_name_or_create(const std::string& name, Type* source, Type* dest);
40 VariableType* by_name_or_create(const std::string& name, const std::string& color);
42 template <class T> T* by_name_or_create(const std::string& name)
44 auto cont = children_.find(name);
45 return cont == children_.end() ? new T(name, this) : static_cast<T*>(cont->second);
48 void set_calling_container(Container* container) { issuer_ = container; }
50 void log_definition(e_event_type event_type);
51 void log_definition(Type* source, Type* dest);
54 class ContainerType : public Type {
56 explicit ContainerType(const std::string& name) : Type(name, name, "", nullptr){};
57 ContainerType(const std::string& name, Type* father);
60 class VariableType : public Type {
61 std::vector<VariableEvent*> events_;
63 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){};
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);
100 void set_event(const std::string& value_name);
101 void push_event(const std::string& value_name);
102 void push_event(const std::string& value_name, TIData* extra);
104 void pop_event(TIData* extra);