• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 RELATIONAL_STORE_DELEGATE_H
17 #define RELATIONAL_STORE_DELEGATE_H
18 
19 #include <map>
20 #include <memory>
21 #include "distributeddb/result_set.h"
22 #include "query.h"
23 #include "store_types.h"
24 #include "store_observer.h"
25 
26 namespace DistributedDB {
27 class RelationalStoreDelegate {
28 public:
29     DB_API virtual ~RelationalStoreDelegate() = default;
30 
31     struct Option {
32         StoreObserver *observer = nullptr;
33         // communicator label use dualTuple hash or not;
34         bool syncDualTupleMode = false;
35         bool isEncryptedDb = false;
36         CipherType cipher = CipherType::DEFAULT;
37         CipherPassword passwd;
38         uint32_t iterateTimes = 0;
39     };
40 
41     DB_API virtual DBStatus CreateDistributedTable(const std::string &tableName) = 0;
42 
43     DB_API virtual DBStatus Sync(const std::vector<std::string> &devices, SyncMode mode,
44         const Query &query, const SyncStatusCallback &onComplete, bool wait) = 0;
45 
46     DB_API virtual DBStatus RemoveDeviceData(const std::string &device) = 0;
47 
48     DB_API virtual DBStatus RemoveDeviceData(const std::string &device, const std::string &tableName) = 0;
49 
50     // timeout is in ms.
51     DB_API virtual DBStatus RemoteQuery(const std::string &device, const RemoteCondition &condition,
52         uint64_t timeout, std::shared_ptr<ResultSet> &result) = 0;
53 };
54 } // namespace DistributedDB
55 #endif // RELATIONAL_STORE_DELEGATE_H