solinject  1.0.0
C++17 Dependency Injection header-only library
sol::di::impl::ServiceBase< T > Class Template Referenceabstract

Base for the DI service classes. More...

#include <ServiceBase.hpp>

Inheritance diagram for sol::di::impl::ServiceBase< T >:
[legend]
Collaboration diagram for sol::di::impl::ServiceBase< T >:
[legend]

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...
 
- Public Types inherited from sol::di::impl::IServiceTyped< T >
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.
 
- Public Types inherited from sol::di::impl::IService
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...
 
- Public Member Functions inherited from sol::di::impl::IService
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...
 

Detailed Description

template<class T>
class sol::di::impl::ServiceBase< T >

Base for the DI service classes.

Template Parameters
Tservice type

Member Typedef Documentation

◆ Container

template<class T >
using sol::di::impl::ServiceBase< T >::Container = typename Base::Container

DI container.

◆ Factory

template<class T >
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.

◆ ServicePtr

template<class T >
using sol::di::impl::ServiceBase< T >::ServicePtr = typename Base::ServicePtr

Pointer to an instance of a service.

Member Function Documentation

◆ GetService()

template<class T >
virtual ServicePtr sol::di::impl::ServiceBase< T >::GetService ( const Container container)
inlinevirtual

Resolves the service and checks for circular dependencies.

Parameters
[in]containerDI container
Returns
pointer to a service instance
Exceptions
sol::di::exc::CircularDependencyException

Implements sol::di::impl::IServiceTyped< T >.

Member Data Documentation

◆ m_IsLocked

template<class T >
bool sol::di::impl::ServiceBase< T >::m_IsLocked = false
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.


The documentation for this class was generated from the following file: