The Gaudi Framework  master (37c0b60a)
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 More...
 
- Public Member Functions inherited from implements< IClassManager >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 implements ()=default
 Default constructor. More...
 
 implements (const implements &)
 Copy constructor (zero the reference count) More...
 
implementsoperator= (const implements &)
 Assignment operator (do not touch the reference count). More...
 
unsigned long addRef () override
 Reference Interface instance
More...
 
unsigned long release () override
 Release Interface instance
More...
 
unsigned long refCount () const override
 Current reference count
More...
 

Private Attributes

SmartIF< ISvcLocatorm_svclocator
 
SmartIF< IMessageSvcm_msgsvc
 
SmartIF< IInterfacem_pOuter
 

Additional Inherited Members

- Public Types inherited from implements< IClassManager >
using base_class = implements< Interfaces... >
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
using iids = typename extend_interfaces_base::ext_iids
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Attributes inherited from implements< IClassManager >
std::atomic_ulong m_refCount
 Reference counter
More...
 

Detailed Description

Definition at line 38 of file DLLClassManager.h.

Constructor & Destructor Documentation

◆ DLLClassManager()

DLLClassManager::DLLClassManager ( IInterface iface)

Definition at line 30 of file DLLClassManager.cpp.

30  {
31  m_pOuter = iface;
33 
34  assert( m_svclocator.isValid() );
35 
36  addRef(); // Initial count set to 1
37 }

Member Function Documentation

◆ loadModule()

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

Definition at line 40 of file DLLClassManager.cpp.

40  {
41  // Access the message service if not yet done already
42  if ( !m_msgsvc ) m_msgsvc = m_svclocator;
43  MsgStream log( m_msgsvc, "DllClassManager" );
44 
45  std::string mod = module == "" ? System::moduleNameFull() : module;
46  if ( module == "NONE" ) return StatusCode::SUCCESS;
47 
48  void* libHandle = nullptr;
50  try {
51  status = System::loadDynamicLib( module, &libHandle ) ? StatusCode::SUCCESS : StatusCode::FAILURE;
52  } catch ( const std::exception& excpt ) {
53  if ( m_msgsvc ) { log << MSG::ERROR << "Exception whilst loading " << module << " : " << excpt.what() << endmsg; }
54  status = StatusCode::FAILURE;
55  }
56 
57  if ( status.isFailure() ) {
58  // DLL library not loaded
59  log << MSG::ERROR << "Could not load module " << module << endmsg;
60  log << MSG::ERROR << "System Error: " << System::getLastErrorString() << endmsg;
61  return StatusCode::FAILURE;
62  }
63  // FIXME this is a hack to avoid a very early call to moduleLoad from
64  // FIXME AppMgr::i_startup
65  if ( fireIncident && !module.empty() ) {
66  // now fire ModuleLoadedIncident
67  const bool CREATEIF( true );
68  auto pIncidentSvc = m_svclocator->service<IIncidentSvc>( "IncidentSvc", CREATEIF );
69  if ( !pIncidentSvc ) {
70  log << MSG::FATAL << "Can not locate IncidentSvc" << endmsg;
71  throw GaudiException( "Error retrieving IncidentSvc", "DLLClassManager::DLLClassManager", StatusCode::FAILURE );
72  }
73  pIncidentSvc->fireIncident( ModuleLoadedIncident( "DLLClassManager", module ) );
74  }
75 
76  return StatusCode::SUCCESS;
77 }

◆ queryInterface()

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

implementation of IInterface::queryInterface

Definition at line 80 of file DLLClassManager.cpp.

80  {
81  // try local interfaces
82  StatusCode sc = base_class::queryInterface( iid, pinterface );
83  if ( sc.isSuccess() ) return sc;
84  // fall back on the owner
85  return m_pOuter->queryInterface( iid, pinterface );
86 }

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:
implements::queryInterface
StatusCode queryInterface(const InterfaceID &ti, void **pp) override
Implementation of IInterface::queryInterface.
Definition: implements.h:30
System::loadDynamicLib
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition: System.cpp:150
std::string
STL class.
std::exception
STL class.
Gaudi.Configuration.log
log
Definition: Configuration.py:28
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
GaudiException
Definition: GaudiException.h:31
System::moduleNameFull
GAUDI_API const std::string & moduleNameFull()
Get the full name of the (executable/DLL) file.
Definition: ModuleInfo.cpp:87
DLLClassManager::m_svclocator
SmartIF< ISvcLocator > m_svclocator
Definition: DLLClassManager.h:50
Gaudi.CommonGaudiConfigurables.mod
mod
Definition: CommonGaudiConfigurables.py:39
DLLClassManager::m_pOuter
SmartIF< IInterface > m_pOuter
Definition: DLLClassManager.h:52
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:72
StatusCode
Definition: StatusCode.h:65
DLLClassManager::m_msgsvc
SmartIF< IMessageSvc > m_msgsvc
Definition: DLLClassManager.h:51
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
MsgStream
Definition: MsgStream.h:33
ModuleLoadedIncident
fired when a module (DLL) is loaded
Definition: ModuleIncident.h:53
MSG::FATAL
@ FATAL
Definition: IMessageSvc.h:25
implements< IClassManager >::addRef
unsigned long addRef() override
Reference Interface instance
Definition: implements.h:48
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
std::string::empty
T empty(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
System::getLastErrorString
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition: System.cpp:279
IIncidentSvc
Definition: IIncidentSvc.h:33
std::exception::what
T what(T... args)