| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DLLClassManager.cpp
Go to the documentation of this file.
1 // $Id: DLLClassManager.cpp,v 1.17 2007/12/12 16:03:19 marcocle Exp $
2
3 // Include files
4 #include "GaudiKernel/GaudiException.h"
5 #include "GaudiKernel/IService.h"
6 #include "GaudiKernel/ISvcLocator.h"
7 #include "GaudiKernel/IAlgManager.h"
8 #include "GaudiKernel/ISvcManager.h"
9 #include "GaudiKernel/IIncidentSvc.h"
10 #include "GaudiKernel/ModuleIncident.h"
11 #include "GaudiKernel/MsgStream.h"
12 #include "DLLClassManager.h"
13 #include "GaudiKernel/System.h"
14
15 #include "GaudiKernel/IAlgorithm.h"
16
17 #include <iostream>
18 #include <cassert>
19
20 // default creator
21 DLLClassManager::DLLClassManager( IInterface* iface ) {
22 m_pOuter = iface;
23 m_svclocator = m_pOuter;
24
25 assert(m_svclocator.isValid());
26
27 addRef(); // Initial count set to 1
28 }
29
30 // virtual destructor
31 DLLClassManager::~DLLClassManager() {
32 }
33
34 // implementation of IClassManager::loadModule
35 StatusCode DLLClassManager::loadModule( const std::string& module,
36 bool fireIncident ) {
37 // Access the message service if not yet done already
38 if (!m_msgsvc.isValid()) {
39 m_msgsvc = m_svclocator;
40 }
41 MsgStream log(m_msgsvc, "DllClassManager");
42
43 std::string mod = module=="" ? System::moduleNameFull() : module;
44 if( module == "NONE" ) return StatusCode::SUCCESS;
45
46 void* libHandle = 0;
47 StatusCode status = StatusCode::FAILURE;
48 try
49 {
50 status = System::loadDynamicLib( module, &libHandle);
51 }
52 catch ( const std::exception & excpt )
53 {
54 if ( m_msgsvc )
55 {
56 log << MSG::ERROR << "Exception whilst loading " << module << " : " << excpt.what() << endmsg;
57 }
58 status = StatusCode::FAILURE;
59 }
60
61 if( status.isFailure() ) {
62 // DLL library not loaded
63 log << MSG::ERROR << "Could not load module " << module << endmsg;
64 log << MSG::ERROR << "System Error: " << System::getLastErrorString() << endmsg;
65 return StatusCode::FAILURE;
66 }
67 //FIXME this is a hack to avoid a very early call to moduleLoad from
68 //FIXME AppMgr::i_startup
69 if (fireIncident && module != "") {
70 //now fire ModuleLoadedIncident
71 const bool CREATEIF(true);
72 SmartIF<IIncidentSvc> pIncidentSvc(m_svclocator->service("IncidentSvc", CREATEIF));
73 if( !pIncidentSvc.isValid() ) {
74 log << MSG::FATAL << "Can not locate IncidentSvc" << endmsg;
75 throw GaudiException("Error retrieving IncidentSvc",
76 "DLLClassManager::DLLClassManager", StatusCode::FAILURE);
77 }
78 pIncidentSvc->fireIncident(ModuleLoadedIncident("DLLClassManager",
79 module) );
80 }
81
82 return StatusCode::SUCCESS;
83 }
84
85 // implementation of IInterface::queryInterface
86 StatusCode DLLClassManager::queryInterface(const InterfaceID& iid, void** pinterface) {
87 // try local interfaces
88 StatusCode sc = base_class::queryInterface(iid, pinterface);
89 if (sc.isSuccess()) return sc;
90 // fall back on the owner
91 return m_pOuter->queryInterface(iid, pinterface);
92 }