aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/vespa/messagebus/protocolset.h
blob: f8ab1cab055880a13717043002d987ff3ca1e54e (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <memory>
#include <vector>
#include "iprotocol.h"

namespace mbus {

/**
 * This class is used to bundle a set of IProtocol objects to be
 * supported by a MessageBus instance.
 **/
class ProtocolSet
{
private:
    std::vector<IProtocol::SP> _vector;

public:
    /**
     * Create an empty ProtocolSet.
     **/
    ProtocolSet();

    /**
     * Add a Protocol to this set.
     *
     * @return this object, to allow chaining
     * @param protocol the IProtocol we want to add
     **/
    ProtocolSet &add(IProtocol::SP protocol);

    /**
     * Check if this set is empty
     *
     * @return true if this set is empty
     **/
    bool empty() const;

    /**
     * Extract a single protocol from this set. This will remove the
     * protocol from the set. If the set is empty, a shared pointer to
     * 0 will be returned.
     *
     * @return the extracted IProtocol
     **/
    IProtocol::SP extract();
};

} // namespace mbus