Menu

[r333]: / trunk / cppunit / src / cppunit / PlugInManager.cpp  Maximize  Restore  History

Download this file

112 lines (83 with data), 2.4 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
#include <cppunit/XmlOutputterHook.h>
#if !defined(CPPUNIT_NO_TESTPLUGIN)
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/plugin/PlugInManager.h>
#include <cppunit/plugin/TestPlugIn.h>
#include <cppunit/plugin/DynamicLibraryManager.h>
namespace CppUnit
{
PlugInManager::PlugInManager()
{
}
PlugInManager::~PlugInManager()
{
for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it )
unload( *it );
}
void
PlugInManager::load( const std::string &libraryFileName,
const Parameters &parameters )
{
PlugInInfo info;
info.m_fileName = libraryFileName;
info.m_manager = new DynamicLibraryManager( libraryFileName );
TestPlugInSignature plug = (TestPlugInSignature)info.m_manager->findSymbol(
CPPUNIT_STRINGIZE( CPPUNIT_PLUGIN_EXPORTED_NAME ) );
info.m_interface = (*plug)();
m_plugIns.push_back( info );
info.m_interface->initialize( &TestFactoryRegistry::getRegistry(), parameters );
}
void
PlugInManager::unload( const std::string &libraryFileName )
{
for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it )
{
if ( it->m_fileName == libraryFileName )
{
unload( *it );
m_plugIns.erase( it );
break;
}
}
}
void
PlugInManager::addListener( TestResult *eventManager )
{
for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it )
it->m_interface->addListener( eventManager );
}
void
PlugInManager::removeListener( TestResult *eventManager )
{
for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it )
it->m_interface->removeListener( eventManager );
}
void
PlugInManager::unload( PlugInInfo &plugIn )
{
try
{
plugIn.m_interface->uninitialize( &TestFactoryRegistry::getRegistry() );
delete plugIn.m_manager;
}
catch (...)
{
delete plugIn.m_manager;
plugIn.m_manager = NULL;
throw;
}
}
void
PlugInManager::addXmlOutputterHooks( XmlOutputter *outputter )
{
for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it )
it->m_interface->addXmlOutputterHooks( outputter );
}
void
PlugInManager::removeXmlOutputterHooks()
{
for ( PlugIns::iterator it = m_plugIns.begin(); it != m_plugIns.end(); ++it )
it->m_interface->removeXmlOutputterHooks();
}
} // namespace CppUnit
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)
MongoDB Logo MongoDB