blob: 2b48342d21cf84188ad640d6c3b33380b662037f (
plain) (
blame)
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "imessagehandler.h"
#include "ireplyhandler.h"
#include "common.h"
namespace mbus {
/**
* To facilitate several configuration parameters to the {@link MessageBus#createIntermediateSession(MessageHandler,
* ReplyHandler, IntermediateSessionParams)}, all parameters are held by this class. This class has reasonable default
* values for each parameter.
*
* @author Simon Thoresen Hult
* @version $Id$
*/
class IntermediateSessionParams {
private:
string _name;
bool _broadcastName;
IMessageHandler *_msgHandler;
IReplyHandler *_replyHandler;
public:
/**
* Constructs a new instance of this class with default values.
*/
IntermediateSessionParams();
/**
* Returns the name to register with message bus.
*
* @return The name.
*/
const string &getName() const { return _name; }
/**
* Sets the name to register with message bus.
*
* @param name The name to set.
* @return This, to allow chaining.
*/
IntermediateSessionParams &setName(const string &name) { _name = name; return *this; }
/**
* Returns whether or not to broadcast the name of this session on the network.
*
* @return True to broadcast, false otherwise.
*/
bool getBroadcastName() const { return _broadcastName; }
/**
* Sets whether or not to broadcast the name of this session on the network.
*
* @param broadcastName True to broadcast, false otherwise.
* @return This, to allow chaining.
*/
IntermediateSessionParams &setBroadcastName(bool broadcastName) { _broadcastName = broadcastName; return *this; }
/**
* Returns the handler to receive incoming replies. If you call this method without first assigning a
* reply handler to this object, you wil de-ref null.
*
* @return The handler.
*/
IReplyHandler &getReplyHandler() const { return *_replyHandler; }
/**
* Sets the handler to receive incoming replies.
*
* @param handler The handler to set.
* @return This, to allow chaining.
*/
IntermediateSessionParams &setReplyHandler(IReplyHandler &handler) { _replyHandler = &handler; return *this; }
/**
* Returns the handler to receive incoming messages. If you call this method without first assigning a
* message handler to this object, you wil de-ref null.
*
* @return The handler.
*/
IMessageHandler &getMessageHandler() const { return *_msgHandler; }
/**
* Sets the handler to receive incoming messages.
*
* @param handler The handler to set.
* @return This, to allow chaining.
*/
IntermediateSessionParams &setMessageHandler(IMessageHandler &handler) { _msgHandler = &handler; return *this; }
};
} // namespace mbus
|