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 16 #ifndef META_SRC_CALL_CONTEXT_H 17 #define META_SRC_CALL_CONTEXT_H 18 19 #include <base/containers/vector.h> 20 21 #include <meta/interface/intf_call_context.h> 22 #include <meta/interface/intf_cloneable.h> 23 #include <meta/interface/object_macros.h> 24 META_BEGIN_NAMESPACE()25META_BEGIN_NAMESPACE() 26 27 class DefaultCallContext : public ICallContext, protected ICloneable { 28 META_IMPLEMENT_REF_COUNT() 29 public: 30 ~DefaultCallContext() override; 31 DefaultCallContext(); 32 DefaultCallContext(const DefaultCallContext& other) noexcept; 33 DefaultCallContext(DefaultCallContext&& other) noexcept; 34 35 DefaultCallContext& operator=(const DefaultCallContext& other) noexcept; 36 DefaultCallContext& operator=(DefaultCallContext&& other) noexcept; 37 38 const CORE_NS::IInterface* GetInterface(const BASE_NS::Uid& uid) const override; 39 CORE_NS::IInterface* GetInterface(const BASE_NS::Uid& uid) override; 40 41 bool DefineParameter(BASE_NS::string_view name, const IAny::Ptr& value) override; 42 bool Set(BASE_NS::string_view name, const IAny& value) override; 43 IAny::Ptr Get(BASE_NS::string_view name) const override; 44 45 BASE_NS::array_view<const ArgumentNameValue> GetParameters() const override; 46 47 bool Succeeded() const override; 48 49 bool DefineResult(const IAny::Ptr& value) override; 50 bool SetResult(const IAny& value) override; 51 bool SetResult() override; 52 IAny::Ptr GetResult() const override; 53 void Reset() override; 54 55 void ReportError(BASE_NS::string_view error) override; 56 57 BASE_NS::shared_ptr<CORE_NS::IInterface> GetClone() const override; 58 59 private: 60 BASE_NS::vector<ArgumentNameValue> params_; 61 bool succeeded_ {}; 62 IAny::Ptr result_; 63 }; 64 65 META_END_NAMESPACE() 66 67 #endif 68