LRAUV  revA
LoadedModule.h
Go to the documentation of this file.
1 
10 #ifndef LOADEDMODULE_H_
11 #define LOADEDMODULE_H_
12 
13 #ifndef WINNT
14 #include <dlfcn.h>
15 #endif
16 
17 #include "Module.h"
18 
26 {
27 public:
28  LoadedModule( Module *module, destroy_module_t* destroyModule, void* lib )
29  : module_( module ),
30  destroyModule_( destroyModule ),
31  lib_( lib )
32  {}
33  ;
34 
35  virtual ~LoadedModule()
36  {
37  if( destroyModule_ && module_ )
38  {
39  // Destroy the object
41  }
42  else if( module_ )
43  {
44  // Delete the (most likely scripted) object
45  delete module_;
46  }
47 
48  if( lib_ )
49  {
50  // Close the library
51 #ifndef WINNT
52  // Comment this line out to see symbols in Valgrind memory leaks
53  dlclose( lib_ );
54 #endif
55  //printf( "Closed library at 0X%08x\n", (int)lib_ );
56  lib_ = 0;
57  }
58  };
59 
60  Module* getModule( void )
61  {
62  return module_;
63  }
64 
65 protected:
66 
69  void* lib_;
70 
71 private:
72  // Note that the copy constructor below is private and not given a body.
73  // Any attempt to call it will return a compiler error.
74  LoadedModule( const LoadedModule& old ); // disallow copy constructor
75 
76 };
77 
80 
81 #endif /*LOADEDMODULE_H_*/
Module * module_
Definition: LoadedModule.h:67
Module * getModule(void)
Definition: LoadedModule.h:60
Contains information about a currently loaded module, including the shared library and destroy method...
Definition: LoadedModule.h:25
Module is the abstract base class for a collection of Component objects that can be contained in a lo...
Definition: Module.h:45
virtual ~LoadedModule()
Definition: LoadedModule.h:35
LoadedModule(Module *module, destroy_module_t *destroyModule, void *lib)
Definition: LoadedModule.h:28
Contains the Module class definition.
void destroy_module_t(Module *)
destroy_module must be implemented, following the class implementation: extern "C" void destroy(Modul...
Definition: Module.h:102
destroy_module_t * destroyModule_
Definition: LoadedModule.h:68
void * lib_
Definition: LoadedModule.h:69
FlexArray< LoadedModule * > ListOfLoadedModulePtrs
Define a type for a "list of loaded module pointers".
Definition: LoadedModule.h:79