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