omni::graph::core::ogn::OmniGraphNode_ABI

Defined in omni/graph/core/ogn/OmniGraphNodeABI.h

Inheritance Relationships

Base Type

template<typename NodeTypeClass, typename NodeTypeDataClass>
class OmniGraphNode_ABI : public omni::graph::core::ogn::NodeTypeABI

ABI proxy class for OGN generated nodes.

It provides implementations for all of the INodeType ABI functions which will call the actual node’s versions of those functions if the node defines them.

This class uses a technique called “tag dispatching”, which is a compile-time switch that decides which version of a method will be called. By defining overloaded methods taking either the std::true_type or std::false_type type as the first parameter, the version that is called can be decided at compile time by using a template that instantiates one of the two.

In this template class the methods “X()” use tag dispatching to decide which two versions of the call_X() method to call. The version accepting std::true_type is called when an override of X() is detected and calls the override directly. The version accepting std::false_type performs the default version of X().

Each of the INode ABI functions is implemented with these three functions. Here is an annotated example of how this works for a fictional ABI method X that takes a single int argument:

// By making this a template it can change types at compile-time
template <class NodeTypeClass>
// std::is_same will check to see if the named type matches the return type of the declared function
using has_X = typename std::is_same<void,
    // decltype extracts the type of the declared entity
    // declval gives a compile-time stand-in for the declared entity
    // This statement says "get the type of the value returned by a NodeTypeClass function named X"
    decltype(std::declval<const NodeTypeClass&>().X(
    // This line adds the requirement that the function X takes an integer argument
    std::declval<int>())
    // The value_type trait gets the return type of the is_same template (std::true_type/std::false_type)
    )>::value_type;
// These are two overloads of the same method
// Since the last parameters are incompatible only one can be chosen
void call_X(int value, std::true_type)  {}
void call_X(int value, std::false_type) {}
// This is the public method called from outside the class
void X(int value) {
    // If NodeTypeClass::X exists then is_detected<> selects the std::true_type variation
    // for the first argument. Subsequent arguments are passed through from this method's arguments.
    call_X(is_detected<has_X, NodeTypeClass>(), value);
}

For a full description of the SFINAE technique in general and the tag dispatching implementation see https://www.bfilipek.com/2016/02/notes-on-c-sfinae.html#tag-dispatching

The net result of this metaprogramming is that OmniGraphNode_ABI<MyNode, MyNodeDatabase> instantiates an ABI-compatible class that calls overrides in MyNode where available and the default where not. This is functionally equivalent to acquiring and extracting the Node ABI interface and calling the methods on it. MyNodeDatabase is automatically generated by the .ogn processor and MyNode is the class the node writer provides, giving them full control over the ABI implementation if they wish, and use of the default implementation and generated helper classes if not.

Template Parameters
  • NodeTypeClass – Class the user has defined for implementing the custom parts of the node type interface

  • NodeTypeDataClass – Generated database class for NodeTypeClass

Public Functions

inline OmniGraphNode_ABI(const char *nodeTypeName, int nodeTypeVersion, const char *nodeTypeExtension)

Constructor with the basic information that is needed to identify a node type.

Parameters
  • nodeTypeName – Unique name of the node type

  • nodeTypeVersion – Version of the node type being defined

  • nodeTypeExtension – Extension owning the node type

inline virtual void populateNodeTypeInterface(INodeType &nodeTypeInterface) const override

Populate an INodeType interface with the functions that implement this particular templated node type.

Parameters

nodeTypeInterface[out] Interface to be populated

inline void registerNodeType(IGraphRegistry &iGraphRegistry)

Register the node type encapsulated in this description.

inline void registerNodeType(IGraphRegistry &iGraphRegistry, const std::vector<omni::core::ObjectPtr<unstable::INodeTypeCustomInterfaceBase>> &interfacePtrs)

Register the node type encapsulated in this description along with the user-defined interfaces that it implements.

inline void deregisterNodeType(IGraphRegistry &iGraphRegistry)

Deregister the node type encapsulated in this description.

Public Static Functions

static inline void addInput(const NodeTypeObj &nodeType, const char *name, const char *typeName, bool required, const void *defaultValuePtr, const size_t *defaultElemCountPtr) noexcept

Implementation of omni::graph::core::INodeType::addInput to use as part of a node type definition.

static inline void addOutput(const NodeTypeObj &nodeType, const char *name, const char *typeName, bool required, const void *defaultValuePtr, const size_t *defaultElemCountPtr) noexcept

Implementation of omni::graph::core::INodeType::addOutput to use as part of a node type definition.

static inline void addState(const NodeTypeObj &nodeType, const char *name, const char *typeName, bool required, const void *defaultValuePtr, const size_t *defaultElemCountPtr) noexcept

Implementation of omni::graph::core::INodeType::addState to use as part of a node type definition.

static inline void addExtendedInput(const NodeTypeObj &nodeType, const char *name, const char *typeName, bool required, ExtendedAttributeType extendedType) noexcept

Implementation of omni::graph::core::INodeType::addExtendedInput to use as part of a node type definition.

static inline void addExtendedOutput(const NodeTypeObj &nodeType, const char *name, const char *typeName, bool required, ExtendedAttributeType extendedType) noexcept

Implementation of omni::graph::core::INodeType::addExtendedOutput to use as part of a node type definition.

static inline void addExtendedState(const NodeTypeObj &nodeType, const char *name, const char *typeName, bool required, ExtendedAttributeType extendedType) noexcept

Implementation of omni::graph::core::INodeType::addExtendedState to use as part of a node type definition.

static inline bool hasState(const NodeTypeObj &nodeType) noexcept

