BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Types | Public Member Functions | Protected Member Functions
BeeeOn::DIFactory Class Referenceabstract

Implementation of DIFactory can manage and create instances by name and automatically (usually based on some configuration) inject dependencies into each instance. More...

#include <DIFactory.h>

Inheritance diagram for BeeeOn::DIFactory:
BeeeOn::DependencyInjector

Public Types

typedef Poco::SharedPtr
< DIFactory
Ptr
 

Public Member Functions

DIWrappercreate (const std::string &name, bool detach=false)
 Create a new instance by name. If detached is true, the memory of the returned DIWrapper pointer MUST be explicitly deleted. Otherwise, each created instance is managed by the DIFactory.
 
template<typename T >
Poco::SharedPtr< T > create (const std::string &name, bool detach=false)
 Create a new instance by name and perform runtime cast to the target type if possible. More...
 
DIWrapperfind (const std::string &name)
 Find an existing instance and return it. More...
 
template<typename T >
Poco::SharedPtr< T > find (const std::string &name)
 Find an existing instance and cast it to the target type if possible. More...
 

Protected Member Functions

template<typename T >
Poco::SharedPtr< T > cast (DIWrapper &wrapper)
 Cast the wrapped instance to the target type. If the cast is not possible, throw an exception.
 
virtual DIWrapperfindImpl (const std::string &name)=0
 
virtual DIWrappercreateImpl (const std::string &name, bool detach)=0
 
virtual void castImpl (const std::type_info &type, const DIWrapper &wrapper, void *target)=0
 Perform cast of the given wrapper to the target of the given type. The target points to the Poco::SharedPtr<T> where typeid(T) == type.
 

Detailed Description

Implementation of DIFactory can manage and create instances by name and automatically (usually based on some configuration) inject dependencies into each instance.

Member Function Documentation

template<typename T >
Poco::SharedPtr<T> BeeeOn::DIFactory::create ( const std::string &  name,
bool  detach = false 
)
inline

Create a new instance by name and perform runtime cast to the target type if possible.

See Also
DIFactory::create()
virtual DIWrapper* BeeeOn::DIFactory::createImpl ( const std::string &  name,
bool  detach 
)
protectedpure virtual
Returns
DIWrapper that represents the instance of the given name. If it already exists, return the existing one.
DIWrapper* BeeeOn::DIFactory::find ( const std::string &  name)
inline

Find an existing instance and return it.

Returns
found instance or nullptr
template<typename T >
Poco::SharedPtr<T> BeeeOn::DIFactory::find ( const std::string &  name)
inline

Find an existing instance and cast it to the target type if possible.

Returns
found instance or nullptr
virtual DIWrapper* BeeeOn::DIFactory::findImpl ( const std::string &  name)
protectedpure virtual
Returns
DIWrapper that represents the instance of the given name or nullptr.

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