DLC Toolkit homepage

Welcome to the Dynamically Linked Class toolkit
This page is hosted thanks to SourceForge.net's help so please support them as they support us :
SourceForge.net Logo

This page is no longer maintained. An up-to-date version of DLC is now hosted in Massive G Engine's CVS repository (/mgengine/inc/dlc/).

Examples using DLC and a Doxygen config file to build the documentation might still be retrieved in the archive on DLC's project page on SourceForge. Be warned though that the two main DLC files in that archive (dlc.h and dlcDynamic.h) are outdated so don't mess up with versions.

What DLC is about...

DLC is a small toolkit for C++ developpers willing to dynamically load classes in their program. It currently works fine on Windows and x86 Linux platforms. It supposedly works on other Linux-flavour platforms but hasn't been tested yet. Please report if you tried it on another platform.
It consists of two header files dlc.h and dlcDynamic.h. The file dlc.h declares the pure static template class dlc<...> and some preprocessor macros for instantiating that class and declaring dynamic classes. The file dlcDynamic.h declares the DLC_DYNAMIC macro which can be used to automatically import or export symbols, including classes, when you want your program to compile on Windows. The only thing the programmer has to do is to indicate wich component is being compiled and wich component is being declared by defining a value for DLC_COMPILED_COMPONENT and DLC_DECLARED_COMPONENT.

How it works...

Dynamic classes have to be compiled in a dynamic library (.dll for Windows, .so for Linux) named after the name of the class (i.e. "my_class.so" for class "my_class"). They have to inherit from an interface class (rather a pure virtual one) chosen by the user and wich will be used as first argument of the dlc template class.
The instantiated dlc template class will then provide a direct map between the name of the class (stored in a C character string) and a way to build an object of that class, even without linking the so-called class to the program using it. Only the interface class has to be known when building the program.
Since there is no general way to map a C++ method name to it's name inside the library, the toolkit uses a factory function exported into the library in a C-style so as to be able to retrieve the address of that function. A factory function is a function returning the address of a newly built object. The fact that it is externally a C-style function doesn't actually mean that its code is not in C++. Many papers can be found on the Internet explaining this process. However, heritage between dynamic classes for now is only possible by compiling the classes with the same compiler.
Once your classes are build, it is possible to retrieve the address of a new object of any of those classes through the method dlc<interface_class, n_args, args_types>( "class_name", factory_args ).

Licensing information...

The DLC toolkit is released under the terms of the GNU Lesser General Public License.
Its documentation is released under the GNU Free Documentation License.