solinject
1.0.0
C++17 Dependency Injection header-only library
|
Base for the DI service classes. More...
#include <ServiceBase.hpp>
Public Types | |
using | Base = IServiceTyped< T > |
Base of the ServiceBase class. | |
using | ServicePtr = typename Base::ServicePtr |
Pointer to an instance of a service. More... | |
using | Factory = typename Base::Factory |
Factory function that accepts a reference to a DI container and returns a pointer to an instance of a service. More... | |
using | Container = typename Base::Container |
DI container. More... | |
![]() | |
using | ServicePtr = typename std::shared_ptr< T > |
Pointer to an instance of a service. | |
using | Factory = typename std::function< ServicePtr(const Container &)> |
Factory function that accepts a reference to a DI container and returns a pointer to an instance of a service. | |
![]() | |
using | Container = sol::di::Container |
DI container. | |
using | VoidPtr = std::shared_ptr< void > |
Pointer to void. | |
Public Member Functions | |
virtual ServicePtr | GetService (const Container &container) |
Resolves the service and checks for circular dependencies. More... | |
![]() | |
virtual VoidPtr | GetServiceAsVoidPtr (const Container &container)=0 |
Resolves a service. More... | |
Protected Attributes | |
bool | m_IsLocked = false |
Field that indicates if the DI service is "locked". More... | |
Base for the DI service classes.
T | service type |
using sol::di::impl::ServiceBase< T >::Container = typename Base::Container |
DI container.
using sol::di::impl::ServiceBase< T >::Factory = typename Base::Factory |
Factory function that accepts a reference to a DI container and returns a pointer to an instance of a service.
using sol::di::impl::ServiceBase< T >::ServicePtr = typename Base::ServicePtr |
Pointer to an instance of a service.
|
inlinevirtual |
Resolves the service and checks for circular dependencies.
[in] | container | DI container |
sol::di::exc::CircularDependencyException |
Implements sol::di::impl::IServiceTyped< T >.
|
protected |
Field that indicates if the DI service is "locked".
When a DI service resolves a service, it becomes "locked" until an instance of the service is returned. If the DI service is already locked, it means that we have detected a circular dependency.