5 // class DLLManager is the simple ELF C++ Library manager.
7 // It tries to dynamically load the specified shared library
8 // when it is construted.
10 // You should call LastError() before doing anything. If it
11 // returns NULL there is no error.
18 DLLManager( const char *fname );
19 virtual ~DLLManager();
22 bool GetSymbol( void **, const char *sym_name );
24 const char *LastError()
36 // class DLLFactoryBase is the base class used for the DLLFactory
39 // It inherits from the DLLManager class and must be constructed with
40 // the file name of the shared library and the function name within that
41 // library which will create the desired C++ factory class.
42 // If you do not provide func_name to the constructor, it defaults to
43 // the undecorated "C" symbol "factory0"
45 // factory_func will be set to a pointer to the requested factory creator
46 // function. If there was an error linking to the shared library,
47 // factory_func will be 0.
49 // You can call 'LastError()' to find the error message that occurred.
53 class DLLFactoryBase : public DLLManager
58 const char *func_name=0
61 virtual ~DLLFactoryBase();
63 void * (*factory_func)(void);
68 // The DLLFactory template class inherits from DLLFactoryBase.
69 // The constructor takes the file name of the shared library
70 // and the undecorated "C" symbol name of the factory creator
71 // function. The factory creator function in your shared library
72 // MUST either return a pointer to an object that is a subclass
73 // of 'T' or it must return 0.
75 // If everything is cool, then 'factory' will point to the
76 // requested factory class. If not, it will be 0.
78 // Since the DLLFactory template ultimately inherits DLLManager,
79 // you can call LastError() to get any error code information
81 // The created factory is OWNED by the DLLFactory class.
82 // The created factory will get deleted when the DLLFactory class
83 // is deleted, because the DLL will get unloaded as well.
87 class DLLFactory : public DLLFactoryBase
92 const char *func_name=0
93 ) : DLLFactoryBase( fname, func_name )
96 factory = (T *)factory_func();