OMNI_GRAPH_EXEC_GET_NODE_DATA_AS

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

OMNI_GRAPH_EXEC_GET_NODE_DATA_AS(context_, type_, ...)

Calls either omni::graph::exec::unstable::IExecutionContext::getNodeDataAs() or omni::graph::exec::unstable::IExecutionStateInfo::getNodeDataAs() (dependent on the type of the first argument).

The purpose of this macro is to generate an appropriate omni::core::TypeId at compile time from the data item’s type. The user can manually do this, but this macro is much less error prone.

auto data = OMNI_GRAPH_EXEC_GET_NODE_DATA_AS(
    task->getContext(),        // pointer to either IExecutionContext or IExecutionStateInfo
    GraphContextCacheOverride, // the type of the data to retrieve
    task->getUpstreamPath(),   // node path
    tokens::kInstanceContext   // key to use as a lookup in the node's key/value datastore
);

if (data)
{
     GraphContextCacheOverride* item = data.value();
     // ...
}
else
{
     omni::core::Result badResult = data.error(); // e.g. kResultNotFound (see docs)
     // ...
}

The macro itself is a variadic macro and can map to multiple overloads of getNodeDataAs() methods in the interface given as the first argument

With newer compilers (GCC >= 8), this macro can be replaced with templated methods (without breaking the ABI).