1 /* 2 * Copyright (C) 2024 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 OHOS_MEDIA_CLOUD_SYNC_RESULT_H 16 #define OHOS_MEDIA_CLOUD_SYNC_RESULT_H 17 18 #include "mdk_error.h" 19 20 namespace OHOS::Media::CloudSync { 21 #define EXPORT __attribute__ ((visibility ("default"))) 22 class EXPORT MDKResult { 23 public: 24 // 返回结果是否成功 IsSuccess()25 bool IsSuccess() const 26 { 27 if (error_.HasError()) { 28 return false; 29 } 30 return true; 31 } SetDKError(MDKError error)32 void SetDKError(MDKError error) 33 { 34 error_ = error; 35 } GetDKError()36 MDKError GetDKError() const 37 { 38 return error_; 39 } 40 41 protected: 42 MDKError error_; 43 }; 44 45 class EXPORT MDKRecordOperResult : public MDKResult { 46 public: MDKRecordOperResult()47 MDKRecordOperResult() 48 {} MDKRecordOperResult(MDKLocalErrorCode code)49 MDKRecordOperResult(MDKLocalErrorCode code) 50 { 51 error_.SetLocalError(code); 52 } 53 54 public: SetDKRecord(const MDKRecord & record)55 void SetDKRecord(const MDKRecord &record) 56 { 57 record_ = record; 58 } GetDKRecord()59 MDKRecord GetDKRecord() const 60 { 61 return record_; 62 } 63 64 private: 65 MDKRecord record_; 66 }; 67 } // namespace OHOS::Media::CloudSync 68 #endif