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

A class to construct an IPbus client based on the protocol identifier specified NOTE! This is a factory method and must be Mutex protected if it is used in multithreaded environments! More...

#include <uhal/ClientFactory.hpp>

Inheritance diagram for uhal::ClientFactory:
[legend]
Collaboration diagram for uhal::ClientFactory:
[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

template<class T >
void add (const std::string &aProtocol, const std::string &aDescription="")
 Method to create an associate between a protocol identifier and a Creator of a particular type. More...
 
boost::shared_ptr< ClientInterfacegetClient (const std::string &aId, const std::string &aUri)
 Construct an IPbus client based on the protocol identifier specified. More...
 

Static Public Member Functions

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

Private Member Functions

 ClientFactory ()
 Default constructor This is private since only a single instance is to be created, using the getInstance method. More...
 
virtual ~ClientFactory ()
 Destructor. More...
 

Private Attributes

boost::unordered_map< std::string, boost::shared_ptr< CreatorInterface > > mCreators
 Hash map associating a creator for a particular protocol with a file name. More...
 
std::map< std::string, std::string > mProductDescriptions
 Store the description of the factory product. More...
 

Static Private Attributes

static ClientFactorymInstance = NULL
 The single instance of the class. More...
 

Detailed Description

A class to construct an IPbus client based on the protocol identifier specified NOTE! This is a factory method and must be Mutex protected if it is used in multithreaded environments!

Definition at line 72 of file ClientFactory.hpp.

Constructor & Destructor Documentation

◆ ClientFactory()

uhal::ClientFactory::ClientFactory ( )
private

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

Definition at line 79 of file ClientFactory.cpp.

Referenced by getInstance().

◆ ~ClientFactory()

uhal::ClientFactory::~ClientFactory ( )
privatevirtual

Destructor.

Definition at line 84 of file ClientFactory.cpp.

Member Function Documentation

◆ add()

template<class T >
void uhal::ClientFactory::add ( const std::string &  aProtocol,
const std::string &  aDescription = "" 
)

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

Parameters
aProtocolthe protocol identifier
aDescriptionan optional description of the protocol

Definition at line 38 of file ClientFactory.hxx.

References mCreators, mProductDescriptions, and uhal::Warning.

Referenced by getInstance().

◆ getClient()

boost::shared_ptr< ClientInterface > uhal::ClientFactory::getClient ( const std::string &  aId,
const std::string &  aUri 
)

Construct an IPbus client based on the protocol identifier specified.

Parameters
aIdthe uinique identifier that the client will be given.
aUria string containing the full URI of the target. This string is parsed to extract the protocol, and it is this which is used to identify the relevent creator which is then used to create the client.
Returns
a shared pointer to the newly created client

Definition at line 89 of file ClientFactory.cpp.

References uhal::Info, mCreators, mProductDescriptions, uhal::URI::mProtocol, and uhal::Quote().

◆ getInstance()

ClientFactory & uhal::ClientFactory::getInstance ( )
static

Static method to retrieve the single instance of the class.

Returns
the single instance of the class

Definition at line 51 of file ClientFactory.cpp.

References add(), ClientFactory(), and mInstance.

Referenced by uhal::tests::PerfTester::buildClients(), and uhal::ConnectionManager::getDevice().

Member Data Documentation

◆ mCreators

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

Hash map associating a creator for a particular protocol with a file name.

Definition at line 168 of file ClientFactory.hpp.

Referenced by add(), and getClient().

◆ mInstance

ClientFactory * uhal::ClientFactory::mInstance = NULL
staticprivate

The single instance of the class.

Definition at line 166 of file ClientFactory.hpp.

Referenced by getInstance().

◆ mProductDescriptions

std::map< std::string , std::string > uhal::ClientFactory::mProductDescriptions
private

Store the description of the factory product.

Definition at line 170 of file ClientFactory.hpp.

Referenced by add(), and getClient().


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