μHAL (v2.7.9)
Part of the IPbus software repository
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>

Inheritance diagram for uhal::DerivedNodeFactory:
[legend]
Collaboration diagram for uhal::DerivedNodeFactory:
[legend]

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

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

boost::unordered_map< std::string, boost::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 boost::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 68 of file DerivedNodeFactory.hpp.

Constructor & Destructor Documentation

◆ DerivedNodeFactory()

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 53 of file DerivedNodeFactory.cpp.

Referenced by getInstance().

◆ ~DerivedNodeFactory()

uhal::DerivedNodeFactory::~DerivedNodeFactory ( )
virtual

Destructor.

Definition at line 58 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 63 of file DerivedNodeFactory.cpp.

References DerivedNodeFactory(), and mInstance.

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

Friends And Related Function Documentation

◆ NodeTreeBuilder

friend class NodeTreeBuilder
friend

Definition at line 70 of file DerivedNodeFactory.hpp.

◆ RegistrationHelper

template<typename T >
friend struct RegistrationHelper
friend

EXPERIMENTAL! Give the RegistrationHelper access to the private factory.

Definition at line 75 of file DerivedNodeFactory.hpp.

Member Data Documentation

◆ mCreators

boost::unordered_map< std::string , boost::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 160 of file DerivedNodeFactory.hpp.

Referenced by add(), and convertToClassType().

◆ mInstance

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

The single instance of the class.

Definition at line 157 of file DerivedNodeFactory.hpp.

Referenced by getInstance().


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