• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/base/namespace.h>
22 #include <meta/ext/implementation_macros.h>
23 #include <meta/interface/interface_helpers.h>
24 #include <meta/interface/intf_call_context.h>
25 #include <meta/interface/intf_cloneable.h>
26 #include <meta/interface/object_macros.h>
27 
META_BEGIN_NAMESPACE()28 META_BEGIN_NAMESPACE()
29 
30 class DefaultCallContext : public IntroduceInterfaces<ICallContext, ICloneable> {
31 public:
32     ~DefaultCallContext() override;
33     DefaultCallContext();
34     DefaultCallContext(const DefaultCallContext& other) noexcept;
35     DefaultCallContext(DefaultCallContext&& other) noexcept;
36 
37     DefaultCallContext& operator=(const DefaultCallContext& other) noexcept;
38     DefaultCallContext& operator=(DefaultCallContext&& other) noexcept;
39 
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