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 #ifndef RELATIONAL_STORE_DELEGATE_IMPL_H 16 #define RELATIONAL_STORE_DELEGATE_IMPL_H 17 #ifdef RELATIONAL_STORE 18 19 #include "macro_utils.h" 20 #include "relational_store_connection.h" 21 22 namespace DistributedDB { 23 class RelationalStoreDelegateImpl final : public RelationalStoreDelegate { 24 public: 25 RelationalStoreDelegateImpl() = default; 26 ~RelationalStoreDelegateImpl() override; 27 28 RelationalStoreDelegateImpl(RelationalStoreConnection *conn, const std::string &path); 29 30 DISABLE_COPY_ASSIGN_MOVE(RelationalStoreDelegateImpl); 31 32 DBStatus Sync(const std::vector<std::string> &devices, SyncMode mode, 33 const Query &query, const SyncStatusCallback &onComplete, bool wait) override; 34 35 DBStatus RemoveDeviceData(const std::string &device) override; 36 37 DBStatus CreateDistributedTable(const std::string &tableName) override; 38 39 DBStatus RemoveDeviceData(const std::string &device, const std::string &tableName) override; 40 41 // For connection 42 DBStatus Close(); 43 44 void SetReleaseFlag(bool flag); 45 46 DBStatus RemoteQuery(const std::string &device, const RemoteCondition &condition, uint64_t timeout, 47 std::shared_ptr<ResultSet> &result) override; 48 49 DBStatus RemoveDeviceData() override; 50 private: 51 static void OnSyncComplete(const std::map<std::string, std::vector<TableStatus>> &devicesStatus, 52 const SyncStatusCallback &onComplete); 53 54 RelationalStoreConnection *conn_ = nullptr; 55 std::string storePath_; 56 std::atomic<bool> releaseFlag_ = false; 57 }; 58 } // namespace DistributedDB 59 #endif 60 #endif // RELATIONAL_STORE_DELEGATE_IMPL_H