Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Plugger Class Reference

#include <elm/sys/Plugger.h>

+ Inheritance diagram for Plugger:

Classes

class  Iter
 
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)
 
Pluginplug (const string &path)
 
PluginplugFile (sys::Path path)
 
String hook (void) const
 
string getLastError (void)
 
bool quiet (void) const
 
void setQuiet (bool quiet)
 
bool isPlugged (string name) const
 
virtual void onError (String message)
 
virtual void onWarning (String message)
 
error_t lastError (void)
 
String lastErrorMessage (void)
 
const Vector< string > & paths () const
 
Range< Iteravailable ()
 
const Vector< Plugin * > & plugged () const
 
- Public Member Functions inherited from ErrorBase
 ErrorBase (ErrorHandler *error_handler=&ErrorHandler::DEFAULT)
 
void setErrorHandler (ErrorHandler *error_handler)
 
ErrorHandlergetErrorHandler (void) const
 

Additional Inherited Members

- Protected Member Functions inherited from ErrorBase
void onError (error_level_t level, const string &message)
 

Detailed Description

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.

Member Typedef Documentation

◆ error_t

Member Enumeration Documentation

◆ error_t

enum error_t
Enumerator
OK 
NO_PLUGIN 
NO_HOOK 
BAD_VERSION 
NO_MAGIC 
BAD_PLUGIN 
MISSING_DEP 

Constructor & Destructor Documentation

◆ Plugger()

Plugger ( CString  hook,
const Version plugger_version,
String  paths = "*" 
)

Build a new plugger.

Parameters
hookHook name for retrieving plugin in the code unit.
plugger_versionPlugger version for compatibility checking.
_pathsList of path separated by ":" for retrieving the plugin. Pass "*" for initializing with the default system paths.

References Vector< T, E, A >::indexOf(), Path::PATH_SEPARATOR, and Plugger::paths().

◆ ~Plugger()

~Plugger ( void  )
virtual

Member Function Documentation

◆ addPath()

void addPath ( String  path)

Add new path for retrieving plugins.

Parameters
pathAdded path.

◆ available()

Range< Iter > available ( )
inline

Get the list of the names of available plug-ins (may be not already plugged).

Returns
List of names of the available plug-ins.

References elm::range().

◆ getLastError()

string getLastError ( void  )

◆ hook()

String hook ( void  ) const
inline

◆ isPlugged()

bool isPlugged ( string  name) const

Test if the named plug-in is plugged.

Parameters
nameName of the plug-in.
Returns
True if the plug-in is plugged, false else.

References elm::io::p(), and Plugger::plugged().

◆ lastError()

Plugger::error_t lastError ( void  )

Get the last error.

Returns
Last error.

References elm::io::err.

◆ lastErrorMessage()

String lastErrorMessage ( void  )

Get the message for the last error.

Returns
Error message.
Deprecated:

References Plugger::getLastError().

◆ onError()

void onError ( String  message)
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.

Parameters
messageMessage of the error.
Deprecated:

References elm::cerr, and elm::io::endl.

Referenced by Plugger::plugFile().

◆ onWarning()

void onWarning ( String  message)
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.

Parameters
messageMessage of the warning.
Deprecated:

References elm::cerr, and elm::io::endl.

Referenced by Plugger::plugFile().

◆ paths()

const Vector< string > & paths ( ) const
inline

Get the list of direcory paths used to retrieve plug-ins.

Returns
List of plug-ins paths.

Referenced by Plugger::Plugger().

◆ plug()

Plugin * plug ( const string name)

Get a plugin by its name.

Parameters
nameName of the plugin to get (possibly containing '/' to access sub-directories).
Returns
Found plugin or null.

References Plugger::NO_PLUGIN, Plugger::OK, elm::sys::PLUG_EXT, Plugger::plugFile(), String::startsWith(), and StringBuffer::toString().

Referenced by Plugger::plugFile().

◆ plugFile()

◆ plugged()

const Vector<Plugin *>& plugged ( ) const
inline

Referenced by Plugger::isPlugged().

◆ quiet()

bool quiet ( void  ) const
inline

Test if the plugger emit or not message error during plugin operation.

Returns
True for quiet, false else.

Referenced by Plugger::setQuiet().

◆ removePath()

void removePath ( String  path)

Remove a path.

Parameters
pathRemoved path.

◆ resetPaths()

void resetPaths ( void  )

Remove all paths.

◆ setQuiet()

void setQuiet ( bool  quiet)
inline

Set the quiet mode of the plugger. If set to true, the plugger will no more emit error messages during plugin operation.

Parameters
quietTrue for quiet mode, false else.

References Plugger::quiet().


The documentation for this class was generated from the following files: