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_OBJECT_NAME_H
16 #define META_SRC_OBJECT_NAME_H
17
18 #include <meta/ext/base_object.h>
19 #include <meta/ext/serialization/serializer.h>
20 #include <meta/interface/interface_helpers.h>
21 #include <meta/interface/intf_named.h>
22 #include <meta/interface/serialization/intf_serializable.h>
23
META_BEGIN_NAMESPACE()24 META_BEGIN_NAMESPACE()
25 namespace Internal {
26 class ObjectName : public IntroduceInterfaces<BaseObject, IObjectName, ISerializable> {
27 META_OBJECT(ObjectName, META_NS::ClassId::ObjectName, IntroduceInterfaces)
28 public:
29 BASE_NS::string GetName() const override
30 {
31 return name_;
32 }
33 bool SetName(BASE_NS::string_view name) override
34 {
35 name_ = name;
36 return true;
37 }
38
39 ReturnError Export(IExportContext& c) const override
40 {
41 return Serializer(c) & NamedValue("Name", name_);
42 }
43 ReturnError Import(IImportContext& c) override
44 {
45 return Serializer(c) & NamedValue("Name", name_);
46 }
47
48 private:
49 BASE_NS::string name_;
50 };
51 } // namespace Internal
52
53 META_END_NAMESPACE()
54
55 #endif
56