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>
9#include <nlohmann/json.hpp>
10
11namespace BPMNOS::Execution {
12
13namespace Color {
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 */
50class Recorder : public Observer {
51public:
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;
65private:
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
friend std::ostream & operator<<(std::ostream &os, const Modifier &mod)
Definition Recorder.h:41
Class recording all token changes.
Definition Recorder.h:50
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
nlohmann::ordered_json log
A json object of the entire log.
Definition Recorder.h:60
void subscribe(Engine *engine)
Definition Recorder.cpp:30
void notice(const Observable *observable) override
Definition Recorder.cpp:38
Recorder(size_t maxSize=std::numeric_limits< size_t >::max())
Definition Recorder.cpp:7
BPMNOS::number objective
The global objective.
Definition Recorder.h:59
BPMNOS_NUMBER_TYPE number
Definition Number.h:42