PixelLightAPI  .
Public Member Functions | Protected Member Functions | Protected Attributes
PLEngine::ScriptApplication Class Reference

Script application class. More...

#include <ScriptApplication.h>

Inheritance diagram for PLEngine::ScriptApplication:
Inheritance graph
[legend]

List of all members.

Public Member Functions

PL_API ScriptApplication (PLCore::Frontend &cFrontend)
 Constructor.
PL_API ScriptApplication (PLCore::Frontend &cFrontend, PLCore::String sScriptFilename)
 Constructor for loading in and executing a scripted stand-alone application using just a single line of C++ code.
PL_API ScriptApplication (PLCore::Frontend &cFrontend, PLCore::String sScriptFilename, PLCore::String sName, PLCore::String sTitle, PLCore::String sAppDataSubdir)
 Constructor for loading in and executing a scripted stand-alone application using just a single line of C++ code.
virtual PL_API ~ScriptApplication ()
 Destructor.
PL_API PLCore::String GetBaseDirectory () const
 Returns the base directory of the application.
PL_API void SetBaseDirectory (const PLCore::String &sBaseDirectory)
 Sets the base directory of the application.
PL_API PLCore::ScriptGetScript () const
 Returns the used script instance.
PL_API PLCore::String GetScriptFilename () const
 Returns the absolute filename of the used script.
PL_API PLCore::String GetScriptDirectory () const
 Returns the absolute directory the used script is in.

Protected Member Functions

virtual PL_API void OnInit ()
 Called when application should initialize itself.
virtual PL_API void OnDeInit ()
 Called when application should de-initialize itself.
virtual PL_API void OnUpdate () override
 Called to let the frontend update it's states.
PL_API bool LoadScript (const PLCore::String &sFilename)
 Loads a script.
PL_API void DestroyScript ()
 Destroys the currently used script.

Protected Attributes

PLCore::String m_sInitialScriptFilename

Detailed Description

Script application class.

Remarks:
This class can load in and execute a given script out of the box.
Note:
  • If a script filename was given to the constructor, the script is started within the "OnInit()"-method
  • Adds the global variable "this" to the script so that it's able to access "this" RTTI class instance

Constructor & Destructor Documentation

Constructor.

Parameters:
[in]cFrontendFrontend this application instance is running in

Constructor for loading in and executing a scripted stand-alone application using just a single line of C++ code.

Parameters:
[in]cFrontendFrontend this application instance is running in
[in]sScriptFilenameFilename of the script to load
Remarks:
		*    Usage example:
		*    int PLMain(const String &sExecutableFilename, const Array<String> &lstArguments)
		*    {
		*        return ScriptApplication("Data/Scripts/45ScriptApplication.lua").Run(sExecutableFilename, lstArguments);
		*    }
		*  
PL_API PLEngine::ScriptApplication::ScriptApplication ( PLCore::Frontend cFrontend,
PLCore::String  sScriptFilename,
PLCore::String  sName,
PLCore::String  sTitle,
PLCore::String  sAppDataSubdir 
)

Constructor for loading in and executing a scripted stand-alone application using just a single line of C++ code.

Parameters:
[in]cFrontendFrontend this application instance is running in
[in]sScriptFilenameFilename of the script to load
[in]sNameOptional name of the application, if empty string a name is constructed automatically by using the filename of the script
[in]sTitleOptional title of the application, if empty string a title is constructed automatically by using the filename of the script
[in]sAppDataSubdirOptional subdirectory for application data files, if empty string a directory is constructed automatically by using the filename of the script
Remarks:
		*    Usage example:
		*    int PLMain(const String &sExecutableFilename, const Array<String> &lstArguments)
		*    {
		*        return ScriptApplication("Data/Scripts/45ScriptApplication.lua").Run(sExecutableFilename, lstArguments);
		*    }
		*  

Destructor.


Member Function Documentation

Returns the base directory of the application.

Returns:
The base directory of the application (native path style, e.g. on Windows: 'C:\')
PL_API void PLEngine::ScriptApplication::SetBaseDirectory ( const PLCore::String sBaseDirectory)

Sets the base directory of the application.

Parameters:
[in]sBaseDirectoryThe base directory of the application (e.g. on Windows: 'C:\')

Returns the used script instance.

Returns:
Used script instance, can be a null pointer (do not destroy the returned instance)

Returns the absolute filename of the used script.

Returns:
Absolute filename of the used script (native path style, e.g. on Windows: 'C:.lua')

Returns the absolute directory the used script is in.

Returns:
The absolute directory the used script is in (native path style, e.g. on Windows: 'C:\' if currently the script 'C:.lua' is used)
virtual PL_API void PLEngine::ScriptApplication::OnInit ( ) [protected, virtual]

Called when application should initialize itself.

Remarks:
The default implementation does the following tasks:
  • Everything that EngineApplication::OnInit() does
  • Load the script given to the constructor
  • Call optional <OnInitFunction> script function
  • Return and go on with Main()

Reimplemented from PLCore::CoreApplication.

virtual PL_API void PLEngine::ScriptApplication::OnDeInit ( ) [protected, virtual]

Called when application should de-initialize itself.

Remarks:
The default implementation does the following tasks:

Reimplemented from PLCore::CoreApplication.

virtual PL_API void PLEngine::ScriptApplication::OnUpdate ( ) [override, protected, virtual]

Called to let the frontend update it's states.

Remarks:
The default implementation does the following tasks:

Reimplemented from PLEngine::EngineApplication.

PL_API bool PLEngine::ScriptApplication::LoadScript ( const PLCore::String sFilename) [protected]

Loads a script.

Parameters:
[in]sFilenameFilename of the script to load
Returns:
'true' if all went fine, else 'false'
Note:
  • Calls the optional script function <OnInitFunction>
PL_API void PLEngine::ScriptApplication::DestroyScript ( ) [protected]

Destroys the currently used script.

Note:
  • Calls the optional script function <OnDeInitFunction>

Member Data Documentation

Initial filename of the script to use


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:29
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported