#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2023 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #if !defined(NUCLEX_SUPPORT_SERVICES_LAZYSERVICEINJECTOR_H) #error This header must be included via LazyServiceInjector.h #endif #include // for std::shared_ptr, std::make_shared() namespace Nuclex { namespace Support { namespace Services { // ------------------------------------------------------------------------------------------- // namespace Private { /// Constructs unknown types automatically injecting their dependencies /// Type that will be constructed /// /// Constructor signature obtained from the constructor signature detector /// template class ServiceFactory; /// Constructs unknown types automatically injecting their dependencies /// Type that will be constructed /// /// Specialization for default-constructible types /// template class ServiceFactory> { /// Creates a new instance of the service factory's type /// Not used in this specialization /// The new instance of the service factory's type public: static std::shared_ptr CreateInstance(const ServiceProvider &) { return std::make_shared(); } }; /// Constructs unknown types automatically injecting their dependencies /// Type that will be constructed /// /// Constructor signature obtained from the constructor signature detector /// /// /// Variadic version for types with 1 or more constructor arguments /// template class ServiceFactory> { /// Creates a new instance of the service factory's type /// /// Service provider that will be used to resolve constructor dependencies /// /// The new instance of the service factory's type public: static std::shared_ptr CreateInstance( const ServiceProvider &serviceProvider ) { return std::make_shared(typename TArguments::Type(serviceProvider)...); } }; } // namespace Private // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Services