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 SINGLE_VER_KV_ENTRY_H 17 #define SINGLE_VER_KV_ENTRY_H 18 19 #include <vector> 20 #include "db_types.h" 21 #include "parcel.h" 22 23 namespace DistributedDB { 24 class SingleVerKvEntry { 25 public: ~SingleVerKvEntry()26 virtual ~SingleVerKvEntry() {}; 27 virtual std::string GetOrigDevice() const = 0; 28 virtual void SetOrigDevice(const std::string &device) = 0; 29 virtual Timestamp GetTimestamp() const = 0; 30 virtual void SetTimestamp(Timestamp timestamp) = 0; 31 virtual Timestamp GetWriteTimestamp() const = 0; 32 virtual void SetWriteTimestamp(Timestamp timestamp) = 0; 33 virtual uint64_t GetFlag() const = 0; 34 virtual int SerializeData(Parcel &parcel, uint32_t softWareVersion) = 0; 35 virtual int DeSerializeData(Parcel &parcel) = 0; 36 virtual uint32_t CalculateLen(uint32_t softWareVersion) = 0; 37 virtual const Key &GetKey() const = 0; 38 virtual const Value &GetValue() const = 0; 39 virtual void SetKey(const Key &key) = 0; 40 virtual void SetValue(const Value &value) = 0; 41 virtual void SetHashKey(const Key &hashKey) = 0; 42 Release(std::vector<SingleVerKvEntry * > & entries)43 static void Release(std::vector<SingleVerKvEntry *> &entries) 44 { 45 for (auto &entry : entries) { 46 delete entry; 47 entry = nullptr; 48 } 49 entries.clear(); 50 }; 51 }; 52 } // namespace DistributedDB 53 54 #endif // SINGLE_VER_KV_ENTRY_H 55