#include <pythonscript.h>
Public Member Functions | |
PythonScript (PythonScriptService &service) | |
bool | init (utility::ErrorState &errorState) override |
template<typename ReturnType , typename ... Args> | |
bool | get (const std::string &identifier, utility::ErrorState &errorState, ReturnType &returnValue, Args &&... args) |
template<typename ... Args> | |
bool | call (const std::string &identifier, utility::ErrorState &errorState, Args &&... args) |
pybind11::object | get (const std::string &symbol) |
![]() | |
Resource () | |
![]() | |
Object () | |
virtual | ~Object () |
virtual void | onDestroy () |
Object (Object &)=delete | |
Object & | operator= (const Object &)=delete |
Object (Object &&)=delete | |
Object & | operator= (Object &&)=delete |
Public Attributes | |
std::string | mPath |
property: 'Path' Path to the python script. More... | |
![]() | |
std::string | mID |
Property: 'mID' unique name of the object. Used as an identifier by the system. More... | |
Additional Inherited Members | |
![]() | |
static bool | isIDProperty (rtti::Instance &object, const rtti::Property &property) |
A python script loaded from a text file into a pybind11 module. Functions within the script can be called using the call() method and handles to functions and classes can be acquired using get()
PythonScript | ( | PythonScriptService & | service | ) |
bool call | ( | const std::string & | identifier, |
utility::ErrorState & | errorState, | ||
Args &&... | args | ||
) |
Tries to call a method in the python script with the specified arguments. If the call fails the error will be logged in errorState.
identifier | name of the function to call |
errorState | contains the error if the call fails |
args | additional input arguments |
bool get | ( | const std::string & | identifier, |
utility::ErrorState & | errorState, | ||
ReturnType & | returnValue, | ||
Args &&... | args | ||
) |
Tries to call a method with the given name and arguments. The return value is stored in 'returnValue'. If the call fails the error will be logged in errorState.
identifier | the name of the function to call |
errorState | contains the error if the call fails |
returnValue | the return value of the call |
args | additional input arguments |
pybind11::object get | ( | const std::string & | symbol | ) |
Requests a symbol (in most cases a class or function) from the script and returns its C++ representation.
|
overridevirtual |
Override this method to initialize the object after de-serialization. When called it is safe to assume that all dependencies have been resolved up to this point.
errorState | should contain the error message when initialization fails. |
Reimplemented from Object.
std::string mPath |
property: 'Path' Path to the python script.