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 #include "sync_target.h" 17 18 #include "db_errno.h" 19 #include "sync_operation.h" 20 #include "log_print.h" 21 22 namespace DistributedDB { ~SyncTarget()23SyncTarget::~SyncTarget() 24 { 25 operation_ = nullptr; 26 } 27 GetSyncId() const28int SyncTarget::GetSyncId() const 29 { 30 if (operation_ == nullptr) { 31 return 0; 32 } 33 return operation_->GetSyncId(); 34 } 35 SetTaskType(int taskType)36void SyncTarget::SetTaskType(int taskType) 37 { 38 taskType_ = taskType; 39 } 40 GetTaskType() const41int SyncTarget::GetTaskType() const 42 { 43 return taskType_; 44 } 45 SetMode(int mode)46void SyncTarget::SetMode(int mode) 47 { 48 mode_ = mode; 49 } 50 GetMode() const51int SyncTarget::GetMode() const 52 { 53 return mode_; 54 } 55 SetSyncOperation(SyncOperation * operation)56void SyncTarget::SetSyncOperation(SyncOperation *operation) 57 { 58 if ((operation != nullptr) && !operation->IsKilled()) { 59 operation_ = operation; 60 mode_ = operation->GetMode(); 61 taskType_ = REQUEST; 62 } 63 operation_ = operation; 64 } 65 GetSyncOperation(SyncOperation * & operation) const66void SyncTarget::GetSyncOperation(SyncOperation *&operation) const 67 { 68 if (operation_ == nullptr) { 69 LOGD("GetSyncOperation is nullptr"); 70 } 71 operation = operation_; 72 } 73 IsAutoSync() const74bool SyncTarget::IsAutoSync() const 75 { 76 if (operation_ == nullptr) { 77 return false; 78 } 79 return operation_->IsAutoSync(); 80 } 81 GetResponseSessionId() const82uint32_t SyncTarget::GetResponseSessionId() const 83 { 84 return 0; 85 } 86 } // namespace DistributedDB 87 88