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 MULTI_VER_SYNCER_H
17 #define MULTI_VER_SYNCER_H
18 
19 #ifndef OMIT_MULTI_VER
20 #include "generic_syncer.h"
21 #include "macro_utils.h"
22 
23 namespace DistributedDB {
24 class MultiVerSyncer final : public GenericSyncer {
25 public:
26     MultiVerSyncer();
27     ~MultiVerSyncer() override;
28 
29     // Enable auto sync function
30     void EnableAutoSync(bool enable) override;
31 
32     // delete specified device's watermark
33     int EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash) override;
34 
35     // delete specified device's and table's watermark
36     int EraseDeviceWaterMark(const std::string &deviceId, bool isNeedHash,
37         const std::string &tableName) override;
38 
39     // Local data changed callback
40     void LocalDataChanged(int notifyEvent) override;
41 
42     // Remote data changed callback
43     void RemoteDataChanged(const std::string &device) override;
44 
45     void RemoteDeviceOffline(const std::string &device) override;
46 
47     // Set stale data wipe policy
48     int SetStaleDataWipePolicy(WipePolicy policy) override;
49 
50 protected:
51     // Create a sync engine, if has memory error, will return nullptr.
52     ISyncEngine *CreateSyncEngine() override;
53 
54     // Add a Sync Operation, after call this function, the operation will be start
55     void AddSyncOperation([[gnu::unused]] ISyncEngine *engine, SyncOperation *operation) override;
56 
57     // Used to set to the SyncOperation Onkill
58     void SyncOperationKillCallbackInner(int syncId) override;
59 
60 private:
61     bool autoSyncEnable_;
62 };
63 } // namespace DistributedDB
64 
65 #endif // MULTI_VER_SYNCER_H
66 #endif