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... | |
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 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 | |
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 115 of file ConnectionManager.cpp.
References CallBack(), mMutex, uhal::utilities::OpenFile(), and uhal::utilities::ParseSemicolonDelimitedUriList().
|
virtual |
Destructor.
Definition at line 129 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 222 of file ConnectionManager.cpp.
References uhal::Error, uhal::Info, mConnectionDescriptors, mMutex, mPreviouslyOpenedFiles, uhal::utilities::PugiXMLParseResultPrettifier(), and uhal::Quote().
Referenced by ConnectionManager().
|
static |
Clears cache of Node tree structure for previously-opened address files (thread safe)
Definition at line 212 of file ConnectionManager.cpp.
References uhal::NodeTreeBuilder::clearAddressFileCache(), uhal::NodeTreeBuilder::getInstance(), uhal::Info, 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 138 of file ConnectionManager.cpp.
References uhal::ClientFactory::getInstance(), uhal::NodeTreeBuilder::getInstance(), uhal::Info, mConnectionDescriptors, mMutex, and uhal::Quote().
Referenced by uhal::tests::MinimalFixture< type >::getHwInterface(), uhal::tests::MinimalFixture< IPBUS_2_0_PCIE >::getHwInterface(), uhal::tests::job_multiple(), and uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES().
|
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 167 of file ConnectionManager.cpp.
References uhal::ClientFactory::getInstance(), uhal::NodeTreeBuilder::getInstance(), uhal::Info, and mMutex.
std::vector< std::string > uhal::ConnectionManager::getDevices | ( | ) | const |
Return all device IDs known to this connection manager.
Definition at line 179 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 193 of file ConnectionManager.cpp.
References mConnectionDescriptors.
|
private |
A map of connection identifiers to stucts containing details of the parsed XML node.
Definition at line 176 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 165 of file ConnectionManager.hpp.
Referenced by CallBack(), clearAddressFileCache(), ConnectionManager(), and getDevice().
|
private |
A set of previously opened filenames, so that the same file is not parsed multiple times.
Definition at line 179 of file ConnectionManager.hpp.
Referenced by CallBack().