A class to open and manage XML connection files and wrap up the interfaces to the NodeTreeBuilder and the ClientFactory. More...
#include <uhal/ConnectionManager.hpp>
Classes | |
struct | ConnectionDescriptor |
A struct to hold the fields of each entry in the XML connections file. More... | |
Public Member Functions | |
ConnectionManager (const std::string &aFilenameExpr) | |
Default constructor Given a semi-colon delimeted list of glob expressions, parse all the files matching it (e.g. More... | |
ConnectionManager (const std::string &aFilenameExpr, const std::vector< std::string > &aUserClientActivationList) | |
virtual | ~ConnectionManager () |
Destructor. More... | |
HwInterface | getDevice (const std::string &aId) |
Retrieves protocol, host, and port from the connection file to create an IPbus Client Retrieves the address table file from the connection file to create the Node tree Puts the two together to create a full HwInterface. More... | |
std::vector< std::string > | getDevices () const |
Return all device IDs known to this connection manager. More... | |
std::vector< std::string > | getDevices (const std::string &aRegex) const |
Return all device IDs known to this connection manager which match a (boost) regular expression. More... | |
Static Public Member Functions | |
static HwInterface | getDevice (const std::string &aId, const std::string &aUri, const std::string &aAddressFileExpr) |
Use the specified protocol, host, and port to create an IPbus Client Use the specified address table to create the Node tree Puts the two together to create a full HwInterface. More... | |
static HwInterface | getDevice (const std::string &aId, const std::string &aUri, const std::string &aAddressFileExpr, const std::vector< std::string > &aUserClientActivationList) |
static void | clearAddressFileCache () |
Clears cache of Node tree structure for previously-opened address files (thread safe) More... | |
Private Member Functions | |
void | CallBack (const std::string &aProtocol, const boost::filesystem::path &aPath, std::vector< uint8_t > &aFile) |
Method called once the file specified in the constructor has been opened. More... | |
Private Attributes | |
const std::vector< std::string > | mUserClientActivationList |
std::map< std::string, ConnectionDescriptor > | mConnectionDescriptors |
A map of connection identifiers to stucts containing details of the parsed XML node. More... | |
std::set< std::string > | mPreviouslyOpenedFiles |
A set of previously opened filenames, so that the same file is not parsed multiple times. More... | |
Static Private Attributes | |
static boost::mutex | mMutex |
A mutex lock to protect access to the factory methods in multithreaded environments. More... | |
A class to open and manage XML connection files and wrap up the interfaces to the NodeTreeBuilder and the ClientFactory.
Definition at line 78 of file ConnectionManager.hpp.
uhal::ConnectionManager::ConnectionManager | ( | const std::string & | aFilenameExpr | ) |
Default constructor Given a semi-colon delimeted list of glob expressions, parse all the files matching it (e.g.
$BUILD/config/c*.xml). If one parsing fails throw an exception and return filename and line number
aFilenameExpr | a semi-colon delimeted list of glob expressions specifying one or more XML connection files to load |
Definition at line 106 of file ConnectionManager.cpp.
References CallBack(), mMutex, uhal::utilities::OpenFile(), and uhal::utilities::ParseSemicolonDelimitedUriList().
uhal::ConnectionManager::ConnectionManager | ( | const std::string & | aFilenameExpr, |
const std::vector< std::string > & | aUserClientActivationList | ||
) |
Definition at line 120 of file ConnectionManager.cpp.
References CallBack(), mMutex, uhal::utilities::OpenFile(), and uhal::utilities::ParseSemicolonDelimitedUriList().
|
virtual |
Destructor.
Definition at line 135 of file ConnectionManager.cpp.
|
private |
Method called once the file specified in the constructor has been opened.
aProtocol | The protocol by which the file was loaded |
aPath | The fully qualified path to the file which has been opened |
aFile | A byte vector containing the content of the opened file. Done like this since the routine handles local and http files identically |
Definition at line 233 of file ConnectionManager.cpp.
References uhal::ConnectionManager::ConnectionDescriptor::address_table, pugi::xpath_node_set::begin(), pugi::xpath_node_set::end(), uhal::Error, uhal::ConnectionManager::ConnectionDescriptor::id, uhal::Info, pugi::xml_document::load_buffer_inplace(), uhal::log(), mConnectionDescriptors, mPreviouslyOpenedFiles, uhal::utilities::PugiXMLParseResultPrettifier(), uhal::Quote(), pugi::xml_node::select_nodes(), and uhal::ConnectionManager::ConnectionDescriptor::uri.
Referenced by ConnectionManager().
|
static |
Clears cache of Node tree structure for previously-opened address files (thread safe)
Definition at line 224 of file ConnectionManager.cpp.
References uhal::NodeTreeBuilder::clearAddressFileCache(), uhal::NodeTreeBuilder::getInstance(), uhal::Info, uhal::log(), and mMutex.
HwInterface uhal::ConnectionManager::getDevice | ( | const std::string & | aId | ) |
Retrieves protocol, host, and port from the connection file to create an IPbus Client Retrieves the address table file from the connection file to create the Node tree Puts the two together to create a full HwInterface.
aId | the unique identifier for the connection |
Definition at line 140 of file ConnectionManager.cpp.
References uhal::ClientFactory::getInstance(), uhal::NodeTreeBuilder::getInstance(), uhal::Info, uhal::log(), mConnectionDescriptors, mMutex, mUserClientActivationList, and uhal::Quote().
Referenced by uhal::tests::MinimalFixture< type >::getHwInterface(), uhal::tests::MinimalFixture< IPBUS_2_0_PCIE >::getHwInterface(), and uhal::tests::job_multiple().
|
static |
Use the specified protocol, host, and port to create an IPbus Client Use the specified address table to create the Node tree Puts the two together to create a full HwInterface.
aId | the unique identifier for the connection |
aUri | the URI string detailing how the connection is made |
aAddressFileExpr | a file expression pointing to exactly one local or remote address file (note. this assumes a semi-colon delimited list which can contain glob file expressions, etc. This expression is parsed and evaluated, and the file count checked at runtime.) |
Definition at line 169 of file ConnectionManager.cpp.
References uhal::ClientFactory::getInstance(), uhal::NodeTreeBuilder::getInstance(), uhal::Info, uhal::log(), and mMutex.
|
static |
Definition at line 180 of file ConnectionManager.cpp.
References uhal::ClientFactory::getInstance(), uhal::NodeTreeBuilder::getInstance(), uhal::Info, uhal::log(), and mMutex.
std::vector< std::string > uhal::ConnectionManager::getDevices | ( | ) | const |
Return all device IDs known to this connection manager.
Definition at line 191 of file ConnectionManager.cpp.
References mConnectionDescriptors.
std::vector< std::string > uhal::ConnectionManager::getDevices | ( | const std::string & | aRegex | ) | const |
Return all device IDs known to this connection manager which match a (boost) regular expression.
aRegex | a string expression which is converted to a (boost) regular expression against which the device IDs are tested |
Definition at line 205 of file ConnectionManager.cpp.
References mConnectionDescriptors.
|
private |
A map of connection identifiers to stucts containing details of the parsed XML node.
Definition at line 175 of file ConnectionManager.hpp.
Referenced by CallBack(), getDevice(), and getDevices().
|
staticprivate |
A mutex lock to protect access to the factory methods in multithreaded environments.
Definition at line 162 of file ConnectionManager.hpp.
Referenced by clearAddressFileCache(), ConnectionManager(), and getDevice().
|
private |
A set of previously opened filenames, so that the same file is not parsed multiple times.
Definition at line 178 of file ConnectionManager.hpp.
Referenced by CallBack().
|
private |
Definition at line 172 of file ConnectionManager.hpp.
Referenced by getDevice().