• 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_EXT_MINIMAL_OBJECT_H
17 #define META_EXT_MINIMAL_OBJECT_H
18 
19 #include <base/util/uid_util.h>
20 
21 #include <meta/base/namespace.h>
22 #include <meta/interface/interface_helpers.h>
23 #include <meta/interface/intf_lifecycle.h>
24 #include <meta/interface/intf_object.h>
25 #include <meta/interface/intf_object_flags.h>
26 #include <meta/interface/intf_static_metadata.h>
27 
META_BEGIN_NAMESPACE()28 META_BEGIN_NAMESPACE()
29 
30 class MinimalObject : public IntroduceInterfaces<IObject, IObjectFlags, IStaticMetadata> {
31 public:
32     MinimalObject() : flags_(ObjectFlagBits::DEFAULT_FLAGS) {}
33     MinimalObject(const ObjectFlagBitsValue& value) : flags_(value) {}
34 
35     BASE_NS::string GetName() const override
36     {
37         return GetClassId().ToString();
38     }
39 
40     ObjectFlagBitsValue GetObjectFlags() const override
41     {
42         return flags_;
43     }
44 
45     void SetObjectFlags(const ObjectFlagBitsValue& value) override
46     {
47         flags_ = value;
48     }
49 
50     ObjectFlagBitsValue GetObjectDefaultFlags() const override
51     {
52         return ObjectFlagBits::DEFAULT_FLAGS;
53     }
54 
55     // this allows to use the same macros for minimal objects too
56     inline static const nullptr_t STATIC_METADATA {};
57     static const StaticObjectMetadata* StaticMetadata()
58     {
59         return nullptr;
60     }
61     const StaticObjectMetadata* GetStaticMetadata() const override
62     {
63         return StaticMetadata();
64     }
65 
66 private:
67     ObjectFlagBitsValue flags_ {};
68 };
69 
70 META_END_NAMESPACE()
71 
72 #endif
73