• 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     bool DefineParameter(BASE_NS::string_view name, const IAny::Ptr& value) override;
41     bool Set(BASE_NS::string_view name, const IAny& value) override;
42     IAny::Ptr Get(BASE_NS::string_view name) const override;
43 
44     BASE_NS::array_view<const ArgumentNameValue> GetParameters() const override;
45 
46     bool Succeeded() const override;
47 
48     bool DefineResult(const IAny::Ptr& value) override;
49     bool SetResult(const IAny& value) override;
50     bool SetResult() override;
51     IAny::Ptr GetResult() const override;
52     void Reset() override;
53 
54     void ReportError(BASE_NS::string_view error) override;
55 
56     BASE_NS::shared_ptr<CORE_NS::IInterface> GetClone() const override;
57 
58 private:
59     BASE_NS::vector<ArgumentNameValue> params_;
60     bool succeeded_ {};
61     IAny::Ptr result_;
62 };
63 
64 META_END_NAMESPACE()
65 
66 #endif
67