class PythonFunctionalNode

Overview

Specialization of FunctionalNode in which _function is a python callable object. More…

#include <functional_node.h>

class PythonFunctionalNode: public FunctionalNode {
public:
    // construction

    PythonFunctionalNode(
        const std::string& id,
        const boost::python::list& o_ports,
        FunctionalNodePolicies::ExecutionPolicy policy = FunctionalNodePolicies::ExecutionPolicy::ON_NEW_INPUT
    );

    // methods

    boost::python::object pySetup(boost::python::object obj);

    template <typename T_IN, size_t N = 0>
    InputPort<T_IN, bpy::object>* getOrRegisterInput(const std::string& id);

    template <size_t N = 0>
    OutputPort<bpy::object>* registerOutput(const std::string& id);

    template <size_t N = 0>
    OutputPort<bpy::object>* getOutput(const std::string& id);
};

Detailed Documentation

Specialization of FunctionalNode in which _function is a python callable object.

_function can have a variable number of inputs and outputs between 0 and input_s/output_s

Construction

PythonFunctionalNode(
    const std::string& id,
    const boost::python::list& o_ports,
    FunctionalNodePolicies::ExecutionPolicy policy = FunctionalNodePolicies::ExecutionPolicy::ON_NEW_INPUT
)

Constructor.

Methods

boost::python::object pySetup(boost::python::object obj)

Setup this node with a python callable object and registers it to ComputationalGraphManager.

After calling this function the object is moved into a shared pointer which is returned by the function. Afterwards this object shouldn’t be used. Use the returned shared pointer.

It is meant to be used as call function in a Python decorator which creates a PythonFunctionalNode from a given Python function

template <typename T_IN, size_t N = 0>
InputPort<T_IN, bpy::object>* getOrRegisterInput(const std::string& id)

Safely get or register an input port.

template <size_t N = 0>
OutputPort<bpy::object>* registerOutput(const std::string& id)

Safely registers an output port.

template <size_t N = 0>
OutputPort<bpy::object>* getOutput(const std::string& id)

Safely get an output port.