Cat
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DLLMgr Class Reference

#include <inc/DLLMgr.h>

Public Member Functions

 DLLMgr ()
 Standard constructor. More...
 
virtual ~DLLMgr ()
 Destructor. More...
 
StatusCode load (std::string)
 
StatusCode unload (std::string)
 
DLLdll (std::string)
 
std::vector< DLL * > dlls (std::string)
 
DLLlibraryOfObject (std::string)
 
ElementcreateElement (std::string)
 
StatusCode destroy (Element *)
 
ProcessuscreateProcessus (std::string)
 
StatusCode destroy (Processus *)
 
void print ()
 

Private Member Functions

void verbose (std::string msg)
 
void debug (std::string msg)
 
void info (std::string msg)
 
void warning (std::string msg)
 
void fatal (std::string msg)
 
void verbose (std::string msg, std::string name)
 
void debug (std::string msg, std::string name)
 
void info (std::string msg, std::string name)
 
void warning (std::string msg, std::string name)
 
void fatal (std::string msg, std::string name)
 

Private Attributes

MsgSvc m_log
 
std::vector< DLL * > m_dlls
 

Detailed Description

Manager of the DLL for the Application

Author
Frederic Machefert
Date
2006-10-25

Definition at line 19 of file DLLMgr.h.

Constructor & Destructor Documentation

◆ DLLMgr()

DLLMgr::DLLMgr ( )

Standard constructor.

Definition at line 20 of file DLLMgr.cpp.

20  {
21 
22 }

◆ ~DLLMgr()

DLLMgr::~DLLMgr ( )
virtual

Destructor.

Definition at line 26 of file DLLMgr.cpp.

26 {}

Member Function Documentation

◆ createElement()

Element * DLLMgr::createElement ( std::string  name)

Build an element from the manager

Definition at line 128 of file DLLMgr.cpp.

References DLL::createElement(), and libraryOfObject().

Referenced by Application::create(), dlls(), and export_base().

128  {
129  DLL* lib = libraryOfObject(name);
130  if ( 0!=lib ){
131  return lib->createElement( name );
132  }
133  return NULL;
134 }
Element * createElement(std::string)
Definition: DLL.cpp:278
DLL * libraryOfObject(std::string)
Definition: DLLMgr.cpp:98
Definition: DLL.h:57

◆ createProcessus()

Processus * DLLMgr::createProcessus ( std::string  name)

create a processus from the manager

Definition at line 139 of file DLLMgr.cpp.

References DLL::createProcessus(), and libraryOfObject().

Referenced by dlls(), and export_base().

139  {
140  DLL* lib = libraryOfObject(name);
141  if ( 0!=lib ){
142  return lib->createProcessus( name );
143  }
144  return NULL;
145 }
DLL * libraryOfObject(std::string)
Definition: DLLMgr.cpp:98
Processus * createProcessus(std::string)
Definition: DLL.cpp:297
Definition: DLL.h:57

◆ debug() [1/2]

void DLLMgr::debug ( std::string  msg)
inlineprivate

Definition at line 85 of file DLLMgr.h.

References MsgSvc::DEBUG, and MsgSvc::msgSvc().

