~ubuntu-branches/ubuntu/quantal/psi/quantal

« back to all changes in this revision

Viewing changes to third-party/cppunit/cppunit/src/cppunit/DynamicLibraryManager.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <cppunit/plugin/DynamicLibraryManager.h>
2
 
 
3
 
#if !defined(CPPUNIT_NO_TESTPLUGIN)
4
 
#include <cppunit/plugin/DynamicLibraryManagerException.h>
5
 
 
6
 
CPPUNIT_NS_BEGIN
7
 
 
8
 
 
9
 
DynamicLibraryManager::DynamicLibraryManager( const std::string &libraryFileName )
10
 
    : m_libraryHandle( NULL )
11
 
    , m_libraryName( libraryFileName )
12
 
{
13
 
  loadLibrary( libraryFileName );
14
 
}
15
 
 
16
 
 
17
 
DynamicLibraryManager::~DynamicLibraryManager()
18
 
{
19
 
  releaseLibrary();
20
 
}
21
 
 
22
 
 
23
 
DynamicLibraryManager::Symbol 
24
 
DynamicLibraryManager::findSymbol( const std::string &symbol )
25
 
{
26
 
  try
27
 
  {
28
 
    Symbol symbolPointer = doFindSymbol( symbol );
29
 
    if ( symbolPointer != NULL )
30
 
      return symbolPointer;
31
 
  }
32
 
  catch ( ... )
33
 
  {
34
 
  }
35
 
 
36
 
  throw DynamicLibraryManagerException( m_libraryName, 
37
 
                                        symbol,
38
 
                                        DynamicLibraryManagerException::symbolNotFound );
39
 
  return NULL;    // keep compiler happy
40
 
}
41
 
 
42
 
 
43
 
void
44
 
DynamicLibraryManager::loadLibrary( const std::string &libraryName )
45
 
{
46
 
  try
47
 
  {
48
 
    releaseLibrary();
49
 
    m_libraryHandle = doLoadLibrary( libraryName );
50
 
    if ( m_libraryHandle != NULL )
51
 
      return;
52
 
  }
53
 
  catch (...)
54
 
  {
55
 
  }
56
 
 
57
 
  throw DynamicLibraryManagerException( m_libraryName,
58
 
                                        getLastErrorDetail(),
59
 
                                        DynamicLibraryManagerException::loadingFailed );
60
 
}
61
 
 
62
 
 
63
 
void 
64
 
DynamicLibraryManager::releaseLibrary()
65
 
{
66
 
  if ( m_libraryHandle != NULL )
67
 
  {
68
 
    doReleaseLibrary();
69
 
    m_libraryHandle = NULL;
70
 
  }
71
 
}
72
 
 
73
 
 
74
 
CPPUNIT_NS_END
75
 
 
76
 
 
77
 
#endif // !defined(CPPUNIT_NO_TESTPLUGIN)