• 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 #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 IntroduceInterfaces<BaseObject, IAny> {
29     META_OBJECT(Number, META_NS::ClassId::Number, IntroduceInterfaces)
30 public:
31     using VariantType = std::variant<int64_t, uint64_t, float>;
32 
33     explicit Number(VariantType v = {});
34 
35     const BASE_NS::array_view<const TypeId> GetCompatibleTypes(CompatibilityDirection) const override;
36     AnyReturnValue GetData(const TypeId& uid, void* data, size_t size) const override;
37     AnyReturnValue SetData(const TypeId& uid, const void* data, size_t size) override;
38     AnyReturnValue CopyFrom(const IAny& any) override;
39     AnyReturnValue ResetValue() override;
40     IAny::Ptr Clone(const AnyCloneOptions& options) const override;
41     TypeId GetTypeId(TypeIdRole role) const override;
42     BASE_NS::string GetTypeIdString() const override;
43 
44 private:
45     VariantType value_;
46 };
47 
48 } // namespace Internal
49 META_END_NAMESPACE()
50 
51 #endif
52