-
Notifications
You must be signed in to change notification settings - Fork 4
/
feedback.h
99 lines (87 loc) · 1.86 KB
/
feedback.h
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/**
* Feedback.h
*
* Interface that is implemented by all the possible feedback channels
*
* @author Emiel Bruijntjes <[email protected]>
* @copyright 2015 - 2016 Copernica BV
*/
/**
* Include guard
*/
#pragma once
/**
* Dependencies
*/
#include <amqpcpp.h>
/**
* Class definition
*/
class Feedback
{
public:
/**
* Interface implemented by a queue-owner
*/
class Owner
{
public:
/**
* Called when result comes in
* @param queue
* @param buffer
* @param size
*/
virtual void onReceived(Feedback *queue, const char *buffer, size_t size) = 0;
/**
* Called in case of an error
* @param queue
* @param message
*/
virtual void onError(Feedback *queue, const char *message) = 0;
};
protected:
/**
* Pointer to the owner
* @var Owner
*/
Owner *_owner;
/**
* Is the object ready
* @var bool
*/
bool _ready = false;
/**
* Protected constructor
* @param owner Object that will be notified with the result
*/
Feedback(Owner *owner) : _owner(owner) {}
public:
/**
* Destructor
*/
virtual ~Feedback() = default;
/**
* Start consuming data from the temporary queue
*/
virtual void wait() = 0;
/**
* The tcp channel that is handling incoming results
* @return TcpHandler
*/
virtual TcpHandler *handler() = 0;
/**
* Name of the feedback channel
* @todo this should be changed into an "address" property
*/
virtual const std::string &name() const = 0;
/**
* Is the result already available?
* @return bool
*/
bool ready() const
{
// this is stored in a member
return _ready;
}
};