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

#include "documentmessage.h"
#include <vespa/document/base/documentid.h>

namespace documentapi {

class GetDocumentMessage : public DocumentMessage {
private:
    document::DocumentId _documentId; // The identifier of the document to retrieve.
    string               _fieldSet; // Comma-separated list of fields to return

protected:
    DocumentReply::UP doCreateReply() const override;

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

    /**
     * Constructs a new message for deserialization.
     */
    GetDocumentMessage();

    /**
     * Constructs a new document get message.
     *
     * @param documentId The identifier of the document to retrieve.
     */
    explicit GetDocumentMessage(const document::DocumentId &documentId);

    /**
     * Constructs a new document get message.
     *
     * @param documentId The identifier of the document to retrieve.
     * @param fieldSet The fields to retrieve (comma-separated)
     */
    GetDocumentMessage(const document::DocumentId &documentId, vespalib::stringref fieldSet);

    ~GetDocumentMessage();

    /**
     * Returns the identifier of the document to retrieve.
     *
     * @return The document id.
     */
    const document::DocumentId &getDocumentId() const;

    /**
     * Sets the identifier of the document to retrieve.
     *
     * @param documentId The document id to set.
     */
    void setDocumentId(const document::DocumentId &documentId);

    /**
     * Returns the fields to be retrieved by the get.
     */
    const string& getFieldSet() const { return _fieldSet; }

    uint32_t getType() const override;
    string toString() const override { return "getdocumentmessage"; }
};

}