1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef GENERIC_MULTI_VER_KVENTRY_H
17 #define GENERIC_MULTI_VER_KVENTRY_H
18 
19 #ifndef OMIT_MULTI_VER
20 #include <cstdint>
21 #include <vector>
22 
23 #include "macro_utils.h"
24 #include "multi_ver_kv_entry.h"
25 #include "multi_ver_value_object.h"
26 
27 namespace DistributedDB {
28 class GenericMultiVerKvEntry : public MultiVerKvEntry {
29 public:
30     GenericMultiVerKvEntry();
31     ~GenericMultiVerKvEntry() override;
32     DISABLE_COPY_ASSIGN_MOVE(GenericMultiVerKvEntry);
33 
34     int GetSerialData(std::vector<uint8_t> &data) const override;
35 
36     int GetValueHash(std::vector<ValueSliceHash> &valueHashes) const override;
37 
38     void GetTimestamp(uint64_t &timestamp) const override;
39     void SetTimestamp(uint64_t timestamp) override;
40 
41     void GetOriTimestamp(uint64_t &oriTimestamp) const;
42     void SetOriTimestamp(uint64_t oriTimestamp);
43 
44     int DeSerialData(const std::vector<uint8_t> &data);
45 
46     int SetKey(const Key &key);
47     int GetKey(Key &key) const;
48 
49     int SetValue(const Value &value);
50     int GetValue(Value &value) const;
51 
52     void SetOperFlag(uint64_t flag);
53     void GetOperFlag(uint64_t &flag) const;
54 
55     void SetDataLength(uint32_t length);
56     uint32_t GetDataLength() const;
57 
58 private:
59     std::vector<uint8_t> key_;
60     MultiVerValueObject valueObject_;
61     uint64_t operFlag_;
62     uint64_t timestamp_;
63     uint64_t oriTimestamp_;
64 };
65 } // namespace DistributedDB
66 
67 #endif // GENERIC_MULTI_VER_KVENTRY_H
68 #endif