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#include <meta/interface/builtin_objects.h> 16#include <meta/interface/intf_future.h> 17#include <meta/interface/intf_object_registry.h> 18#include <meta/interface/intf_task_queue.h> 19 20#include "attachment_container.h" 21#include "base_object.h" 22#include "connector.h" 23#include "container/object_container.h" 24#include "container/object_flat_container.h" 25#include "container_observer.h" 26#include "engine/engine_input_property_manager.h" 27#include "functions.h" 28#include "loaders/class_content_loader.h" 29#include "loaders/csv_string_resource_loader.h" 30#include "loaders/json_content_loader.h" 31#include "meta_object.h" 32#include "model/composite_object_provider.h" 33#include "model/container_data_model.h" 34#include "model/content_loader_object_provider.h" 35#include "model/instantiating_object_provider.h" 36#include "number.h" 37#include "object.h" 38#include "object_context.h" 39#include "object_hierarchy_observer.h" 40#include "property/bind.h" 41#include "proxy_object.h" 42#include "serialization/backend/debug_output.h" 43#include "serialization/backend/json_input.h" 44#include "serialization/backend/json_output.h" 45#include "serialization/exporter.h" 46#include "serialization/importer.h" 47#include "serialization/json_exporter.h" 48#include "serialization/json_importer.h" 49#include "serialization/ser_nodes.h" 50#include "startable_object_controller.h" 51 52META_BEGIN_NAMESPACE() 53 54IObjectFactory::Ptr GetManualClockFactory(); 55IObjectFactory::Ptr GetSystemClockFactory(); 56 57namespace Internal { 58 59IObjectFactory::Ptr GetPollingTaskQueueFactory(); 60IObjectFactory::Ptr GetThreadedTaskQueueFactory(); 61IObjectFactory::Ptr GetPromiseFactory(); 62IObjectFactory::Ptr GetContentObjectFactory(); 63 64static constexpr ObjectTypeInfo OBJECTS[] = { MetaObject::OBJECT_INFO, Object::OBJECT_INFO, 65 ObjectContainer::OBJECT_INFO, ObjectFlatContainer::OBJECT_INFO, ProxyObject::OBJECT_INFO, 66 ContainerObserver::OBJECT_INFO, SettableFunction::OBJECT_INFO, PropertyFunction::OBJECT_INFO, 67 ObjectContext::OBJECT_INFO, AttachmentContainer::OBJECT_INFO, ContainerDataModel::OBJECT_INFO, 68 CompositeObjectProvider::OBJECT_INFO, InstantiatingObjectProvider::OBJECT_INFO, 69 ContentLoaderObjectProvider::OBJECT_INFO, CsvStringResourceLoader::OBJECT_INFO, ClassContentLoader::OBJECT_INFO, 70 ObjectHierarchyObserver::OBJECT_INFO, StartableObjectController::OBJECT_INFO, Internal::Number::OBJECT_INFO, 71 Connector::OBJECT_INFO, JsonContentLoader::OBJECT_INFO, EngineValueManager::OBJECT_INFO, 72 EngineInputPropertyManager::OBJECT_INFO }; 73 74void RegisterBuiltInObjects(IObjectRegistry& registry) 75{ 76 registry.RegisterObjectType<META_NS::BaseObject>(); 77 for (auto& t : OBJECTS) { 78 registry.RegisterObjectType(t.GetFactory()); 79 } 80 registry.RegisterObjectType(GetManualClockFactory()); 81 registry.RegisterObjectType(GetSystemClockFactory()); 82 registry.RegisterObjectType(GetPollingTaskQueueFactory()); 83 registry.RegisterObjectType(GetThreadedTaskQueueFactory()); 84 registry.RegisterObjectType(GetPromiseFactory()); 85 registry.RegisterObjectType(GetContentObjectFactory()); 86 registry.RegisterObjectType<Serialization::Exporter>(); 87 registry.RegisterObjectType<Serialization::JsonExporter>(); 88 registry.RegisterObjectType<Serialization::Importer>(); 89 registry.RegisterObjectType<Serialization::JsonImporter>(); 90 registry.RegisterObjectType<Serialization::DebugOutput>(); 91 registry.RegisterObjectType<Serialization::JsonOutput>(); 92 registry.RegisterObjectType<Serialization::JsonInput>(); 93 registry.RegisterObjectType<Serialization::NilNode>(); 94 registry.RegisterObjectType<Serialization::MapNode>(); 95 registry.RegisterObjectType<Serialization::ArrayNode>(); 96 registry.RegisterObjectType<Serialization::ObjectNode>(); 97 registry.RegisterObjectType<Serialization::RootNode>(); 98 registry.RegisterObjectType<Serialization::BoolNode>(); 99 registry.RegisterObjectType<Serialization::IntNode>(); 100 registry.RegisterObjectType<Serialization::UIntNode>(); 101 registry.RegisterObjectType<Serialization::DoubleNode>(); 102 registry.RegisterObjectType<Serialization::StringNode>(); 103 registry.RegisterObjectType<Serialization::RefNode>(); 104 registry.RegisterObjectType<Bind>(); 105} 106 107void UnRegisterBuiltInObjects(IObjectRegistry& registry) 108{ 109 registry.UnregisterObjectType<Bind>(); 110 registry.UnregisterObjectType<Serialization::NilNode>(); 111 registry.UnregisterObjectType<Serialization::MapNode>(); 112 registry.UnregisterObjectType<Serialization::ArrayNode>(); 113 registry.UnregisterObjectType<Serialization::ObjectNode>(); 114 registry.UnregisterObjectType<Serialization::RootNode>(); 115 registry.UnregisterObjectType<Serialization::BoolNode>(); 116 registry.UnregisterObjectType<Serialization::IntNode>(); 117 registry.UnregisterObjectType<Serialization::UIntNode>(); 118 registry.UnregisterObjectType<Serialization::DoubleNode>(); 119 registry.UnregisterObjectType<Serialization::StringNode>(); 120 registry.UnregisterObjectType<Serialization::RefNode>(); 121 registry.UnregisterObjectType<Serialization::NilNode>(); 122 registry.UnregisterObjectType<Serialization::JsonInput>(); 123 registry.UnregisterObjectType<Serialization::JsonOutput>(); 124 registry.UnregisterObjectType<Serialization::DebugOutput>(); 125 registry.UnregisterObjectType<Serialization::JsonImporter>(); 126 registry.UnregisterObjectType<Serialization::Importer>(); 127 registry.UnregisterObjectType<Serialization::JsonExporter>(); 128 registry.UnregisterObjectType<Serialization::Exporter>(); 129 registry.UnregisterObjectType(GetContentObjectFactory()); 130 registry.UnregisterObjectType(GetManualClockFactory()); 131 registry.UnregisterObjectType(GetSystemClockFactory()); 132 registry.UnregisterObjectType(GetPollingTaskQueueFactory()); 133 registry.UnregisterObjectType(GetThreadedTaskQueueFactory()); 134 registry.UnregisterObjectType(GetPromiseFactory()); 135 for (auto& t : OBJECTS) { 136 registry.UnregisterObjectType(t.GetFactory()); 137 } 138 registry.UnregisterObjectType<META_NS::BaseObject>(); 139} 140} // namespace Internal 141META_END_NAMESPACE() 142