PlugInManager.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef CPPUNIT_PLUGIN_PLUGINMANAGER_H
  2. #define CPPUNIT_PLUGIN_PLUGINMANAGER_H
  3. #include <cppunit/Portability.h>
  4. #if !defined(CPPUNIT_NO_TESTPLUGIN)
  5. #if CPPUNIT_NEED_DLL_DECL
  6. #pragma warning( push )
  7. #pragma warning( disable: 4251 ) // X needs to have dll-interface to be used by clients of class Z
  8. #endif
  9. #include <cppunit/plugin/PlugInParameters.h>
  10. struct CppUnitTestPlugIn;
  11. CPPUNIT_NS_BEGIN
  12. class DynamicLibraryManager;
  13. class TestResult;
  14. class XmlOutputter;
  15. /*! \brief Manges TestPlugIn.
  16. */
  17. class CPPUNIT_API PlugInManager
  18. {
  19. public:
  20. /*! Constructs a PlugInManager object.
  21. */
  22. PlugInManager();
  23. /// Destructor.
  24. virtual ~PlugInManager();
  25. /*! \brief Loads the specified plug-in.
  26. *
  27. * After being loaded, the CppUnitTestPlugIn::initialize() is called.
  28. *
  29. * \param libraryFileName Name of the file that contains the TestPlugIn.
  30. * \param parameters List of string passed to the plug-in.
  31. * \return Pointer on the DynamicLibraryManager associated to the library.
  32. * Valid until the library is unloaded. Never \c NULL.
  33. * \exception DynamicLibraryManagerException is thrown if an error occurs during loading.
  34. */
  35. void load( const std::string &libraryFileName,
  36. const PlugInParameters &parameters = PlugInParameters() );
  37. /*! \brief Unloads the specified plug-in.
  38. * \param libraryFileName Name of the file that contains the TestPlugIn passed
  39. * to a previous call to load().
  40. */
  41. void unload( const std::string &libraryFileName );
  42. /*! \brief Gives a chance to each loaded plug-in to register TestListener.
  43. *
  44. * For each plug-in, call CppUnitTestPlugIn::addListener().
  45. */
  46. void addListener( TestResult *eventManager );
  47. /*! \brief Gives a chance to each loaded plug-in to unregister TestListener.
  48. * For each plug-in, call CppUnitTestPlugIn::removeListener().
  49. */
  50. void removeListener( TestResult *eventManager );
  51. /*! \brief Provides a way for the plug-in to register some XmlOutputterHook.
  52. */
  53. void addXmlOutputterHooks( XmlOutputter *outputter );
  54. /*! \brief Called when the XmlOutputter is destroyed.
  55. *
  56. * Can be used to free some resources allocated by addXmlOutputterHooks().
  57. */
  58. void removeXmlOutputterHooks();
  59. protected:
  60. /*! \brief (INTERNAL) Information about a specific plug-in.
  61. */
  62. struct PlugInInfo
  63. {
  64. std::string m_fileName;
  65. DynamicLibraryManager *m_manager;
  66. CppUnitTestPlugIn *m_interface;
  67. };
  68. /*! Unloads the specified plug-in.
  69. * \param plugIn Information about the plug-in.
  70. */
  71. void unload( PlugInInfo &plugIn );
  72. private:
  73. /// Prevents the use of the copy constructor.
  74. PlugInManager( const PlugInManager &copy );
  75. /// Prevents the use of the copy operator.
  76. void operator =( const PlugInManager &copy );
  77. private:
  78. typedef CppUnitDeque<PlugInInfo> PlugIns;
  79. PlugIns m_plugIns;
  80. };
  81. CPPUNIT_NS_END
  82. #if CPPUNIT_NEED_DLL_DECL
  83. #pragma warning( pop )
  84. #endif
  85. #endif // !defined(CPPUNIT_NO_TESTPLUGIN)
  86. #endif // CPPUNIT_PLUGIN_PLUGINMANAGER_H