omni::graph::exec::unstable::NodeDefLambda

Defined in omni/graph/exec/unstable/NodeDefLambda.h

class NodeDefLambda : public omni::graph::exec::unstable::NodeDefT<INodeDef>

Wrapper of a lambda function into an opaque node definition.

This class is great for quick prototyping and nodes that won’t be statically analyzed. It is recommended to convert such nodes into real classes to avoid paying the price of std::function call from already virtual method and to provide type information.

See Execution Concepts for an in-depth guide on how definitions are used during execution.

Thread Safety

Since definitions can be shared by multiple nodes, and nodes can be executed in parallel, implementations of this interface should expect its methods to be called in parallel.

Public Functions

inline void acquire() noexcept

Increments the object’s reference count.

Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().

Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.

Thread Safety

This method is thread safe.

inline void release() noexcept

Decrements the objects reference count.

Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).

Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().

Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.

Thread Safety

This method is thread safe.

inline uint32_t getUseCount() noexcept

Returns the number of different instances (this included) referencing the current object.

Thread Safety

This method is thread safe.

inline void *cast(omni::core::TypeId id) noexcept

See omni::core::IObject::cast.

inline void *castWithoutAcquire(omni::core::TypeId id) noexcept

See omni::graph::exec::unstable::IBase_abi::castWithoutAcquire_abi.

Public Static Functions

template<typename Fn>
static inline omni::core::ObjectPtr<NodeDefLambda> create(const carb::cpp::string_view &definitionName, Fn &&fn, SchedulingInfo schedInfo) noexcept

Templated constructor for wrapper class.

The given definition name must not be nullptr.

The given invokable object myst not be nullptr.

The returned object will not be nullptr.

Template Parameters

Fn – Invokable type (e.g. function, functor, lambda, etc) with the signature Status(ExecutionTask&).

Parameters
  • definitionName – Definition name is considered as a token that transformation passes can register against.

  • fn – Execute function body. Signature should be Status(ExecutionTask&).

  • schedInfo – Fixed at runtime scheduling constraint.

static inline omni::core::ObjectPtr<NodeDefT> create(const carb::cpp::string_view &definitionName) noexcept

Construct node definition.

This function always returns a valid pointer.

Parameters

definitionName – Definition name is considered as a token that transformation passes can register against. This name must not be nullptr.

Protected Functions

template<typename Fn>
inline NodeDefLambda(const carb::cpp::string_view &definitionName, Fn &&fn, SchedulingInfo schedInfo) noexcept

Templated and protected constructor for wrapper class.

Use the create factory method to construct objects of this class.

inline Status execute_abi(ExecutionTask *info) noexcept override

Execute the node definition.

The given task must not be nullptr.

Prefer calling omni::graph::exec::unstable::ExecutionTask::execute() rather than this method as omni::graph::exec::unstable::ExecutionTask::execute() populates information such as omni::graph::exec::unstable::getCurrentTask().

See Error Handling to understand the error handling/reporting responsibilities of implementors of this method.

Thread Safety

See thread safety information in interface description.

inline SchedulingInfo getSchedulingInfo_abi(const ExecutionTask *info) noexcept override

Provides runtime information about scheduling constraints for a given task/node.

The provided omni::graph::exec::unstable::ExecutionTask can be used to determine the path of the current definition.

The given task must not be nullptr.

Thread Safety

See thread safety information in interface description.

inline const ConstName *getName_abi() noexcept override

Return unique definition identifier.

The returned pointer is never nullptr. The lifetime of the data returned is tied to the lifetime of this object.

Thread Safety

See thread safety information in interface description.

inline void acquire_abi() noexcept override

Increments the object’s reference count.

Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().

Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.

Thread Safety

This method is thread safe.

inline void release_abi() noexcept override

Decrements the objects reference count.

Most implementations will destroy the object if the reference count reaches 0 (though this is not a requirement).

Objects may have multiple reference counts (e.g. one per interface implemented). As such, it is important that you call omni::core::IObject::release() on the same pointer from which you called omni::core::IObject::acquire().

Do not directly use this method, rather use omni::core::ObjectPtr, which will manage calling omni::core::IObject::acquire() and omni::core::IObject::release() for you.

Thread Safety

This method is thread safe.

inline uint32_t getUseCount_abi() noexcept override

Returns the number of different instances (this included) referencing the current object.

inline void *cast_abi(omni::core::TypeId id) noexcept override

Returns a pointer to the interface defined by the given type id if this object implements the type id’s interface.

Objects can support multiple interfaces, even interfaces that are in different inheritance chains.

The returned object will have omni::core::IObject::acquire() called on it before it is returned, meaning it is up to the caller to call omni::core::IObject::release() on the returned pointer.

The returned pointer can be safely reinterpret_cast<> to the type id’s C++ class. For example, “omni.windowing.IWindow” can be cast to omni::windowing::IWindow.

Do not directly use this method, rather use a wrapper function like omni::core::cast() or omni::core::ObjectPtr::as().

Thread Safety

This method is thread safe.

inline void *castWithoutAcquire_abi(omni::core::TypeId id) noexcept override

Casts this object to the type described the the given id.

Returns nullptr if the cast was not successful.

Unlike omni::core::IObject::cast(), this casting method does not call omni::core::IObject::acquire().

Thread Safety

This method is thread safe.

Protected Attributes

std::atomic<uint32_t> m_refCount

Reference count.