/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ #include namespace AzFramework { namespace Components { template ComponentAdapter::ComponentAdapter(const TConfiguration& configuration) : m_controller(configuration) { } ////////////////////////////////////////////////////////////////////////// // Serialization and version conversion template void ComponentAdapter::Reflect(AZ::ReflectContext* context) { TController::Reflect(context); if (auto serializeContext = azrtti_cast(context)) { serializeContext->Class() ->Version(1) ->Field("Controller", &ComponentAdapter::m_controller) ; } } ////////////////////////////////////////////////////////////////////////// // Get*Services functions template void ComponentAdapter::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& services) { GetProvidedServicesHelper(services, typename AZ::HasComponentProvidedServices::type()); } template void ComponentAdapter::GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& services) { GetRequiredServicesHelper(services, typename AZ::HasComponentRequiredServices::type()); } template void ComponentAdapter::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& services) { GetIncompatibleServicesHelper(services, typename AZ::HasComponentIncompatibleServices::type()); } template void ComponentAdapter::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& services) { GetDependentServicesHelper(services, typename AZ::HasComponentDependentServices::type()); } ////////////////////////////////////////////////////////////////////////// // AZ::Component interface implementation template void ComponentAdapter::Init() { ComponentInitHelper::Init(m_controller); } template void ComponentAdapter::Activate() { m_controller.Activate(GetEntityId()); } template void ComponentAdapter::Deactivate() { m_controller.Deactivate(); } template bool ComponentAdapter::ReadInConfig(const AZ::ComponentConfig* baseConfig) { if (const auto config = azrtti_cast(baseConfig)) { m_controller.SetConfiguration(*config); return true; } return false; } template bool ComponentAdapter::WriteOutConfig(AZ::ComponentConfig* outBaseConfig) const { if (auto config = azrtti_cast(outBaseConfig)) { *config = m_controller.GetConfiguration(); return true; } return false; } } // namespace Components } // namespace AzFramework