diff options
author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-15 14:33:11 +0000 |
---|---|---|
committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-04-15 14:33:11 +0000 |
commit | 1b4bcf6f703248cb397587fe08635a1491d460ec (patch) | |
tree | e0ae81d803807027d7b4a6f14d9c39da2321dd47 /include/cppunit/plugin/DynamicLibraryManager.h | |
parent | 5f5af41d52c01c8320baffea21cd60ebbb16380b (diff) | |
download | cppunit-1b4bcf6f703248cb397587fe08635a1491d460ec.tar.gz |
NEWS: updated.
NEWS: updated.
* configure.in: added include/cppunit/config/Makefile and
include/cppunit/plugin/Makefile to the list of target.
* doc/CppUnit-win.dox: enabled generation of HTML Help documentation.
* include/cppunit/config/Makefile.am:
* include/cppunit/plugin/Makefile.am: added.
* include/cppunit/config-bcb5.h:
* include/cppunit/config-msvc6.h:
* include/cppunit/config-mac.h: moved to include/cppunit/config/.
* include/cppunit/Portability.h: updated config files location. Added macros
CPPUNIT_STRINGIZE and CPPUNIT_JOIN (implementation adapted from boost.org).
Added macro CPPUNIT_MAKE_UNIQUE_NAME.
* include/cppunit/Test.h: modified methods order.
* include/cppunit/extensions/HelperMacros.h: renamed macro
__CPPUNIT_MAKE_UNIQUE_NAME to CPPUNIT_MAKE_UNIQUE_NAME and moved its
definition to include/cppunit/Portability.h.
* include/cppunit/extensions/TestDecorator.h: Inherits Test instead of TestLeaf.
* include/cppunit/plugin/DynamicLibraryManager.h:
* src/cppunit/DynamicLibraryManager.cpp: added. DLL manager (load & lookup
symbol).
* src/cppunit/BeOsDynamicLibraryManager.cpp:
* src/cppunit/UnixDynamicLibraryManager.cpp:
* src/cppunit/Win32DynamicLibraryManager.cpp: added. Implementation of
platform dependent methods of DynamicLibraryManager.
* include/cppunit/plugin/DynamicLibraryManagerException.h:
* src/cppunit/DynamicLibraryManagerException.cpp: added. Exception thrown
by DynamicLibraryManager.
* include/cppunit/plugin/TestPlugIn.h: added. CppUnitTestPlugIn interface
definition. Helper macros to implements plug-in.
* include/cppunit/plugin/TestPlugInSuite.h:
* src/cppunit/plugin/TestPlugInSuite.cpp: added. A suite to wrap a test
plug-in.
* include/cppunit/plugin/TestPlugInDefaultImpl.h:
* src/cppunit/TestPlugInDefaultImpl.cpp: added. A default implementation
of the test plug-in interface.
* src/msvc6/DllPlugInTester/DllPlugInTester.cpp: updated to use the
new TestPlugIn.
* examples/cppunittest/TestResultCollectorTest.cpp: fixed typo.
Diffstat (limited to 'include/cppunit/plugin/DynamicLibraryManager.h')
-rw-r--r-- | include/cppunit/plugin/DynamicLibraryManager.h | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/include/cppunit/plugin/DynamicLibraryManager.h b/include/cppunit/plugin/DynamicLibraryManager.h new file mode 100644 index 0000000..93ce583 --- /dev/null +++ b/include/cppunit/plugin/DynamicLibraryManager.h @@ -0,0 +1,114 @@ +#ifndef CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H +#define CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H + +#include <cppunit/Portability.h> + +#if !defined(CPPUNIT_NO_TESTPLUGIN) +#include <string> + + +namespace CppUnit +{ + + +/*! \brief Manages dynamic libraries. + * + * The Dynamic Library Manager provides a platform independent way to work with + * dynamic library. It load a specific dynamic library, and can returns specific + * symbol exported by the dynamic library. + * + * If an error occurs, a DynamicLibraryManagerException is thrown. + * + * \internal Implementation of the OS independent methods is in + * DynamicLibraryManager.cpp. + * + * \internal Porting to a new platform: + * - Adds platform detection in config/SelectDllLoader.h. Should define a specific + * macro for that platform of the form: CPPUNIT_HAVE_XYZ_DLL_LOADER, where + * XYZ is the platform. + * - Makes a copy of UnixDynamicLibraryManager.cpp and named it after the platform. + * - Updated the 'guard' in your file (CPPUNIT_HAVE_XYZ_DLL_LOADER) so that it is + * only processed if the matching platform has been detected. + * - Change the implementation of methods doLoadLibrary(), doReleaseLibrary(), + * doFindSymbol() in your copy. Those methods usually maps directly to OS calls. + * - Adds the file to the project. + */ +class DynamicLibraryManager +{ +public: + typedef void *Symbol; + typedef void *LibraryHandle; + + /*! Loads the specified library. + * \param libraryFileName Name of the library to load. + * \exception DynamicLibraryManagerException if a failure occurs while loading + * the library (fail to found or load the library). + */ + DynamicLibraryManager( const std::string &libraryFileName ); + + /// Releases the loaded library.. + ~DynamicLibraryManager(); + + /*! Returns a pointer on the specified symbol exported by the library. + * \param symbol Name of the symbol exported by the library. + * \return Pointer on the symbol. Should be casted to the actual type. Never \c NULL. + * \exception DynamicLibraryManagerException if the symbol is not found. + */ + Symbol findSymbol( const std::string &symbol ); + +private: + /*! Loads the specified library. + * \param libraryName Name of the library to load. + * \exception DynamicLibraryManagerException if a failure occurs while loading + * the library (fail to found or load the library). + */ + void loadLibrary( const std::string &libraryName ); + + /*! Releases the loaded library. + * + * \warning Must NOT throw any exceptions (called from destructor). + */ + void releaseLibrary(); + + /*! Loads the specified library. + * + * May throw any exceptions (indicates failure). + * \param libraryName Name of the library to load. + * \return Handle of the loaded library. \c NULL indicates failure. + */ + LibraryHandle doLoadLibrary( const std::string &libraryName ); + + /*! Releases the loaded library. + * + * The handle of the library to free is in \c m_libraryHandle. It is never + * \c NULL. + * \warning Must NOT throw any exceptions (called from destructor). + */ + void doReleaseLibrary(); + + /*! Returns a pointer on the specified symbol exported by the library. + * + * May throw any exceptions (indicates failure). + * \param symbol Name of the symbol exported by the library. + * \return Pointer on the symbol. \c NULL indicates failure. + */ + Symbol doFindSymbol( const std::string &symbol ); + + /// Prevents the use of the copy constructor. + DynamicLibraryManager( const DynamicLibraryManager © ); + + /// Prevents the use of the copy operator. + void operator =( const DynamicLibraryManager © ); + +private: + LibraryHandle m_libraryHandle; + std::string m_libraryName; +}; + + +} // namespace CppUnit + + +#endif // !defined(CPPUNIT_NO_TESTPLUGIN) + +#endif // CPPUNIT_PLUGIN_DYNAMICLIBRARYMANAGER_H |