-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathconsole_printer_udl.cpp
More file actions
60 lines (49 loc) · 1.85 KB
/
console_printer_udl.cpp
File metadata and controls
60 lines (49 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <cascade/user_defined_logic_interface.hpp>
#include <iostream>
namespace derecho{
namespace cascade{
#define MY_UUID "48e60f7c-8500-11eb-8755-0242ac110002"
#define MY_DESC "Demo DLL UDL that printing what ever received on console."
std::string get_uuid() {
return MY_UUID;
}
std::string get_description() {
return MY_DESC;
}
class ConsolePrinterOCDPO: public OffCriticalDataPathObserver {
virtual void operator () (const derecho::node_id_t sender,
const std::string& key_string,
const uint32_t prefix_length,
persistent::version_t version,
const mutils::ByteRepresentable* const value_ptr,
const std::unordered_map<std::string,bool>& outputs,
ICascadeContext* ctxt,
uint32_t worker_id) override {
std::cout << "[console printer ocdpo]: I(" << worker_id << ") received an object from sender:" << sender << " with key=" << key_string
<< ", matching prefix=" << key_string.substr(0,prefix_length) << std::endl;
}
static std::shared_ptr<OffCriticalDataPathObserver> ocdpo_ptr;
public:
static void initialize() {
if(!ocdpo_ptr) {
ocdpo_ptr = std::make_shared<ConsolePrinterOCDPO>();
}
}
static auto get() {
return ocdpo_ptr;
}
};
std::shared_ptr<OffCriticalDataPathObserver> ConsolePrinterOCDPO::ocdpo_ptr;
void initialize(ICascadeContext* ctxt) {
ConsolePrinterOCDPO::initialize();
}
std::shared_ptr<OffCriticalDataPathObserver> get_observer(
ICascadeContext*,const nlohmann::json&) {
return ConsolePrinterOCDPO::get();
}
void release(ICascadeContext* ctxt) {
// nothing to release
return;
}
} // namespace cascade
} // namespace derecho