omni::graph::core::ogn::OmniGraphDatabase

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

class OmniGraphDatabase

Class defining the minimal amount of shared interface for the generated database interface classes.

This class should never be instatiated directly as it is not safe across ABI boundaries. Instead, templated classes will derive from it to create new classes that live entirely on the plugin’s side. The template parameter NodeClassType is the node implementation class that makes use of the database. This was necessary to avoid circular dependencies.

Public Functions

inline Type typeFromName(NameToken typeNameToken) const

Get the attribute Type from the OGN type name.

Parameters

typeNameToken[in] Token with the string representation of the attribute type used by OGN

Returns

Attribute type corresponding to the type name, invalid if the type name could not be parsed

inline NameToken stringToToken(const char *tokenName) const

Access the token interface to convert a string to a token, for dealing with unique managed strings.

Parameters

tokenName[in] Name of the string representing a token

Returns

Token corresponding to the unique string (for fast comparison)

inline const char *tokenToString(NameToken token) const

Access the token interface to convert a token to a string, for dealing with unique managed strings.

Parameters

token[in] Name of the token representing a unique string

Returns

String corresponding to the token

inline TargetPath stringToPath(const char *pathString) const

Access the path interface to convert a string to a path.

Parameters

pathString[in] Name of the string representing a token

Returns

Path corresponding to the string

inline const char *pathToString(const TargetPath path) const

Access the path interface to convert a path to a string.

Parameters

path[in] Input path

Returns

String corresponding to the path

inline NameToken pathToToken(const TargetPath path) const

Access the path interface to convert a path to a token.

Parameters

path[in] Input path

Returns

Token corresponding to the path

inline TargetPath tokenToPath(const NameToken pathString) const

Access the path interface to convert a token to a path.

Parameters

pathString[in] Token of the path

Returns

Path corresponding to the token

inline const GraphContextObj &abi_context(InstanceIndex relativeIdx = {0}) const

Access the raw graph ABI object, for when you have to do something really unusual.

Returns

ABI object referencing the graph in which the node lives

inline const NodeObj &abi_node(InstanceIndex relativeIdx = {0}) const

Access the raw node ABI object, for when you have to do something really unusual.

Returns

ABI object referencing the node to which this database belongs

inline size_t getGraphTotalInstanceCount() const

Retrieves the number of instances the owning graph has.

Be aware that depending on the context of execution and/or the current offset of the database, that not all of the instances can be accessed. For example: In a computeVectorized function, always rely on the ‘count’ parameter that is passed in. In a compute function, it is not safe to access anything else that the instance currently evaluating

Returns

The number of instances (targets) associated to the graph. 0 if the graph is not instantiated.

template<typename UserDataType>
inline UserDataType *userData(InstanceIndex relativeIdx = {0}) const

Access the user data, cast to the templated type.

There is no guarantee that the existing user data is of the requested type - that is up to the caller to ensure.

Template Parameters

UserDataType – Type of the user data

Parameters

relativeIdx[in] Instance index of the node to which the user data applies

Returns

Internal user data that was set elsewhere, cast to the templated type

template<typename ...Args>
inline void logError(const char *fmt, Args&&... args)

Log an error using print-like formatting.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • fmt[in] Printf-like formatting string

  • args[in] Variable list of printf-like arguments to be formatted

template<typename ...Args>
inline void logError(InstanceIndex relativeIdx, const char *fmt, Args&&... args)

Log an error for a specific node instance using print-like formatting.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • relativeIdx[in] The graph instance for which this message should be logged

  • fmt[in] Printf-like formatting string

  • args[in] Variable list of printf-like arguments to be formatted

template<typename ...Args>
inline void logWarning(const char *fmt, Args&&... args)

Log a warning using print-like formatting.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • fmt[in] Printf-like formatting string

  • args[in] Variable list of printf-like arguments to be formatted

template<typename ...Args>
inline void logWarning(InstanceIndex relativeIdx, const char *fmt, Args&&... args)

Log a warning for a specific node instance using print-like formatting.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • relativeIdx[in] The graph instance for which this message should be logged

  • fmt[in] Printf-like formatting string

  • args[in] Variable list of printf-like arguments to be formatted

