μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
uhal::DerivedNodeFactory Class Reference

A singleton class to register derived nodes, and create instances of them later NOTE! This is a factory method and must be Mutex protected if it is used in multithreaded environments! More...

#include <uhal/DerivedNodeFactory.hpp>

Classes

class  Creator
 Templated concrete implementation with a CreatorInterface interface. More...
 
class  CreatorInterface
 An abstract base class for defining the interface to the creators. More...
 

Public Member Functions

 DerivedNodeFactory (const DerivedNodeFactory &)=delete
 
DerivedNodeFactoryoperator= (const DerivedNodeFactory &)=delete
 
virtual ~DerivedNodeFactory ()
 Destructor. More...
 

Static Public Member Functions

static DerivedNodeFactorygetInstance ()
 Static method to retrieve the single instance of the class. More...
 

Private Member Functions

 DerivedNodeFactory ()
 Default constructor This is private since only a single instance is to be created, using the getInstance method. More...
 
NodeconvertToClassType (Node *aNode)
 
template<class T >
void add (const std::string &aNodeClassName)
 Method to create an associate between a node type identifier and a Creator of that particular node type. More...
 

Private Attributes

std::unordered_map< std::string, std::shared_ptr< CreatorInterface > > mCreators
 Hash map associating a creator for a particular node type with a string identifier for that node type. More...
 

Static Private Attributes

static std::shared_ptr< DerivedNodeFactorymInstance
 The single instance of the class. More...
 

Friends

class NodeTreeBuilder
 
template<typename T >
struct RegistrationHelper
 EXPERIMENTAL! Give the RegistrationHelper access to the private factory. More...
 

Detailed Description

A singleton class to register derived nodes, and create instances of them later NOTE! This is a factory method and must be Mutex protected if it is used in multithreaded environments!

Definition at line 62 of file DerivedNodeFactory.hpp.

Constructor & Destructor Documentation

◆ DerivedNodeFactory() [1/2]

uhal::DerivedNodeFactory::DerivedNodeFactory ( )
private

Default constructor This is private since only a single instance is to be created, using the getInstance method.

Definition at line 52 of file DerivedNodeFactory.cpp.

Referenced by getInstance().

◆ DerivedNodeFactory() [2/2]

uhal::DerivedNodeFactory::DerivedNodeFactory ( const DerivedNodeFactory )
delete

◆ ~DerivedNodeFactory()

uhal::DerivedNodeFactory::~DerivedNodeFactory ( )
virtual

Destructor.

Definition at line 57 of file DerivedNodeFactory.cpp.

Member Function Documentation

◆ add()

template<class T >
void uhal::DerivedNodeFactory::add ( const std::string &  aNodeClassName)
private

Method to create an associate between a node type identifier and a Creator of that particular node type.

Parameters
aNodeClassNamethe node type identifier

Definition at line 44 of file DerivedNodeFactory.hxx.

References uhal::log(), mCreators, and uhal::Warning.

Referenced by uhal::RegistrationHelper< T >::RegistrationHelper().

◆ convertToClassType()

Node * uhal::DerivedNodeFactory::convertToClassType ( Node aNode)
private

◆ getInstance()

DerivedNodeFactory & uhal::DerivedNodeFactory::getInstance ( )
static

Static method to retrieve the single instance of the class.

Returns
the single instance of the class

Definition at line 62 of file DerivedNodeFactory.cpp.

References DerivedNodeFactory(), and mInstance.

Referenced by uhal::NodeTreeBuilder::moduleNodeCreator(), uhal::NodeTreeBuilder::plainNodeCreator(), and uhal::RegistrationHelper< T >::RegistrationHelper().

◆ operator=()

DerivedNodeFactory & uhal::DerivedNodeFactory::operator= ( const DerivedNodeFactory )
delete

Friends And Related Function Documentation

◆ NodeTreeBuilder

friend class NodeTreeBuilder
friend

Definition at line 64 of file DerivedNodeFactory.hpp.

◆ RegistrationHelper

template<typename T >
friend struct RegistrationHelper
friend

EXPERIMENTAL! Give the RegistrationHelper access to the private factory.

Definition at line 69 of file DerivedNodeFactory.hpp.

Member Data Documentation

◆ mCreators

std::unordered_map< std::string , std::shared_ptr< CreatorInterface > > uhal::DerivedNodeFactory::mCreators
private

Hash map associating a creator for a particular node type with a string identifier for that node type.

Definition at line 158 of file DerivedNodeFactory.hpp.

Referenced by add(), and convertToClassType().

◆ mInstance

std::shared_ptr< DerivedNodeFactory > uhal::DerivedNodeFactory::mInstance
staticprivate

The single instance of the class.

Definition at line 155 of file DerivedNodeFactory.hpp.

Referenced by getInstance().


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