solinject  1.0.0
C++17 Dependency Injection header-only library
sol::di::impl::SingletonService< TService, TServiceParents > Class Template Reference

Singleton DI service. More...

#include <SingletonService.hpp>

Inheritance diagram for sol::di::impl::SingletonService< TService, TServiceParents >:
[legend]
Collaboration diagram for sol::di::impl::SingletonService< TService, TServiceParents >:
[legend]

Public Types

using Base = ServiceBase< TService >
 Base of the SingletonService class.
 
using Container = typename Base::Container
 DI container. More...
 
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 VoidPtr = typename IService::VoidPtr
 Pointer to void. More...
 
- Public Types inherited from sol::di::impl::ServiceBase< TService >
using Base = IServiceTyped< TService >
 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< TService >
using ServicePtr = typename std::shared_ptr< TService >
 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 Types inherited from sol::di::impl::ServiceBase< TServiceParents >
using Base = IServiceTyped< TServiceParents >
 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< TServiceParents >
using ServicePtr = typename std::shared_ptr< TServiceParents >
 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 Member Functions

 SingletonService (ServicePtr service)
 Constructor. More...
 
 SingletonService (Factory factory)
 Constructor. More...
 
- Public Member Functions inherited from sol::di::impl::ServiceBase< TService >
virtual ServicePtr GetService (const Container &container)
 Resolves the service and checks for circular dependencies. More...
 
- Public Member Functions inherited from sol::di::impl::ServiceBase< TServiceParents >
virtual ServicePtr GetService (const Container &container)
 Resolves the service and checks for circular dependencies. More...
 

Protected Member Functions

virtual VoidPtr GetServiceAsVoidPtr (const Container &container) override
 Resolves a service. More...
 

Additional Inherited Members

- Protected Attributes inherited from sol::di::impl::ServiceBase< TService >
bool m_IsLocked
 Field that indicates if the DI service is "locked". More...
 
- Protected Attributes inherited from sol::di::impl::ServiceBase< TServiceParents >
bool m_IsLocked
 Field that indicates if the DI service is "locked". More...
 

Detailed Description

template<class TService, class... TServiceParents>
class sol::di::impl::SingletonService< TService, TServiceParents >

Singleton DI service.

Template Parameters
Tservice type

Member Typedef Documentation

◆ Container

template<class TService , class... TServiceParents>
using sol::di::impl::SingletonService< TService, TServiceParents >::Container = typename Base::Container

DI container.

◆ Factory

template<class TService , class... TServiceParents>
using sol::di::impl::SingletonService< TService, TServiceParents >::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 TService , class... TServiceParents>
using sol::di::impl::SingletonService< TService, TServiceParents >::ServicePtr = typename Base::ServicePtr

Pointer to an instance of a service.

◆ VoidPtr

template<class TService , class... TServiceParents>
using sol::di::impl::SingletonService< TService, TServiceParents >::VoidPtr = typename IService::VoidPtr

Pointer to void.

Constructor & Destructor Documentation

◆ SingletonService() [1/2]

template<class TService , class... TServiceParents>
sol::di::impl::SingletonService< TService, TServiceParents >::SingletonService ( ServicePtr  service)
inline

Constructor.

Parameters
servicepointer to a service instance

◆ SingletonService() [2/2]

template<class TService , class... TServiceParents>
sol::di::impl::SingletonService< TService, TServiceParents >::SingletonService ( Factory  factory)
inline

Constructor.

Parameters
factoryfactory function

Member Function Documentation

◆ GetServiceAsVoidPtr()

template<class TService , class... TServiceParents>
virtual VoidPtr sol::di::impl::SingletonService< TService, TServiceParents >::GetServiceAsVoidPtr ( const Container container)
inlineoverrideprotectedvirtual

Resolves a service.

Parameters
containerDI container
Returns
A service instance as VoidPtr

Implements sol::di::impl::IService.


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