NAP
Public Member Functions | Public Attributes | List of all members
PythonScriptComponent Class Reference

#include <pythonscriptcomponent.h>

Public Member Functions

bool init (utility::ErrorState &errorState) override
 
virtual void getDependentComponents (std::vector< rtti::TypeInfo > &components) const override
 
- Public Member Functions inherited from Component
virtual const rtti::TypeInfo getInstanceType () const =0
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

ResourcePtr< PythonScriptmPythonScript = nullptr
 property: 'PythonScript' Pointer to a python script resource that manages the script that contains the python class for this component. More...
 
std::string mClassName
 property: 'Class' The name of the class defined in the python script More...
 
std::vector< std::string > mDependencies
 property: 'Dependencies' list of component types that need to be among this scripts siblings and that will be initialized before this component. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

The resource part of the PythonScriptComponent. Allows for running a python script inside a NAP application. The python script has to implement a class with the name of the ClassName property. The class should implement:

Inheritance diagram for PythonScriptComponent:
[legend]
Collaboration diagram for PythonScriptComponent:
[legend]

Member Function Documentation

◆ getDependentComponents()

virtual void getDependentComponents ( std::vector< rtti::TypeInfo > &  components) const
overridevirtual

Populates a list of components this component depends on. Every component dependency, when found, is initialized before this component. A dependency is NOT a hard requirement. Serialization will not fail if the dependent component isn't declared in JSON. It only means that when a component is declared under the same entity, and that component is tagged as a dependency of this component, it is initialized before this component. It is your responsibility to return false on initialization if the dependency is a hard requirement and can't be found. To ensure the right order of initialization based on a hard requirement it is advised to use a nap::ComponentPtr instead.

Parameters
componentslist of component types this resource depends on.

Reimplemented from Component.

◆ init()

bool init ( utility::ErrorState errorState)
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.

Parameters
errorStateshould contain the error message when initialization fails.
Returns
if initialization succeeded or failed.

Reimplemented from Object.

Member Data Documentation

◆ mClassName

std::string mClassName

property: 'Class' The name of the class defined in the python script

◆ mDependencies

std::vector<std::string> mDependencies

property: 'Dependencies' list of component types that need to be among this scripts siblings and that will be initialized before this component.

◆ mPythonScript

ResourcePtr<PythonScript> mPythonScript = nullptr

property: 'PythonScript' Pointer to a python script resource that manages the script that contains the python class for this component.