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_ANY_H
17 #define META_SRC_ANY_H
18
19 #include <meta/interface/intf_any.h>
20
META_BEGIN_NAMESPACE()21 META_BEGIN_NAMESPACE()
22
23 class DummyAny : public IntroduceInterfaces<IAny, IValue> {
24 public:
25 ObjectId GetClassId() const override
26 {
27 return {};
28 }
29 const BASE_NS::array_view<const TypeId> GetCompatibleTypes(CompatibilityDirection dir) const override
30 {
31 return {};
32 }
33 AnyReturnValue GetData(const TypeId& id, void* data, size_t size) const override
34 {
35 return AnyReturn::NOT_SUPPORTED;
36 }
37 AnyReturnValue SetData(const TypeId& id, const void* data, size_t size) override
38 {
39 return AnyReturn::NOT_SUPPORTED;
40 }
41 AnyReturnValue CopyFrom(const IAny& any) override
42 {
43 return AnyReturn::NOT_SUPPORTED;
44 }
45 IAny::Ptr Clone(const AnyCloneOptions& options) const override
46 {
47 if (options.role == TypeIdRole::ARRAY) {
48 CORE_LOG_E("DummyAny: cloning into an array not supported.");
49 return {};
50 }
51 return IAny::Ptr(new DummyAny);
52 }
53 TypeId GetTypeId(TypeIdRole) const override
54 {
55 return {};
56 }
57 BASE_NS::string GetTypeIdString() const override
58 {
59 return "";
60 }
61 AnyReturnValue SetValue(const IAny& value) override
62 {
63 return AnyReturn::NOT_SUPPORTED;
64 }
65 const IAny& GetValue() const override
66 {
67 return *this;
68 }
69 bool IsCompatible(const TypeId& id) const override
70 {
71 return false;
72 }
73 };
74
75 inline const DummyAny INVALID_ANY {};
76
77 META_END_NAMESPACE()
78
79 #endif
80