• 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_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     AnyReturnValue ResetValue() override
46     {
47         return AnyReturn::NOT_SUPPORTED;
48     }
49     IAny::Ptr Clone(const AnyCloneOptions& options) const override
50     {
51         if (options.role == TypeIdRole::ARRAY) {
52             CORE_LOG_E("DummyAny: cloning into an array not supported.");
53             return {};
54         }
55         return IAny::Ptr(new DummyAny);
56     }
57     TypeId GetTypeId(TypeIdRole) const override
58     {
59         return {};
60     }
61     BASE_NS::string GetTypeIdString() const override
62     {
63         return "";
64     }
65     AnyReturnValue SetValue(const IAny& value) override
66     {
67         return AnyReturn::NOT_SUPPORTED;
68     }
69     const IAny& GetValue() const override
70     {
71         return *this;
72     }
73     bool IsCompatible(const TypeId& id) const override
74     {
75         return false;
76     }
77 };
78 
79 inline const DummyAny INVALID_ANY {};
80 
81 META_END_NAMESPACE()
82 
83 #endif
84