Implementation of omni::graph::core::INodeType::hasState to use as part of a node type definition.

static inline void setHasState(const NodeTypeObj &nodeType, bool hasState) noexcept

Implementation of omni::graph::core::INodeType::setHasState to use as part of a node type definition.

static inline bool compute(const GraphContextObj &context, const NodeObj &node) noexcept

Implementation of omni::graph::core::INodeType::compute to use as part of a node type definition.

static inline size_t computeVectorized(const GraphContextObj &context, const NodeObj &node, size_t count) noexcept

Implementation of omni::graph::core::INodeType::computeVectorized to use as part of a node type definition.

static inline const char *getNodeType()

Implementation of omni::graph::core::INodeType::getNodeType to use as part of a node type definition.

static inline const char *getTypeName(const NodeTypeObj &nodeType)

Implementation of omni::graph::core::INodeType::getTypeName to use as part of a node type definition.

static inline void initialize(const GraphContextObj &context, const NodeObj &node) noexcept

Implementation of omni::graph::core::INodeType::initialize to use as part of a node type definition.

static inline void initializeType(const NodeTypeObj &nodeType) noexcept

Implementation of omni::graph::core::INodeType::initializeType to use as part of a node type definition.

static inline void registerTasks() noexcept

Implementation of omni::graph::core::INodeType::registerTasks to use as part of a node type definition.

static inline void release(const NodeObj &node) noexcept

Implementation of omni::graph::core::INodeType::release to use as part of a node type definition.

static inline void initInstance(const NodeObj &node, GraphInstanceID instanceId) noexcept

Implementation of omni::graph::core::INodeType::releaseInstace to use as part of a node type definition.

static inline void releaseInstance(const NodeObj &node, GraphInstanceID instanceId) noexcept

Implementation of omni::graph::core::INodeType::releaseInstace to use as part of a node type definition.

static inline void destroyDB(const NodeObj &node, ogn::OmniGraphDatabase *db)

Implementation of omni::graph::core::INodeType::destroyDB to use as part of a node type definition.

static inline void notifyTypeResolution(AttributeObj const &attrib, ogn::OmniGraphDatabase *db)

Implementation of omni::graph::core::INodeType::notifyTypeResolution to use as part of a node type definition.

static inline void notifyDynamicAttributeChanged(ogn::OmniGraphDatabase *db, AttributeObj const &attr, bool isAttributeCreated)

Implementation of omni::graph::core::INodeType::notifyDynamicAttributeChanged to use as part of a node type definition.

static inline void notifyDataLocationChanged(ogn::OmniGraphDatabase *db, AttributeObj const &attr)

Implementation of omni::graph::core::INodeType::notifyDataLocationChanged to use as part of a node type definition.

static inline bool updateNodeVersion(const GraphContextObj &context, const NodeObj &node, int oldVersion, int newVersion) noexcept

Implementation of omni::graph::core::INodeType::udpateNodeVersion to use as part of a node type definition.

static inline size_t getAllMetadata(const NodeTypeObj &nodeType, const char **keyBuf, const char **valueBuf, size_t bufSize) noexcept

Implementation of omni::graph::core::INodeType::getAllMetadata to use as part of a node type definition.

static inline const char *getMetadata(const NodeTypeObj &nodeType, const char *key) noexcept

Implementation of omni::graph::core::INodeType::getMetadata to use as part of a node type definition.

static inline size_t getMetadataCount(const NodeTypeObj &nodeType) noexcept

Implementation of omni::graph::core::INodeType::getMetadataCount to use as part of a node type definition.

static inline void setMetadata(const NodeTypeObj &nodeType, const char *key, const char *value) noexcept

Implementation of omni::graph::core::INodeType::setMetadata to use as part of a node type definition.

static inline void addSubNodeType(const NodeTypeObj &nodeType, const char *subNodeTypeName, const NodeTypeObj &subNodeType)

Implementation of omni::graph::core::INodeType::addSubNodeType to use as part of a node type definition.

static inline NodeTypeObj getSubNodeType(const NodeTypeObj &nodeType, const char *subNodeTypeName)

Implementation of omni::graph::core::INodeType::getSubNodeType to use as part of a node type definition.

static inline NodeTypeObj createNodeType(const char *nodeTypeName, int version)

Implementation of omni::graph::core::INodeType::createNodeType to use as part of a node type definition.

static inline void onConnectionTypeResolve(const NodeObj &node)

Implementation of omni::graph::core::INodeType::onConnectionTypeResolve to use as part of a node type definition.

static inline bool inspect(const NodeTypeObj &nodeType, inspect::IInspector *inspector)

Implementation of omni::graph::core::INodeType::inspect to use as part of a node type definition.

static inline bool definedAtRuntime(const NodeTypeObj &nodeType)

Default implementation of omni::graph::core::INodeType::definedAtRuntime to use as part of a node type definition.

static inline bool computeCuda(const NodeObj &node)

Implementation of omni::graph::core::INodeType::computeCuda to use as part of a node type definition.

This ABI is supported for pre and post render graph nodes which are executed as cuda commands. The computeCuda ABI is ignored by the framework and will not produce any output when the nodes which implement it are executed outside of the context of a pre or post render graph.

Parameters

node[in] The node object on which computeCuda is called.

Returns

Returns true if the node compute was successful, otherwise returns false.

Public Static Attributes

static const char *sm_nodeTypeName = {nullptr}

Name of node type, to allow passing a static function to ABI.

Protected Attributes

const char *m_nodeTypeName = {nullptr}

Unique name of the node type.

int m_version = {1}

Current version of the node type.

const char *m_extensionName = {nullptr}

Extension to which this node type belongs.