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 #ifndef META_SRC_NUMBER_H
16 #define META_SRC_NUMBER_H
17
18 #include <variant>
19
20 #include <meta/api/number.h>
21 #include <meta/interface/intf_any.h>
22
23 #include "base_object.h"
24
META_BEGIN_NAMESPACE()25 META_BEGIN_NAMESPACE()
26 namespace Internal {
27
28 class Number : public META_NS::Internal::BaseObjectFwd<Number, META_NS::ClassId::Number, IAny> {
29 public:
30 using VariantType = std::variant<int64_t, uint64_t, float>;
31
32 explicit Number(VariantType v = {});
33
34 const BASE_NS::array_view<const TypeId> GetCompatibleTypes(CompatibilityDirection) const override;
35 AnyReturnValue GetData(const TypeId& uid, void* data, size_t size) const override;
36 AnyReturnValue SetData(const TypeId& uid, const void* data, size_t size) override;
37 AnyReturnValue CopyFrom(const IAny& any) override;
38 IAny::Ptr Clone(const AnyCloneOptions& options) const override;
39 TypeId GetTypeId(TypeIdRole role) const override;
40 BASE_NS::string GetTypeIdString() const override;
41
42 private:
43 VariantType value_;
44 };
45
46 } // namespace Internal
47 META_END_NAMESPACE()
48
49 #endif
50