DLLClassManager Class Reference

#include <src/ApplicationMgr/DLLClassManager.h>

Inheritance diagram for DLLClassManager:
Collaboration diagram for DLLClassManager:

Public Member Functions

 DLLClassManager (IInterface *iface)
 
virtual ~DLLClassManager ()
 
virtual StatusCode loadModule (const std::string &module, bool fireIncident=true)
 Declare a sharable library to be used for creating instances of a given algorithm type. More...
 
virtual StatusCode queryInterface (const InterfaceID &iid, void **pinterface)
 implementation of IInterface::queryInterface More...
 
- Public Member Functions inherited from extend_interfaces1< IClassManager >
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
virtual ~extend_interfaces1 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IClassManager
 DeclareInterfaceID (IClassManager, 2, 0)
 
 DeclareInterfaceID (IClassManager, 2, 0)
 
- Public Member Functions inherited from IInterface
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
virtual void * i_cast (const InterfaceID &) const =0
 main cast function More...
 
virtual std::vector< std::string > getInterfaceNames () const =0
 Returns a vector of strings containing the names of all the implemented interfaces. More...
 
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long release ()=0
 Release Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 

Private Attributes

SmartIF< ISvcLocatorm_svclocator
 
SmartIF< IMessageSvcm_msgsvc
 
SmartIF< IInterfacem_pOuter
 

Additional Inherited Members

- Public Types inherited from implements1< IClassManager >
typedef implements1 base_class
 Typedef to this class. More...
 
typedef implements1 base_class
 Typedef to this class. More...
 
typedef extend_interfaces1< IClassManagerextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces1< IClassManagerextend_interfaces_base
 Typedef to the base of this class. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
typedef extend_interfaces_base::ext_iids interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces1< IClassManager >
typedef IClassManager::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
typedef IClassManager::iid::iids::type ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
enum  Status {
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR,
  SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR
}
 Return status. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
typedef Gaudi::InterfaceId< IInterface, 0, 0 > iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 

Detailed Description

Definition at line 28 of file DLLClassManager.h.

Constructor & Destructor Documentation

DLLClassManager::DLLClassManager ( IInterface iface)

Definition at line 21 of file DLLClassManager.cpp.

21  {
22  m_pOuter = iface;
24 
25  assert(m_svclocator.isValid());
26 
27  addRef(); // Initial count set to 1
28 }
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:51
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
SmartIF< ISvcLocator > m_svclocator
SmartIF< IInterface > m_pOuter
DLLClassManager::~DLLClassManager ( )
virtual

Definition at line 31 of file DLLClassManager.cpp.

31  {
32 }

Member Function Documentation

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

Declare a sharable library to be used for creating instances of a given algorithm type.

Implements IClassManager.

Definition at line 35 of file DLLClassManager.cpp.

36  {
37  // Access the message service if not yet done already
38  if (!m_msgsvc.isValid()) {
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;
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 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
GAUDI_API const std::string & moduleNameFull()
Get the full name of the (executable/DLL) file.
Definition: ModuleInfo.cpp:78
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:82
SmartIF< IMessageSvc > m_msgsvc
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
fired when a module (DLL) is loaded
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:51
GAUDI_API const std::string getLastErrorString()
Get last system error as string.
Definition: System.cpp:254
GAUDI_API unsigned long loadDynamicLib(const std::string &name, ImageHandle *handle)
Load dynamic link library.
Definition: System.cpp:124
SmartIF< ISvcLocator > m_svclocator
StatusCode DLLClassManager::queryInterface ( const InterfaceID iid,
void **  pinterface 
)
virtual

implementation of IInterface::queryInterface

Implements IInterface.

Definition at line 86 of file DLLClassManager.cpp.

86  {
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 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
SmartIF< IInterface > m_pOuter
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.

Member Data Documentation

SmartIF<IMessageSvc> DLLClassManager::m_msgsvc
private

Definition at line 47 of file DLLClassManager.h.

SmartIF<IInterface> DLLClassManager::m_pOuter
private

Definition at line 48 of file DLLClassManager.h.

SmartIF<ISvcLocator> DLLClassManager::m_svclocator
private

Definition at line 42 of file DLLClassManager.h.


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