cppexpose  1.0.0.b785e04f23b8
C++ library for type introspection, reflection, and scripting interface
Public Member Functions | Public Attributes | Protected Attributes | List of all members
cppexpose::ScriptContext Class Reference

The entry point to managing scripting in your application. More...

#include <cppexpose/include/cppexpose/scripting/ScriptContext.h>

Collaboration diagram for cppexpose::ScriptContext:
Collaboration graph
[legend]

Public Member Functions

 ScriptContext (const std::string &backend="javascript")
 Constructor. More...
 
 ScriptContext (std::unique_ptr< AbstractScriptBackend > &&backend)
 Constructor. More...
 
virtual ~ScriptContext ()
 Destructor. More...
 
const std::set< Object * > & globalObjects () const
 Get global objects. More...
 
void addGlobalObject (Object *obj)
 Add global object. More...
 
void removeGlobalObject (Object *obj)
 Remove global object. More...
 
Variant evaluate (const std::string &code)
 Execute script. More...
 

Public Attributes

Signal< const std::string & > scriptException
 Called when a script triggered an exception. More...
 

Protected Attributes

std::unique_ptr< AbstractScriptBackendm_backend
 Scripting backend (can be null) More...
 
std::set< Object * > m_globalObjects
 Global objects that are exposed to the scripting environment. More...
 

Detailed Description

The entry point to managing scripting in your application.

Constructor & Destructor Documentation

cppexpose::ScriptContext::ScriptContext ( const std::string &  backend = "javascript")

Constructor.

Parameters
[in]backendName of the backend (supported: "javascript")
cppexpose::ScriptContext::ScriptContext ( std::unique_ptr< AbstractScriptBackend > &&  backend)

Constructor.

Parameters
[in]backendScripting backend (must NOT be null)
virtual cppexpose::ScriptContext::~ScriptContext ( )
virtual

Destructor.

Member Function Documentation

const std::set<Object *>& cppexpose::ScriptContext::globalObjects ( ) const

Get global objects.

Returns
List of global objects
void cppexpose::ScriptContext::addGlobalObject ( Object obj)

Add global object.

Parameters
[in]objGlobal object (must NOT be null)
Remarks
Adds a global object that is exposed to the scripting environment. It will be available in the global namespace using the object's name. The script context does not take ownership over the object.
void cppexpose::ScriptContext::removeGlobalObject ( Object obj)

Remove global object.

Parameters
[in]objGlobal object (must NOT be null)
Remarks
Removes a global object that is exposed to the scripting environment.
Variant cppexpose::ScriptContext::evaluate ( const std::string &  code)

Execute script.

Parameters
[in]codeScripting code
Returns
Return value of the executed code

Member Data Documentation

Signal<const std::string &> cppexpose::ScriptContext::scriptException

Called when a script triggered an exception.

std::unique_ptr<AbstractScriptBackend> cppexpose::ScriptContext::m_backend
protected

Scripting backend (can be null)

std::set<Object *> cppexpose::ScriptContext::m_globalObjects
protected

Global objects that are exposed to the scripting environment.


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