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 OHOS_AAFWK_WANT_PARAMS_WRAPPER_H 16 #define OHOS_AAFWK_WANT_PARAMS_WRAPPER_H 17 #include "ohos/aafwk/base/base_def.h" 18 #include "ohos/aafwk/base/base_object.h" 19 #include "ohos/aafwk/content/want_params.h" 20 namespace OHOS { 21 namespace AAFwk { 22 class WantParams; 23 INTERFACE(IWantParams, a75b9db6 - 9813 - 4371 - 8848 - d2966ce6ec68) 24 { Query(IInterface * object)25 inline static IWantParams *Query(IInterface * object) 26 { 27 if (object == nullptr) { 28 return nullptr; 29 } 30 return static_cast<IWantParams *>(object->Query(g_IID_IWantParams)); 31 } 32 33 virtual ErrCode GetValue(WantParams & value) = 0; 34 }; 35 class WantParamWrapper final : public Object, public IWantParams { 36 public: WantParamWrapper(const WantParams & value)37 inline WantParamWrapper(const WantParams &value) : wantParams_(value) 38 {} 39 ~WantParamWrapper()40 inline ~WantParamWrapper() 41 {} 42 43 IINTERFACE_DECL(); 44 45 ErrCode GetValue(WantParams &value) override; 46 47 bool Equals(IObject &other) override; 48 49 std::string ToString() override; 50 51 static sptr<IWantParams> Box(const WantParams &value); 52 53 static WantParams Unbox(IWantParams *object); 54 55 static bool ValidateStr(const std::string &str); 56 57 static sptr<IWantParams> Parse(const std::string &str); 58 59 static WantParams ParseWantParams(const std::string &str); 60 61 static constexpr char SIGNATURE = 'W'; 62 63 private: 64 WantParams wantParams_; 65 }; 66 } // namespace AAFwk 67 } // namespace OHOS 68 #endif // OHOS_AAFWK_WANT_PARAMS_WRAPPER_H