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_TARGET_H
17 #define SYNC_TARGET_H
18 
19 #include "isync_target.h"
20 
21 namespace DistributedDB {
22 class SyncTarget : public ISyncTarget {
23 public:
SyncTarget()24     SyncTarget() : operation_(nullptr), taskType_(0), mode_(0) {};
25     ~SyncTarget() override;
26 
27     // Get the Sync Id of this task
28     int GetSyncId() const override;
29 
30     // Set the type of this task request or response
31     void SetTaskType(int taskType) override;
32 
33     // Get the type of this task request or response
34     int GetTaskType() const override;
35 
36     // Set the mode of this task request or response
37     void SetMode(int mode) override;
38 
39     // Get the mode of this task request or response
40     int GetMode() const override;
41 
42     // Set a SyncOperation
43     void SetSyncOperation(SyncOperation *operation) override;
44 
45     // Get a SyncOperation
46     void GetSyncOperation(SyncOperation *&operation) const override;
47 
48     // Is this target is an auto sync
49     bool IsAutoSync() const override;
50 
51     uint32_t GetResponseSessionId() const override;
52 
53 protected:
54     SyncOperation *operation_;
55     int taskType_; // sync task or response task;
56     int mode_;
57 };
58 } // namespace DistributedDB
59 
60 #endif // SYNC_TARGET_H
61