Logo AND Algorithmique Numérique Distribuée

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