Classes | |
struct | cllite::classname_to_dllname |
A basic classname-to-DLL-name transformer. More... | |
Typedefs | |
typedef std::string | key_type |
The lookup key type used by classloaders in cllite. | |
Functions | |
s11n::path_finder & | class_path () |
Returns this library's class search-path. | |
std::string | open_dll (const std::string &basename) |
Tries to open a DLL named basename, which should be either an absolute path/filename or a partial filename, without path and extension parts. | |
template<typename NameTransformer> std::string | open_dll (const std::string &key, const NameTransformer &trans) |
Returns open_dll( trans(key) ). | |
const char * | dll_error () |
Returns the same thing as the underlying dlerror() implementation. | |
template<typename BaseType> s11n::class_loader< BaseType > & | classloader () |
Returns the BaseType classloader, as selected by the classloader_selector<BaseType> class. | |
template<typename BaseType> BaseType * | classload (const key_type &key) |
Tries to load the class named 'key' from BaseType's classloader. | |
template<typename BaseType> s11n::class_loader< BaseType, key_type, true > & | classloader_shared () |
Similar to classloader(), but the object it returns serves shared instances of objects. | |
template<typename BaseType> BaseType * | classload_shared (const key_type &key) |
Similar to classload(), but objects returned by this function are NOT owned by the caller: the classloader cleans them up when it is destroyed (post-main()). | |
template<typename BaseType> void | register_factory (const key_type &key, BaseType *(*factory)()) |
Registers key with a factory returning (BaseType *). | |
template<typename BaseType, typename SubType> void | register_factory (const key_type &key) |
Registers a default factory for creating (SubType *) returned as (BaseType *). | |
template<typename BaseType> void | register_base (const key_type &key) |
Registers a default factory for BaseType. | |
template<typename BaseType> void | register_abstract_base (const key_type &key) |
Registers BaseType as an abstract base class. | |
template<typename BaseType> void | alias (const key_type &thealias, const key_type &isthesameas) |
Aliases thealias to be functionally equivalent to isthesameas for BaseType's classloader. |
It's intention is to provide the mostly-used class_loader<> functionality under one roof, and simplify it's interface.
As of the introduction of cllite, the former dll_loader class is deprecated in favour of the functions in this namespace. The brief reason is that class_loader and dll_loader are not 100% usage-compatible, often causing some additional work in client code. The functions in this namespace provide more flexible DLL support than dll_loader without having to implement a class_loader subtype to do it. This code also demonstrates how class_loader can transparently work with arbitrary client-side DLL-opening code (reminder: class_loader requires NO special symbols in a DLL, as conventional classloaders do).
|
The lookup key type used by classloaders in cllite. Note that non-string types do not generically make sense in this context because DLL-awareness only works for strings. Why? Consider: how do we load a DLL using an arbitrary non-string lookup key without imposing some type of translation conventions on clients? |
|
Aliases thealias to be functionally equivalent to isthesameas for BaseType's classloader. This feature is useful for, e.g., assigning "friendly" or configurable names for a given application element. e.g., consider the option of registering "DefaultDocumentClass" as an alias for some subtype of Document. This allows down-stream code to use symbolic names for loading application-specific types, as opposed to having to know the types real names. |
|
Returns this library's class search-path. It is up to specific classloaders to use or ignore this path: it is a suggestion, and not a rule. Clients are free to modify the returned object. |
|
Tries to load the class named 'key' from BaseType's classloader. If no such class is registered a DLL search is initiated to find the class, using a default classname-to-DLL-name translator. The caller owns the returned pointer, which may be 0 (indicating the classloader could not find the DLL). Definition at line 217 of file cllite.h. References s11n::class_loader< BaseType, KeyType, UseSharedInstances >::load(), and open_dll(). |
|
Returns the BaseType classloader, as selected by the classloader_selector<BaseType> class. Note that this object itself is not DLL-aware: use classload() to enable DLL lookups for missing classes. |
|
Returns the same thing as the underlying dlerror() implementation. Just as dlerror() does, this function will return NULL if called twice in a row. That is, it's error code is only valid once, and then it will return NULL until another error happens. |
|
Tries to open a DLL named basename, which should be either an absolute path/filename or a partial filename, without path and extension parts. class_path() will be used to resolve the full file name. Returns the path to the DLL, if one was found and opened, or an empty string on error. Reminder: the classloader architecture is such that simply opening a DLL is enough to trigger any classloader registrations which might live in it. Referenced by classload(), classload_shared(), and open_dll(). |
|
Registers BaseType as an abstract base class. Use this for abstract base types, so that they get a working factory (i.e., one which always returns 0, since 'new BaseType' will not work for abstract types). Definition at line 303 of file cllite.h. References register_factory(). |