inline VariableAttribute getVariable(NameToken token, InstanceIndex relativeIdx = {0})

Retrieves an attribute representing the value of a variable.

If the variable with the given name does not exist in the graph, an invalid attribute is returned.

Parameters
  • token[in] A token representing the variable name

  • relativeIdx[in] The instance index/offset relative to the one currently pointed by the database

Returns

An attribute that allows access to the variable data.

inline VariableAttribute getVariable(const char *variableName, InstanceIndex relativeIdx = {0})

Retrieves an attribute representing the value of a variable.

If the variable with the given name does not exist in the graph, an invalid attribute is returned.

Parameters
  • variableName[in] A string indicating the variable name

  • relativeIdx[in] The instance index/offset relative to the one currently pointed by the database

Returns

An attribute that allows access to the variable data.

inline NameToken getGraphTarget(InstanceIndex relativeIdx = {0}) const

Retrieves the target of the executing graph.

Parameters

relativeIdx[in] The instance index/offset relative to the one currently pointed by the database

Returns

A token representing the prim path of the graph target

inline gsl::span<NameToken const> getGraphTargets(size_t count) const

Retrieves the targets of the executing graph.

Parameters

count[in] The number of instances available for vectorized access

Returns

A span of token representing the prims path of the graph targets

inline void moveToNextInstance()

Move to next instance in a vectorized context.

inline void resetToFirstInstance()

Move to next instance in a vectorized context.

inline const InstanceIndex &getInstanceIndex() const

Get the current instance index, relative to the the one pointed by the context.

Public Static Functions

template<typename ...Args>
static inline void logMessage(NodeObj const &nodeObj, InstanceIndex inst, Severity sev, const char *fmt, Args&&... args)

Log an evaluation error, warning, or message.

Takes a printf-style list of arguments indicating what happened during evaluation and logs the message.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • nodeObj[in] Node reporting the error

  • inst[in] The graph instance for which this message should be logged

  • sev[in] Severity of the message to report

  • fmt[in] Formatting string

  • args[in] Variadic template arguments in the same form as printf arguments.

template<typename ...Args>
static inline void logError(NodeObj const &nodeObj, const char *fmt, Args&&... args)

Log an evaluation error.

Takes a printf-style list of arguments indicating what error during evaluation and logs the message.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • nodeObj[in] Node reporting the error

  • fmt[in] Formatting string

  • args[in] Variadic template arguments in the same form as printf arguments.

template<typename ...Args>
static inline void logError(NodeObj const &nodeObj, InstanceIndex inst, const char *fmt, Args&&... args)

Log an evaluation error for a specific node instance.

Takes a printf-style list of arguments indicating what error during evaluation and logs the message.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • nodeObj[in] Node reporting the error

  • inst[in] The graph instance for which this message should be logged

  • fmt[in] Formatting string

  • args[in] Variadic template arguments in the same form as printf arguments.

template<typename ...Args>
static inline void logWarning(NodeObj const &nodeObj, const char *fmt, Args&&... args)

Log an evaluation warning.

Takes a printf-style list of arguments indicating what warning during evaluation and logs the message.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • nodeObj[in] Node reporting the warning

  • fmt[in] Formatting string

  • args[in] Variadic template arguments in the same form as printf arguments.

template<typename ...Args>
static inline void logWarning(NodeObj const &nodeObj, InstanceIndex inst, const char *fmt, Args&&... args)

Log an evaluation warning for a specific node instance.

Takes a printf-style list of arguments indicating what warning during evaluation and logs the message.

Template Parameters

Args... – Variable list of printf-like arguments to be formatted

Parameters
  • nodeObj[in] Node reporting the warning

  • inst[in] The graph instance for which this message should be logged

  • fmt[in] Formatting string

  • args[in] Variadic template arguments in the same form as printf arguments.

Protected Functions

inline void _ctor(GraphContextObj const *graphContexts, NodeObj const *nodeObjects, size_t handleCount)

Common constructor for a node’s database.

Parameters
  • graphContexts[in] List of ABI objects referencing the graphs in which the node lives

  • nodeObjects[in] List of ABI objects referencing the instanced nodes to which this database belongs

  • handleCount[in] Number of node instances in nodeObjects

