The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
DLLClassManager Class Reference

#include </builds/gaudi/Gaudi/GaudiCoreSvc/src/ApplicationMgr/DLLClassManager.h>

Inheritance diagram for DLLClassManager:
Collaboration diagram for DLLClassManager:

Public Member Functions

 DLLClassManager (IInterface *iface)
 
StatusCode loadModule (const std::string &module, bool fireIncident=true) override
 
StatusCode queryInterface (const InterfaceID &iid, void **pinterface) override
 implementation of IInterface::queryInterface
 
void const * i_cast (const InterfaceID &iid) const override
 
- Public Member Functions inherited from implements< IClassManager >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
 implements ()=default
 Default constructor.
 
 implements (const implements &)
 Copy constructor (zero the reference count)
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count).
 
unsigned long addRef () const override
 Reference Interface instance.
 
unsigned long release () const override
 Release Interface instance.
 
unsigned long refCount () const override
 Current reference count.
 

Private Attributes

SmartIF< ISvcLocatorm_svclocator
 
SmartIF< IMessageSvcm_msgsvc
 
SmartIF< IInterfacem_pOuter
 

Additional Inherited Members

- Public Types inherited from implements< IClassManager >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
using iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 
- Protected Member Functions inherited from implements< IClassManager >
unsigned long decRef () const override
 
- Protected Attributes inherited from implements< IClassManager >
std::atomic_ulong m_refCount
 Reference counter.
 

Detailed Description

Definition at line 37 of file DLLClassManager.h.

Constructor & Destructor Documentation

◆ DLLClassManager()

DLLClassManager::DLLClassManager ( IInterface * iface)

Definition at line 25 of file DLLClassManager.cpp.

25 : m_svclocator( iface ), m_pOuter( iface ) {
26 assert( m_svclocator.isValid() );
27 addRef(); // Initial count set to 1
28}
SmartIF< ISvcLocator > m_svclocator
SmartIF< IInterface > m_pOuter
unsigned long addRef() const override
Definition implements.h:48

Member Function Documentation

◆ i_cast()

void const * DLLClassManager::i_cast ( const InterfaceID & iid) const
override

Definition at line 76 of file DLLClassManager.cpp.

76 {
77 if ( auto output = base_class::i_cast( iid ) ) return output;
78 // fall back on the owner
79 return m_pOuter->i_cast( iid );
80}
void const * i_cast(const InterfaceID &tid) const override
Definition implements.h:28

◆ loadModule()

StatusCode DLLClassManager::loadModule ( const std::string & module,
bool fireIncident = true )
override

Definition at line 30 of file DLLClassManager.cpp.

30 {
31 // Access the message service if not yet done
33 MsgStream log( m_msgsvc, "DllClassManager" );
34
35 std::string mod = module == "" ? System::moduleNameFull() : module;
36 if ( module == "NONE" ) return StatusCode::SUCCESS;
37
38 void* libHandle = nullptr;
39 StatusCode status = StatusCode::FAILURE;
40 try {
41 status = System::loadDynamicLib( module, &libHandle ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
42 } catch ( const std::exception& excpt ) {
43 if ( m_msgsvc ) { log << MSG::ERROR << "Exception whilst loading " << module << " : " << excpt.what() << endmsg; }
44 status = StatusCode::FAILURE;
45 }
46
47 if ( status.isFailure() ) {
48 // DLL library not loaded
49 log << MSG::ERROR << "Could not load module " << module << endmsg;
50 log << MSG::ERROR << "System Error: " << System::getLastErrorString() << endmsg;
52 }
53 // FIXME this is a hack to avoid a very early call to moduleLoad from
54 // FIXME AppMgr::i_startup
55 if ( fireIncident && !module.empty() ) {
56 // now fire ModuleLoadedIncident
57 const bool CREATEIF( true );
58 auto pIncidentSvc = m_svclocator->service<IIncidentSvc>( "IncidentSvc", CREATEIF );
59 if ( !pIncidentSvc ) {
60 log << MSG::FATAL << "Can not locate IncidentSvc" << endmsg;
61 throw GaudiException( "Error retrieving IncidentSvc", "DLLClassManager::DLLClassManager", StatusCode::FAILURE );
62 }
63 pIncidentSvc->fireIncident( ModuleLoadedIncident( "DLLClassManager", module ) );
64 }
65
67}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
SmartIF< IMessageSvc > m_msgsvc
bool isFailure() const
Definition StatusCode.h:129
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
@ FATAL
Definition IMessageSvc.h:22
@ ERROR
Definition IMessageSvc.h:22
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition System.cpp:115
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition System.cpp:234

◆ queryInterface()

StatusCode DLLClassManager::queryInterface ( const InterfaceID & iid,
void ** pinterface )
override

implementation of IInterface::queryInterface

Definition at line 69 of file DLLClassManager.cpp.

69 {
70 // try local interfaces
71 StatusCode sc = base_class::queryInterface( iid, pinterface );
72 if ( sc.isSuccess() ) return sc;
73 // fall back on the owner
74 return m_pOuter->queryInterface( iid, pinterface );
75}
bool isSuccess() const
Definition StatusCode.h:314
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Definition implements.h:30

Member Data Documentation

◆ m_msgsvc

SmartIF<IMessageSvc> DLLClassManager::m_msgsvc
private

Definition at line 51 of file DLLClassManager.h.

◆ m_pOuter

SmartIF<IInterface> DLLClassManager::m_pOuter
private

Definition at line 52 of file DLLClassManager.h.

◆ m_svclocator

SmartIF<ISvcLocator> DLLClassManager::m_svclocator
private

Definition at line 50 of file DLLClassManager.h.


The documentation for this class was generated from the following files: