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 DELEGATE_CALLBACK_H 16 #define DELEGATE_CALLBACK_H 17 #include "kv_store_snapshot_delegate.h" 18 #include "types_export.h" 19 20 // DelegateCallback conclude the Callback implements of function< void(DBStatus, KvStoreSnapshotDelegate*)> 21 class DelegateCallback { 22 public: DelegateCallback()23 DelegateCallback() {} ~DelegateCallback()24 ~DelegateCallback() {} 25 26 // Delete the copy and assign constructors 27 DelegateCallback(const DelegateCallback &callback) = delete; 28 DelegateCallback& operator=(const DelegateCallback &callback) = delete; 29 DelegateCallback(DelegateCallback &&callback) = delete; 30 DelegateCallback& operator=(DelegateCallback &&callback) = delete; 31 32 void Callback(DistributedDB::DBStatus status, DistributedDB::KvStoreSnapshotDelegate *kvStoreSnapshotDelegate); 33 void CallbackKv(DistributedDB::DBStatus status, const DistributedDB::Value &value); 34 35 DistributedDB::DBStatus GetStatus(); 36 const DistributedDB::Value &GetValue(); 37 GetKvStoreSnapshot()38 const DistributedDB::KvStoreSnapshotDelegate *GetKvStoreSnapshot() 39 { 40 return kvStoreSnapshotDelegate_; 41 } 42 43 private: 44 DistributedDB::DBStatus status_ = DistributedDB::DBStatus::INVALID_ARGS; 45 DistributedDB::Value value_ = {}; 46 DistributedDB::KvStoreSnapshotDelegate *kvStoreSnapshotDelegate_ = nullptr; 47 }; 48 49 #endif // DELEGATE_CALLBACK_H