[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CL_Library classes




Hi,


Here is my CL_Library classes. The package offers three classes :

- CL_LibraryLoader. This class is jys a wrapper to dlfcn under Linux and GetProcAddress family under Windows. This is the way one would load dynamic libraries with Clanlib.

- CL_LibraryFactory does nothing. It's an abstract base class for every classes that would like to be managed by :

- CL_LibraryManager. This class shouldn't be instancied (it would be pointless as it only defines static methods).

Why did I provide the two latest classes ?

Well loading C code and parsing it to find a symbol is something that dlfnc or GetProcAddress do well because C compilators doesn't decorate symbols with anything as within a C module you can't have two functions with the same name. But C++ allows overloading which mean symbols can't be unique anymore within a module so compilators have to add some garbage codes to the symbol to make it unique. Unfortunately, this a random process that can't be parsed by neither dlfnc nor GetProcAddress. Then the only method to dynamically load classes is to provide a C function within the module that will create an instance of the class.

Therefore, CL_LibraryManager handles all this function within a map. Thus you would use it like thata :

Create a base class that inherits CL_LibraryFactory
Create a class that inherits your base class and put somewhere within the module a function like :


extern "C" MyBaseClass *MyClassMer() { return new MyClass; }

Build your library or dll
Load it with CL_LibraryLoader
Get the name of the maker with resolve()
Add it to the CL_LibraryManager map with add()
Retreive it with get()


I hope everything will be fine with the package.

Bye
- Sylvain Hellegouarch

Attachment: CL_Library.zip
Description: Zip archive

---------------------------------------------------------------------
To unsubscribe, e-mail: clanlib-devel-unsubscribe@clanlib.org
For additional commands, e-mail: clanlib-devel-help@clanlib.org