mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 11:31:53 +01:00
auto-init for db back-ends
Auto initialization for all DB back-ends and some tidy-up for network windows auto initialization
This commit is contained in:
@@ -44,6 +44,12 @@
|
||||
#include "Poco/Data/Connector.h"
|
||||
|
||||
|
||||
// Note: to avoid static (de)initialization problems,
|
||||
// during connector automatic (un)registration, it is
|
||||
// best to have this as a macro.
|
||||
#define POCO_DATA_MYSQL_CONNECTOR_NAME "mysql"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace MySQL {
|
||||
@@ -80,4 +86,55 @@ public:
|
||||
} } } // namespace Poco::Data::MySQL
|
||||
|
||||
|
||||
//
|
||||
// Automatic Connector registration
|
||||
//
|
||||
|
||||
struct MySQL_API MySQLConnectorRegistrator
|
||||
/// Connector registering class.
|
||||
/// A global instance of this class is instantiated
|
||||
/// with sole purpose to automatically register the
|
||||
/// MySQL connector with central Poco Data registry.
|
||||
{
|
||||
MySQLConnectorRegistrator()
|
||||
/// Calls Poco::Data::MySQL::registerConnector();
|
||||
{
|
||||
Poco::Data::MySQL::Connector::registerConnector();
|
||||
}
|
||||
|
||||
~MySQLConnectorRegistrator()
|
||||
/// Calls Poco::Data::MySQL::unregisterConnector();
|
||||
{
|
||||
Poco::Data::MySQL::Connector::unregisterConnector();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#if !defined(POCO_NO_AUTOMATIC_LIB_INIT)
|
||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||
extern "C" const struct MySQL_API MySQLConnectorRegistrator pocoMySQLConnectorRegistrator;
|
||||
#if defined(MySQL_EXPORTS)
|
||||
#if defined(_WIN64)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:"#s))
|
||||
#elif defined(_WIN32)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/export:_"#s))
|
||||
#endif
|
||||
#else // !MySQL_EXPORTS
|
||||
#if defined(_WIN64)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/include:"#s))
|
||||
#elif defined(_WIN32)
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) __pragma(comment (linker, "/include:_"#s))
|
||||
#endif
|
||||
#endif // MySQL_EXPORTS
|
||||
#else // !POCO_OS_FAMILY_WINDOWS
|
||||
#define POCO_DATA_MYSQL_FORCE_SYMBOL(s) extern "C" const struct MySQLConnectorRegistrator s;
|
||||
#endif // POCO_OS_FAMILY_WINDOWS
|
||||
POCO_DATA_MYSQL_FORCE_SYMBOL(pocoMySQLConnectorRegistrator)
|
||||
#endif // POCO_NO_AUTOMATIC_LIB_INIT
|
||||
|
||||
//
|
||||
// End automatic Connector registration
|
||||
//
|
||||
|
||||
|
||||
#endif // Data_MySQL_Connector_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user