Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
drand48 is not used anymore; stop using srand48.
[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   std::unique_ptr<TIData> extra_;
74
75 public:
76   StateEvent(Container* container, Type* type, e_event_type event_type, EntityValue* value, TIData* extra);
77   void print() override;
78 };
79
80 class LinkEvent : public PajeEvent {
81   Container* endpoint_;
82   std::string value_;
83   std::string key_;
84   int size_ = -1;
85
86 public:
87   LinkEvent(Container* container, Type* type, e_event_type event_type, Container* sourceContainer,
88             const std::string& value, const std::string& key, int size)
89       : PajeEvent(container, type, SIMIX_get_clock(), event_type)
90       , endpoint_(sourceContainer)
91       , value_(value)
92       , key_(key)
93       , size_(size)
94   {
95   }
96   void print() override;
97 };
98
99 class NewEvent : public PajeEvent {
100   EntityValue* value;
101
102 public:
103   NewEvent(double timestamp, Container* container, Type* type, EntityValue* value)
104       : simgrid::instr::PajeEvent::PajeEvent(container, type, timestamp, PAJE_NewEvent), value(value)
105   {
106   }
107   void print() override;
108 };
109 }
110 }
111 #endif