inline OmniGraphDatabase(GraphContextObj const *graphContexts, NodeObj const *nodeObjects, size_t handleCount)

Simple construction passthrough to _ctor for backward compatibility.

OmniGraphDatabase() = default

Default constructor for a node’s database.

template<AttributePortType portType, typename TAttribute>
inline bool tryGetDynamicAttributes(size_t staticAttributeCount, std::vector<TAttribute> &dynamicAttributes)

Gets the dynamic attributes of the specified type, if any are registered with the node.

Parameters
  • staticAttributeCount[in] The number of attributes that are statically defined in the ogn node definition.

  • dynamicAttributes[out] The buffer for the collected dynamic attributes.

Returns

Returns true if any dynamic attributes of the requested type are found, otherwise returns false.

template<AttributePortType portType>
inline bool tryGetDynamicAttributes(size_t staticAttributeCount, std::vector<DynamicInput> &dynamicAttributes)

Populate an array of dynamic attributes from the node.

Template Parameters

portType – Port type from which the dynamic attributes will be pulled

Parameters
  • staticAttributeCount – Number of static attributes on the node

  • dynamicAttributes – Array of dynamic attributes, to be populated on return

Returns

true Dynamic attributes were found and populated

Returns

false No dynamic attributes were found

template<typename TAttribute>
inline void onDynamicAttributeCreated(std::vector<TAttribute> &dynamicAttributes, AttributeObj const &attribute)

Updates the node database when a dynamic attribute is created.

Template Parameters

TAttribute – The type of the dynamic attribute that was created (DynamicInput/DynamicOutput/DynamicState)

Parameters
  • dynamicAttributes[out] The dynamic attributes buffer.

  • attribute[in] The newly created attribute.

inline void onDynamicInputsCreated(std::vector<DynamicInput> &dynamicInputs, AttributeObj const &attribute)

Updates the node database when a dynamic input is created.

Parameters
  • dynamicInputs[out] The dynamic attributes buffer.

  • attribute[in] The newly created attribute.

template<typename TAttribute>
inline void onDynamicAttributeRemoved(std::vector<TAttribute> &dynamicAttributes, AttributeObj const &attribute)

Updates the node database when a dynamic attribute is removed.

Template Parameters

TAttribute – The type of the dynamic attribute that was created (DynamicInput/DynamicOutput/DynamicState)

Parameters
  • dynamicAttributes[out] The dynamic attributes buffer.

  • attribute[in] The dynamic attribute about to be removed.

inline void onDynamicAttributeCreatedOrRemoved(std::vector<DynamicInput> &inputs, std::vector<DynamicOutput> &outputs, std::vector<DynamicState> &states, AttributeObj const &attribute, bool isAttributeCreated)

Updates the node database when a dynamic attribute is created or removed.

Parameters
  • inputs[out] The buffer of input dynamic attributes.

  • outputs[out] The buffer of output dynamic attributes.

  • states[out] The buffer of state dynamic attributes.

  • attribute[in] The attribute added or removed.

  • isAttributeCreated[in] If true, the input attribute is newly created, otherwise it will be removed.

inline void collectMappedAttributes(std::vector<NameToken> &mappedAttributes)

Called at database initialization to collect all attributes that are mapped.

Parameters

mappedAttributes[out] The buffer of mapped attributes.

inline void updateMappedAttributes(std::vector<NameToken> &mappedAttributes, AttributeObj const &attr)

Called by the database in order to update its mapped attribute array when one of its attribute has changed its mapping state.

Parameters
  • [in/out] – mappedAttributes: The buffer of mapped attributes.

  • attr[out] The attribute that has changed its mapping “state”

inline bool validateNode() const

Called by the auto-generated databases classes to validate that it is safe for a node to have compute or computeVectorized called on it.

Protected Attributes

GraphContextObj const *m_graphContextHandles = {nullptr}

ABI object referencing the OmniGraph.

NodeObj const *m_nodeHandles = {nullptr}

List of node handles per-instance.

InstanceIndex m_offset = {0}

Instance offset in vectorized context.

size_t m_handleCounts = {0}

Number of handles in m_nodeHandles.