aboutsummaryrefslogtreecommitdiffstats
path: root/documentapi/src/vespa/documentapi/messagebus/messages/documentreply.h
blob: d005971f61b6d03b22a3400dbf13ba7c95afa8f2 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <vespa/messagebus/reply.h>
#include <vespa/documentapi/messagebus/priority.h>

namespace documentapi {

/**
 * This class implements a generic document protocol reply that can be reused by document messages that require no
 * special reply implementation while still allowing applications to distinguish between types.
 */
class DocumentReply : public mbus::Reply {
private:
    uint32_t _type;
    Priority::Value _priority;

public:
    /**
     * Convenience typedef.
     */
    using UP = std::unique_ptr<DocumentReply>;
    using SP = std::shared_ptr<DocumentReply>;

    /**
     * Constructs a new reply of given type.
     *
     * @param type The type code to assign to this.
     */
    DocumentReply(uint32_t type);

    /**
     * Virtual destructor required for inheritance.
     */
    ~DocumentReply() override;

    /**
     * Returns the priority tag for this message. This is an optional tag added for VDS that is not interpreted by the
     * document protocol.
     *
     * @return The priority.
     */
    Priority::Value getPriority() const { return _priority; }
    uint8_t priority() const override { return (uint8_t)_priority; }

    /**
     * Sets the priority tag for this message.
     *
     * @param priority The priority to set.
     */
    void setPriority(Priority::Value p) { _priority = p; }
    const mbus::string& getProtocol() const override;
    uint32_t getType() const override { return _type; }
};

}