BPMN-OS
BPMN for optimization and simulation
Loading...
Searching...
No Matches
Recorder.h
Go to the documentation of this file.
1
#ifndef BPMNOS_Execution_Recorder_H
2
#define BPMNOS_Execution_Recorder_H
3
4
#include <ostream>
5
#include <
bpmn++.h
>
6
#include "
execution/engine/src/Engine.h
"
7
#include "
execution/engine/src/Observer.h
"
8
#include "
model/utility/src/Number.h
"
9
#include <nlohmann/json.hpp>
10
11
namespace
BPMNOS::Execution
{
12
13
namespace
Color {
14
enum
Code
{
15
FG_DEFAULT
= 39,
16
FG_BLACK
= 30,
17
FG_RED
= 31,
18
FG_GREEN
= 32,
19
FG_YELLOW
= 33,
20
FG_BLUE
= 34,
21
FG_MAGENTA
= 35,
22
FG_CYAN
= 36,
23
FG_LIGHT_GRAY
= 37,
24
FG_DARK_GRAY
= 90,
25
FG_LIGHT_RED
= 91,
26
FG_LIGHT_GREEN
= 92,
27
FG_LIGHT_YELLOW
= 93,
28
FG_LIGHT_BLUE
= 94,
29
FG_LIGHT_MAGENTA
= 95,
30
FG_LIGHT_CYAN
= 96,
31
FG_WHITE
= 97,
32
BG_RED
= 41,
33
BG_GREEN
= 42,
34
BG_BLUE
= 44,
35
BG_DEFAULT
= 49
36
};
37
class
Modifier
{
38
Code
code;
39
public
:
40
Modifier
(
Code
pCode) : code(pCode) {}
41
friend
std::ostream&
operator<<
(std::ostream& os,
const
Modifier
& mod) {
42
return
os <<
"\033["
<< mod.code <<
"m"
;
43
}
44
};
45
}
46
47
/**
48
* @brief Class recording all token changes.
49
*/
50
class
Recorder
:
public
Observer
{
51
public
:
52
Recorder
(
size_t
maxSize = std::numeric_limits<size_t>::max());
53
Recorder
(std::ostream &os,
size_t
maxSize = std::numeric_limits<size_t>::max());
54
~Recorder
();
55
56
void
subscribe
(
Engine
* engine);
57
void
notice
(
const
Observable
* observable)
override
;
58
59
BPMNOS::number
objective
;
///< The global objective.
60
nlohmann::ordered_json
log
;
///< A json object of the entire log.
61
/**
62
* @brief Returns a json array containing all log entries matching the include object and not matching the exclude object.
63
*/
64
nlohmann::ordered_json
find
(nlohmann::json include, nlohmann::json exclude = nlohmann::json())
const
;
65
private
:
66
std::optional< std::reference_wrapper<std::ostream> > os;
67
bool
isFirst;
68
size_t
maxSize;
69
};
70
71
}
// namespace BPMNOS::Execution
72
73
#endif
// BPMNOS_Execution_Recorder_H
74
Engine.h
Number.h
Observer.h
bpmn++.h
BPMNOS::Execution::Color::Modifier
Definition
Recorder.h:37
BPMNOS::Execution::Color::Modifier::Modifier
Modifier(Code pCode)
Definition
Recorder.h:40
BPMNOS::Execution::Color::Modifier::operator<<
friend std::ostream & operator<<(std::ostream &os, const Modifier &mod)
Definition
Recorder.h:41
BPMNOS::Execution::Engine
Definition
Engine.h:30
BPMNOS::Execution::Observer
Definition
Observer.h:9
BPMNOS::Execution::Recorder
Class recording all token changes.
Definition
Recorder.h:50
BPMNOS::Execution::Recorder::find
nlohmann::ordered_json find(nlohmann::json include, nlohmann::json exclude=nlohmann::json()) const
Returns a json array containing all log entries matching the include object and not matching the excl...
Definition
Recorder.cpp:97
BPMNOS::Execution::Recorder::log
nlohmann::ordered_json log
A json object of the entire log.
Definition
Recorder.h:60
BPMNOS::Execution::Recorder::subscribe
void subscribe(Engine *engine)
Definition
Recorder.cpp:30
BPMNOS::Execution::Recorder::notice
void notice(const Observable *observable) override
Definition
Recorder.cpp:38
BPMNOS::Execution::Recorder::~Recorder
~Recorder()
Definition
Recorder.cpp:21
BPMNOS::Execution::Recorder::Recorder
Recorder(size_t maxSize=std::numeric_limits< size_t >::max())
Definition
Recorder.cpp:7
BPMNOS::Execution::Recorder::objective
BPMNOS::number objective
The global objective.
Definition
Recorder.h:59
BPMNOS::Execution::Color::Code
Code
Definition
Recorder.h:14
BPMNOS::Execution::Color::FG_WHITE
@ FG_WHITE
Definition
Recorder.h:31
BPMNOS::Execution::Color::FG_RED
@ FG_RED
Definition
Recorder.h:17
BPMNOS::Execution::Color::FG_MAGENTA
@ FG_MAGENTA
Definition
Recorder.h:21
BPMNOS::Execution::Color::FG_LIGHT_YELLOW
@ FG_LIGHT_YELLOW
Definition
Recorder.h:27
BPMNOS::Execution::Color::FG_BLACK
@ FG_BLACK
Definition
Recorder.h:16
BPMNOS::Execution::Color::FG_YELLOW
@ FG_YELLOW
Definition
Recorder.h:19
BPMNOS::Execution::Color::FG_LIGHT_GRAY
@ FG_LIGHT_GRAY
Definition
Recorder.h:23
BPMNOS::Execution::Color::FG_LIGHT_RED
@ FG_LIGHT_RED
Definition
Recorder.h:25
BPMNOS::Execution::Color::FG_CYAN
@ FG_CYAN
Definition
Recorder.h:22
BPMNOS::Execution::Color::FG_BLUE
@ FG_BLUE
Definition
Recorder.h:20
BPMNOS::Execution::Color::FG_GREEN
@ FG_GREEN
Definition
Recorder.h:18
BPMNOS::Execution::Color::FG_DEFAULT
@ FG_DEFAULT
Definition
Recorder.h:15
BPMNOS::Execution::Color::BG_RED
@ BG_RED
Definition
Recorder.h:32
BPMNOS::Execution::Color::FG_LIGHT_BLUE
@ FG_LIGHT_BLUE
Definition
Recorder.h:28
BPMNOS::Execution::Color::BG_BLUE
@ BG_BLUE
Definition
Recorder.h:34
BPMNOS::Execution::Color::FG_LIGHT_CYAN
@ FG_LIGHT_CYAN
Definition
Recorder.h:30
BPMNOS::Execution::Color::BG_GREEN
@ BG_GREEN
Definition
Recorder.h:33
BPMNOS::Execution::Color::FG_LIGHT_MAGENTA
@ FG_LIGHT_MAGENTA
Definition
Recorder.h:29
BPMNOS::Execution::Color::FG_DARK_GRAY
@ FG_DARK_GRAY
Definition
Recorder.h:24
BPMNOS::Execution::Color::FG_LIGHT_GREEN
@ FG_LIGHT_GREEN
Definition
Recorder.h:26
BPMNOS::Execution::Color::BG_DEFAULT
@ BG_DEFAULT
Definition
Recorder.h:35
BPMNOS::Execution
Definition
Controller.h:9
BPMNOS::number
BPMNOS_NUMBER_TYPE number
Definition
Number.h:42
BPMNOS::Execution::Observable
Definition
Observable.h:6