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 I_SYNC_INTERFACE_H
17 #define I_SYNC_INTERFACE_H
18 
19 #include <string>
20 
21 #include "db_types.h"
22 #include "kvdb_properties.h"
23 
24 namespace DistributedDB {
25 class ISyncInterface {
26 public:
27     enum {
28         SYNC_SVD = 1,   // Single version data
29         SYNC_MVD,       // Multi version data
30         SYNC_RELATION,  // Relation version data
31     };
32 
33     // Constructor/Destructor.
34     ISyncInterface() = default;
35     virtual ~ISyncInterface() = default;
36 
37     // Get interface type of this kvdb.
38     virtual int GetInterfaceType() const = 0;
39 
40     // Get the interface ref-count, in order to access asynchronously.
41     virtual void IncRefCount() = 0;
42 
43     // Drop the interface ref-count.
44     virtual void DecRefCount() = 0;
45 
46     // Get the identifier of this kvdb.
47     virtual std::vector<uint8_t> GetIdentifier() const = 0;
48     // Get the dual tuple identifier of this kvdb.
49     virtual std::vector<uint8_t> GetDualTupleIdentifier() const = 0;
50 
51     // Get the max timestamp of all entries in database.
52     virtual void GetMaxTimestamp(Timestamp &stamp) const = 0;
53 
54     // Get meta data associated with the given key.
55     virtual int GetMetaData(const Key &key, Value &value) const = 0;
56 
57     // Put meta data as a key-value entry.
58     virtual int PutMetaData(const Key &key, const Value &value, bool isInTransaction) = 0;
59 
60     // Delete multiple meta data records in a transaction.
61     virtual int DeleteMetaData(const std::vector<Key> &keys) = 0;
62 
63     // Delete multiple meta data records with key prefix in a transaction.
64     virtual int DeleteMetaDataByPrefixKey(const Key &keyPrefix) const = 0;
65 
66     // Get all meta data keys.
67     virtual int GetAllMetaKeys(std::vector<Key> &keys) const = 0;
68 
69     virtual const DBProperties &GetDbProperties() const = 0;
70 
71     virtual int GetSecurityOption(SecurityOption &option) const = 0;
72 
73     virtual int IsSupportSubscribe() const = 0;
74 };
75 } // namespace DistributedDB
76 
77 #endif // I_SYNC_INTERFACE_H