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 SYNC_ABLE_ENGINE_H 17 #define SYNC_ABLE_ENGINE_H 18 19 #include <memory.h> 20 21 #include "ref_object.h" 22 #include "syncer_proxy.h" 23 24 namespace DistributedDB { 25 class SyncAbleEngine final { 26 public: 27 explicit SyncAbleEngine(ISyncInterface *store); 28 ~SyncAbleEngine(); 29 void TriggerSync(int notifyEvent); 30 31 // Start a sync action. 32 int Sync(const ISyncer::SyncParma &parm); 33 34 void WakeUpSyncer(); 35 void Close(); 36 37 // Enable auto sync 38 void EnableAutoSync(bool enable); 39 40 int EnableManualSync(void); 41 int DisableManualSync(void); 42 43 // Stop a sync action in progress. 44 void StopSync(int syncId); 45 46 // Get The current virtual timestamp 47 uint64_t GetTimeStamp(); 48 49 int EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash, const std::string &tableName = ""); 50 51 int GetLocalIdentity(std::string &outTarget); 52 53 private: 54 // Start syncer 55 void StartSyncer(); 56 57 // Stop syncer 58 void StopSyncer(); 59 60 SyncerProxy syncer_; // use for sync Interactive 61 std::atomic<bool> started_; 62 ISyncInterface *store_; 63 }; 64 } // namespace DistributedDB 65 #endif // SYNC_ABLE_ENGINE_H