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

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...
 
virtual ~DerivedNodeFactory ()
 Destructor. More...
 
NodeconvertToClassType (Node *aNode)
 
template<class T >
void add (const std::string &aNodeClassName)
 

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 DerivedNodeFactorymInstance = NULL
 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 67 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 ( )
privatevirtual

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

Definition at line 44 of file DerivedNodeFactory.hxx.

References 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 69 of file DerivedNodeFactory.hpp.

◆ RegistrationHelper

template<typename T >
friend struct RegistrationHelper
friend

EXPERIMENTAL! Give the RegistrationHelper access to the private factory.

Definition at line 74 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 166 of file DerivedNodeFactory.hpp.

Referenced by add(), and convertToClassType().

◆ mInstance

DerivedNodeFactory * uhal::DerivedNodeFactory::mInstance = NULL
staticprivate

The single instance of the class.

Definition at line 163 of file DerivedNodeFactory.hpp.

Referenced by getInstance().


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