LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
IScriptLoaderInstance Class Referenceabstract

Interface for script loaders. More...

#include "iscriptloader.h"

Public Member Functions

virtual ~IScriptLoaderInstance ()
 
virtual QObject * GetQObject ()=0
 Returns this loader instance as a QObject. More...
 
virtual void AddGlobalPrefix ()=0
 Adds a global load prefix. More...
 
virtual void AddLocalPrefix (QString prefix=QString())=0
 Adds a local load prefix. More...
 
virtual QStringList EnumerateScripts () const =0
 Lists all available scripts. More...
 
virtual QVariantMap GetScriptInfo (const QString &script)=0
 Returns the metadata of the given script. More...
 
virtual IScript_ptr LoadScript (const QString &script)=0
 Loads the given script. More...
 

Detailed Description

Interface for script loaders.

Script loaders are those objects that are directly responsible for loading scripts and exposing them as IScript. Scripts are loaded via the LoadScript() method.

The list of all available scripts with the current set of prefixes could also be obtained via the

The scripts are identified by their name. Script loader must properly append the corresponding extension while checking for the existence of the corresponding script.

The scripts are loaded from the path which is built as concatenation of prefix path (adjusted via AddGlobalPrefix() and AddLocalPrefix() methods), relative path (which is passed to the IScriptLoader::CreateScriptLoaderInstance() method as parameter) and interpreter name. The following interpreter names are defined (and the corresponding extensions):

  • qtscript for *.qs, *.js, *.es.
  • python for *.py
  • ruby for *.rb

Several local prefixes could be added by the consecutive calls to AddGlobalPrefix() and AddLocalPrefix() respectively. The script loader must check the prefixes in the reversed order of their addition, so if you want the local scripts to have higher precedence than global ones, you should call AddLocalPrefix() after calling AddGlobalPrefix().

See also
IScriptLoader, IScript

Definition at line 113 of file iscriptloader.h.

Constructor & Destructor Documentation

◆ ~IScriptLoaderInstance()

virtual IScriptLoaderInstance::~IScriptLoaderInstance ( )
inlinevirtual

Definition at line 116 of file iscriptloader.h.

Member Function Documentation

◆ AddGlobalPrefix()

virtual void IScriptLoaderInstance::AddGlobalPrefix ( )
pure virtual

Adds a global load prefix.

This is /usr/[local/]share/leechcraft/scripts on Unix-like OSes and APP_PATH%/share/scripts on Windows.

◆ AddLocalPrefix()

virtual void IScriptLoaderInstance::AddLocalPrefix ( QString  prefix = QString())
pure virtual

Adds a local load prefix.

This is ~/.leechcraft/data/scripts/ + prefix.

◆ EnumerateScripts()

virtual QStringList IScriptLoaderInstance::EnumerateScripts ( ) const
pure virtual

Lists all available scripts.

This function lists the names of all available scripts, ready to be passed to LoadScript(), from the locations available with the current set of prefixes.

Returns
The list of available scripts.

◆ GetQObject()

virtual QObject* IScriptLoaderInstance::GetQObject ( )
pure virtual

Returns this loader instance as a QObject.

Returns
This script loader instance as a QObject.

◆ GetScriptInfo()

virtual QVariantMap IScriptLoaderInstance::GetScriptInfo ( const QString &  script)
pure virtual

Returns the metadata of the given script.

◆ LoadScript()

virtual IScript_ptr IScriptLoaderInstance::LoadScript ( const QString &  script)
pure virtual

Loads the given script.

This method loads the script identified by the script, and returns an object used to communicate with the script, or a null pointer if the given script could not be loaded.

Please refer to this class' documentation for more information regarding script paths.

Note
Implementations may choose to return a valid pointer even if the script is loaded correctly. In this case, all operations on it will fail, though.
Parameters
[in]scriptThe script base name.
Returns
The script wrapper object.

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