#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::size_t namespace Nuclex { namespace Support { namespace Services { // ------------------------------------------------------------------------------------------- // namespace Private { /// Informations about an argument passed to the constructor of a type /// Index of this argument template class ConstructorArgument { /// This type public: typedef ConstructorArgument Type; /// Index of this argument on the constructor public: constexpr static std::size_t Index = ArgumentIndex; /// Initializes a new constructor argument /// /// Activator through which the argument will be resolved when it is used /// public: ConstructorArgument(const ServiceProvider &serviceActivator) : serviceActivator(serviceActivator) {} /// Implicitly converts the placeholder to the argument's type /// The full type of the argument /// The value that will be passed as the constructor argument public: template< typename TArgument, typename = typename std::enable_if< IsInjectableArgument::type>::value >::type > operator TArgument() const { typedef typename TArgument::element_type ServiceType; return this->serviceActivator.template Get(); } /// Activator through which the argument will be resolved when needed private: const ServiceProvider &serviceActivator; }; } // namespace Private // ------------------------------------------------------------------------------------------- // namespace Private { /// Stores a constructor signature (the number and type of its arguments) /// Arguments required by the constructor template class ConstructorSignature { /// The type of this constructor signature itself public: typedef ConstructorSignature Type; /// Number of arguments being passed to the constructor public: static constexpr std::size_t ArgumentCount = sizeof...(TArguments); }; } // namespace Private // ------------------------------------------------------------------------------------------- // namespace Private { /// Used if the constructor signature cannot be determined class InvalidConstructorSignature { /// The type of this constructor signature itself public: typedef InvalidConstructorSignature Type; }; } // namespace Private // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Support::Services