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

#pragma once

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

namespace document {
    class ByteBuffer;
}
namespace vespalib {
    class GrowableByteBuffer;
}

namespace documentapi {

class DocumentState {
    std::unique_ptr<document::DocumentId> _docId;
    document::GlobalId _gid;
    uint64_t _timestamp;
    bool _removeEntry;

public:
    DocumentState();
    DocumentState(const DocumentState&);
    DocumentState(const document::DocumentId&,
                  uint64_t timestamp, bool removeEntry);
    DocumentState(const document::GlobalId&,
                  uint64_t timestamp, bool removeEntry);
    DocumentState(document::ByteBuffer &buf);

    DocumentState& operator=(const DocumentState&);
    
    void serialize(vespalib::GrowableByteBuffer &buf) const;

    const document::GlobalId& getGlobalId() const { return _gid; }
    const document::DocumentId* getDocumentId() const { return _docId.get(); }
    uint64_t getTimestamp() const { return _timestamp; }
    bool isRemoveEntry() const { return _removeEntry; }
};

} // documentapi