Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/sys/Plugger.h>
Classes | |
class | Iterator |
class | PathIterator |
Public Types | |
enum | error_t { OK = 0, NO_PLUGIN, NO_HOOK, BAD_VERSION, NO_MAGIC, BAD_PLUGIN, MISSING_DEP } |
typedef enum elm::sys::Plugger::error_t | error_t |
Public Member Functions | |
Plugger (CString hook, const Version &plugger_version, String paths="*") | |
virtual | ~Plugger (void) |
void | addPath (String path) |
void | removePath (String path) |
void | resetPaths (void) |
Plugin * | plug (const string &path) |
Plugin * | plugFile (sys::Path path) |
String | hook (void) const |
string | getLastError (void) |
virtual void | onError (String message) |
virtual void | onWarning (String message) |
error_t | lastError (void) |
String | lastErrorMessage (void) |
Public Member Functions inherited from elm::ErrorBase | |
ErrorBase (ErrorHandler *error_handler=&ErrorHandler::DEFAULT) | |
void | setErrorHandler (ErrorHandler *error_handler) |
ErrorHandler * | getErrorHandler (void) const |
Additional Inherited Members | |
Protected Member Functions inherited from elm::ErrorBase | |
void | onError (error_level_t level, const string &message) |
This class is used for connecting Plugin object from dynamic loaded code unit. The Plugin object is retrieved as a global data matching the hook name passed to the plugger creation. The dynamic loaded code units are retrieved from the paths given to the plugger object. See Plugin.
typedef enum elm::sys::Plugger::error_t elm::sys::Plugger::error_t |
Build a new plugger.
hook | Hook name for retrieving plugin in the code unit. |
plugger_version | Plugger version for compatibility checking. |
_paths | List of path separated by ":" for retrieving the plugin. Pass "*" for initializing with the default system paths. |
References elm::String::indexOf(), elm::sys::Path::PATH_SEPARATOR, and elm::String::substring().
|
virtual |
void elm::sys::Plugger::addPath | ( | String | path | ) |
Add new path for retrieving plugins.
path | Added path. |
string elm::sys::Plugger::getLastError | ( | void | ) |
Return the last produced error.
References BAD_PLUGIN, BAD_VERSION, NO_HOOK, NO_MAGIC, NO_PLUGIN, OK, and elm::StringBuffer::toString().
Referenced by lastErrorMessage().
String elm::sys::Plugger::hook | ( | void | ) | const |
Plugger::error_t elm::sys::Plugger::lastError | ( | void | ) |
Get the last error.
String elm::sys::Plugger::lastErrorMessage | ( | void | ) |
|
virtual |
This method is called when an error arises to let the user display or not the message. As default, the message is displayed on standard error.
message | Message of the error. |
References elm::cerr, and elm::io::endl.
Referenced by plugFile().
|
virtual |
This method is called when a warning arises to let the user display or not the message. As default, the message is displayed on standard error.
message | Message of the warning. |
References elm::cerr, and elm::io::endl.
Get a plugin by its name.
name | Name of the plugin to get (possibly containing '/' to access sub-directories). |
References NO_PLUGIN, OK, elm::sys::PLUG_EXT, plugFile(), elm::String::startsWith(), and elm::StringBuffer::toString().
Referenced by plugFile().
Plug the given file in the plugger.
path | Path of file to plug. |
References elm::_, elm::Version::accepts(), BAD_PLUGIN, BAD_VERSION, elm::sys::fun_suffix, elm::sys::FileItem::get(), elm::io::in, elm::level_error, elm::level_warning, elm::sys::Plugin::MAGIC, elm::MessageException::message(), NO_HOOK, NO_MAGIC, NO_PLUGIN, OK, onError(), elm::sys::Path::parent(), plug(), elm::sys::Plugin::pluggerVersion(), elm::sys::System::readFile(), elm::sys::FileItem::release(), and elm::sys::Path::setExtension().
Referenced by plug().
void elm::sys::Plugger::removePath | ( | String | path | ) |
Remove a path.
path | Removed path. |
void elm::sys::Plugger::resetPaths | ( | void | ) |
Remove all paths.