Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid into CRTP
[simgrid.git] / src / instr / instr_paje_events.hpp
1 /* Copyright (c) 2010-2019. 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_EVENTS_HPP
7 #define INSTR_PAJE_EVENTS_HPP
8
9 #include "src/instr/instr_private.hpp"
10 #include "src/internal_config.h"
11 #include <sstream>
12 #include <string>
13
14 namespace simgrid {
15 namespace instr {
16 class EntityValue;
17 class TIData;
18
19 enum e_event_type : unsigned int {
20   PAJE_DefineContainerType,
21   PAJE_DefineVariableType,
22   PAJE_DefineStateType,
23   PAJE_DefineEventType,
24   PAJE_DefineLinkType,
25   PAJE_DefineEntityValue,
26   PAJE_CreateContainer,
27   PAJE_DestroyContainer,
28   PAJE_SetVariable,
29   PAJE_AddVariable,
30   PAJE_SubVariable,
31   PAJE_SetState,
32   PAJE_PushState,
33   PAJE_PopState,
34   PAJE_ResetState,
35   PAJE_StartLink,
36   PAJE_EndLink,
37   PAJE_NewEvent
38 };
39
40 class PajeEvent {
41   Container* container_;
42   Type* type_;
43 protected:
44   Container* get_container() { return container_; }
45 public:
46   double timestamp_;
47   e_event_type eventType_;
48   std::stringstream stream_;
49
50   PajeEvent(Container* container, Type* type, double timestamp, e_event_type eventType);
51   virtual ~PajeEvent() = default;
52   virtual void print();
53   void insert_into_buffer();
54 };
55
56 class VariableEvent : public PajeEvent {
57   double value_;
58
59 public:
60   VariableEvent(double timestamp, Container* container, Type* type, e_event_type event_type, double value)
61       : PajeEvent::PajeEvent(container, type, timestamp, event_type), value_(value)
62   {
63   }
64   void print() override;
65 };
66
67 class StateEvent : public PajeEvent {
68   EntityValue* value;
69 #if HAVE_SMPI
70   std::string filename = "(null)";
71   int linenumber       = -1;
72 #endif
73   TIData* extra_;
74
75 public:
76   StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
77   ~StateEvent();
78   void print() override;
79 };
80
81 class LinkEvent : public PajeEvent {
82   Container* endpoint_;
83   std::string value_;
84   std::string key_;
85   int size_ = -1;
86
87 public:
88   LinkEvent(Container* container, Type* type, e_event_type event_type, Container* sourceContainer,
89             const std::string& value, const std::string& key, int size)
90       : PajeEvent(container, type, SIMIX_get_clock(), event_type)
91       , endpoint_(sourceContainer)
92       , value_(value)
93       , key_(key)
94       , size_(size)
95   {
96   }
97   void print() override;
98 };
99
100 class NewEvent : public PajeEvent {
101   EntityValue* value;
102
103 public:
104   NewEvent(double timestamp, Container* container, Type* type, EntityValue* value)
105       : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent), value(value)
106   {
107   }
108   void print() override;
109 };
110 }
111 }
112 #endif