85 { m_log.msgSvc (MsgSvc::DEBUG , msg, std::string("DLL") ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ debug() [2/2]

void DLLMgr::debug ( std::string  msg,
std::string  name 
)
inlineprivate

Definition at line 91 of file DLLMgr.h.

References MsgSvc::DEBUG, and MsgSvc::msgSvc().

91 { m_log.msgSvc (MsgSvc::DEBUG , msg, name ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ destroy() [1/2]

StatusCode DLLMgr::destroy ( Element element)

Delete an element from the manager

Definition at line 150 of file DLLMgr.cpp.

References DLL::destroy(), StatusCode::FAILURE, libraryOfObject(), StatusCode::SUCCESS, and Object::type().

Referenced by dlls(), and export_base().

150  {
151  DLL* mydll = libraryOfObject( element->type () );
152  if ( 0 != mydll ) {
153  mydll->destroy(element);
154  return StatusCode::SUCCESS;
155  }
156  return StatusCode::FAILURE;
157 }
DLL * libraryOfObject(std::string)
Definition: DLLMgr.cpp:98
Definition: DLL.h:57
StatusCode destroy(Element *)
Definition: DLL.cpp:316
std::string type()
Definition: Object.h:29

◆ destroy() [2/2]

StatusCode DLLMgr::destroy ( Processus proc)

Delete a processus from the manager

Definition at line 162 of file DLLMgr.cpp.

References DLL::destroy(), StatusCode::FAILURE, libraryOfObject(), StatusCode::SUCCESS, and Object::type().

162  {
163  DLL* mydll = libraryOfObject(proc->type());
164  if ( 0 != mydll ) {
165  mydll->destroy(proc);
166  return StatusCode::SUCCESS;
167  }
168  return StatusCode::FAILURE;
169 }
DLL * libraryOfObject(std::string)
Definition: DLLMgr.cpp:98
Definition: DLL.h:57
StatusCode destroy(Element *)
Definition: DLL.cpp:316
std::string type()
Definition: Object.h:29

◆ dll()

DLL * DLLMgr::dll ( std::string  lib)

find dll objects from its name

Definition at line 113 of file DLLMgr.cpp.

References m_dlls.

Referenced by export_base(), and load().

113  {
114  std::vector<DLL*>::const_iterator iter ;
115  for ( iter = m_dlls.begin() ;
116  iter != m_dlls.end() ;
117  ++iter ) {
118  if ( 0==lib.compare( (*iter)->name() ) ){
119  return (*iter);
120  }
121  }
122  return NULL;
123 }
std::vector< DLL * > m_dlls
Definition: DLLMgr.h:96

◆ dlls()

std::vector<DLL*> DLLMgr::dlls ( std::string  )
inline

find dll objects from its name

Definition at line 45 of file DLLMgr.h.

References createElement(), createProcessus(), destroy(), libraryOfObject(), m_dlls, and print().

Referenced by export_base().

46  {
47  return m_dlls;
48  }
std::vector< DLL * > m_dlls
Definition: DLLMgr.h:96

◆ fatal() [1/2]

void DLLMgr::fatal ( std::string  msg)
inlineprivate

Definition at line 88 of file DLLMgr.h.

References MsgSvc::FATAL, and MsgSvc::msgSvc().

88 { m_log.msgSvc (MsgSvc::FATAL , msg, std::string("DLL") ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ fatal() [2/2]

void DLLMgr::fatal ( std::string  msg,
std::string  name 
)
inlineprivate

Definition at line 94 of file DLLMgr.h.

References MsgSvc::FATAL, and MsgSvc::msgSvc().

94 { m_log.msgSvc (MsgSvc::FATAL , msg, name ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ info() [1/2]

void DLLMgr::info ( std::string  msg)
inlineprivate

Definition at line 86 of file DLLMgr.h.

References MsgSvc::INFO, and MsgSvc::msgSvc().

Referenced by load().

86 { m_log.msgSvc (MsgSvc::INFO , msg, std::string("DLL") ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ info() [2/2]

void DLLMgr::info ( std::string  msg,
std::string  name 
)
inlineprivate

Definition at line 92 of file DLLMgr.h.

References MsgSvc::INFO, and MsgSvc::msgSvc().

92 { m_log.msgSvc (MsgSvc::INFO , msg, name ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ libraryOfObject()

DLL * DLLMgr::libraryOfObject ( std::string  obj)

find DLL which contains objects type

Definition at line 98 of file DLLMgr.cpp.

References m_dlls.

Referenced by createElement(), createProcessus(), destroy(), dlls(), and export_base().

98  {
99  std::vector<DLL*>::const_iterator iter ;
100  for ( iter = m_dlls.begin() ;
101  iter != m_dlls.end() ;
102  ++iter ) {
103  if ( (*iter)->containsObject( obj ) ){
104  return (*iter);
105  }
106  }
107  return NULL;
108 }
std::vector< DLL * > m_dlls
Definition: DLLMgr.h:96
def obj()
Definition: shell.py:26

◆ load()

StatusCode DLLMgr::load ( std::string  library)

load a DLL and stores its entry point

Definition at line 32 of file DLLMgr.cpp.

References dll(), StatusCode::FAILURE, info(), StatusCode::isSuccess(), DLL::load(), m_dlls, DLL::objectList(), StatusCode::SUCCESS, and warning().

Referenced by export_base().

32  {
33  // load library
34  info("Loading dll "+library+".","DLLMgr::load");
35 
36  DLL *mydll = new DLL ();
37  // look if we can load the library
38  if ( mydll->load ( library ).isSuccess() ){
39  info("Library "+library+" loaded.");
40  // look for duplication of library
41  if ( 0!=dll(library) ){
42  warning("DLL "+library+" already loaded. Cannot load library.","DLLMgr::loadDLL");
43  delete mydll;
44  return StatusCode::FAILURE;
45  }
46  // look for duplication of objects
47  std::vector<std::string> list = mydll->objectList();
48  std::vector<DLL*>::const_iterator iter ;
49  std::vector<std::string>::const_iterator objs ;
50  for ( objs=list.begin() ;
51  objs!=list.end() ;
52  ++objs ) {
53  for ( iter = m_dlls.begin() ;
54  iter != m_dlls.end() ;
55  ++iter ) {
56  if ( (*iter)->containsObject( *objs ) ){
57  warning("The DLL "+library+" contains an object ("+
58  (*objs) +" which has already been loaded from "+
59  (*iter)->name()+". Cannot load library.",
60  "DLLMgr::loadDLL");
61  delete mydll;
62  return StatusCode::FAILURE;
63  }
64  }
65  }
66  // everything is ok. definitely keep the new library in the manager
67  m_dlls.push_back ( mydll );
68  return StatusCode::SUCCESS;
69  }
70  // could not even find the library
71  warning("The DLL "+library+" could not be properly loaded.","DLLMgr::loadDLL");
72  delete mydll;
73  return StatusCode::FAILURE;
74 }
std::vector< std::string > objectList()
Definition: DLL.cpp:55
void info(std::string msg)
Definition: DLLMgr.h:86
void warning(std::string msg)
Definition: DLLMgr.h:87
std::vector< DLL * > m_dlls
Definition: DLLMgr.h:96
Definition: DLL.h:57
bool isSuccess() const
Definition: StatusCode.h:64
DLL * dll(std::string)
Definition: DLLMgr.cpp:113
StatusCode load(std::string)
Definition: DLL.cpp:118

◆ print()

void DLLMgr::print ( )

Definition at line 174 of file DLLMgr.cpp.

References m_dlls.

Referenced by dlls(), and export_base().

175 {
176  std::vector<DLL*>::iterator iter ;
177  for ( iter = m_dlls.begin() ;
178  iter != m_dlls.end() ;
179  ++iter ) {(*iter)->print();}
180 }
std::vector< DLL * > m_dlls
Definition: DLLMgr.h:96

◆ unload()

StatusCode DLLMgr::unload ( std::string  lib)

unload a DLL and removes its entry point from the list

Definition at line 79 of file DLLMgr.cpp.

References m_dlls.

Referenced by export_base().

79  {
80  std::vector<DLL*>::iterator dlltoremove;
81  std::vector<DLL*>::iterator iter ;
82  for ( iter = m_dlls.begin() ;
83  iter != m_dlls.end() ;
84  ++iter ) {
85  if ( 0==lib.compare((*iter)->name()) ) {
86  (*iter)->unload();
87  dlltoremove = iter;
88  }
89  delete *dlltoremove;
90  m_dlls.erase(dlltoremove);
91  }
92  return NULL;
93 }
std::vector< DLL * > m_dlls
Definition: DLLMgr.h:96

◆ verbose() [1/2]

void DLLMgr::verbose ( std::string  msg)
inlineprivate

Definition at line 84 of file DLLMgr.h.

References MsgSvc::msgSvc(), and MsgSvc::VERBOSE.

84 { m_log.msgSvc (MsgSvc::VERBOSE , msg, std::string("DLL") ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ verbose() [2/2]

void DLLMgr::verbose ( std::string  msg,
std::string  name 
)
inlineprivate

Definition at line 90 of file DLLMgr.h.

References MsgSvc::msgSvc(), and MsgSvc::VERBOSE.

90 { m_log.msgSvc (MsgSvc::VERBOSE , msg, name ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ warning() [1/2]

void DLLMgr::warning ( std::string  msg)
inlineprivate

Definition at line 87 of file DLLMgr.h.

References MsgSvc::msgSvc(), and MsgSvc::WARNING.

Referenced by load().

87 { m_log.msgSvc (MsgSvc::WARNING , msg, std::string("DLL") ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

◆ warning() [2/2]

void DLLMgr::warning ( std::string  msg,
std::string  name 
)
inlineprivate

Definition at line 93 of file DLLMgr.h.

References MsgSvc::msgSvc(), and MsgSvc::WARNING.

93 { m_log.msgSvc (MsgSvc::WARNING , msg, name ); }
MsgSvc m_log
Definition: DLLMgr.h:82
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42

Member Data Documentation

◆ m_dlls

std::vector<DLL*> DLLMgr::m_dlls
private

Definition at line 96 of file DLLMgr.h.

Referenced by dll(), dlls(), libraryOfObject(), load(), print(), and unload().

◆ m_log

MsgSvc DLLMgr::m_log
private

Definition at line 82 of file DLLMgr.h.


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