μ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 | 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

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

Public Member Functions

virtual ~ClientFactory ()
 Destructor. More...
 
boost::shared_ptr< ClientInterfacegetClient (const std::string &aId, const std::string &aUri)
 Construct an IPbus client based on the protocol identifier specified. More...
 
boost::shared_ptr< ClientInterfacegetClient (const std::string &aId, const std::string &aUri, const std::vector< std::string > &aUserClientActivationList)
 Construct an IPbus client based on the protocol identifier specified. More...
 
template<class T >
void registerClient (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...
 

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...
 
template<class T >
void add (const std::string &aProtocol, const std::string &aDescription, bool aUserDefined)
 Method to create an associate between a protocol identifier and a Creator of a particular type. More...
 

Private Attributes

boost::unordered_map< std::string, ClientInfomClientMap
 Hash map associating a creator for a particular protocol with a file name. More...
 

Static Private Attributes

static boost::shared_ptr< ClientFactorymInstance
 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 74 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 55 of file ClientFactory.cpp.

Referenced by getInstance().

◆ ~ClientFactory()

uhal::ClientFactory::~ClientFactory ( )
virtual

Destructor.

Definition at line 60 of file ClientFactory.cpp.

Member Function Documentation

◆ add()

template<class T >
void uhal::ClientFactory::add ( const std::string &  aProtocol,
const std::string &  aDescription,
bool  aUserDefined 
)
private

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 46 of file ClientFactory.hxx.

References uhal::ClientFactory::ClientInfo::creator, uhal::ClientFactory::ClientInfo::description, uhal::log(), mClientMap, uhal::ClientFactory::ClientInfo::userDefined, and uhal::Warning.

◆ getClient() [1/2]

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 90 of file ClientFactory.cpp.

◆ getClient() [2/2]

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

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.
aUserClientMapsa vector of names of protocols for user clients that should be enabled
Returns
a shared pointer to the newly created client

Definition at line 96 of file ClientFactory.cpp.

References uhal::Info, uhal::log(), mClientMap, 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 65 of file ClientFactory.cpp.

References ClientFactory(), and mInstance.

Referenced by uhal::tests::BOOST_AUTO_TEST_CASE(), uhal::tests::PerfTester::buildClients(), uhal::tests::checkClientFactory(), uhal::ConnectionManager::getDevice(), and uhal::ClientFactory::RegistrationHelper< T >::init().

◆ registerClient()

template<class T >
void uhal::ClientFactory::registerClient ( 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 65 of file ClientFactory.hxx.

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

Member Data Documentation

◆ mClientMap

boost::unordered_map< std::string , ClientInfo > uhal::ClientFactory::mClientMap
private

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

Definition at line 198 of file ClientFactory.hpp.

Referenced by add(), and getClient().

◆ mInstance

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

The single instance of the class.

Definition at line 196 of file ClientFactory.hpp.

Referenced by getInstance().


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