Open 3D Engine GraphModel Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
GraphModel::Node Class Referenceabstract

#include <Node.h>

Inherits GraphModel::GraphElement, and AZStd::enable_shared_from_this< Node >.

Inherited by GraphModel::BaseInputOutputNode, and GraphModel::ModuleNode.

Classes

struct  SortSlotsBySubId
 

Public Types

using SlotDefinitionList = AZStd::vector< SlotDefinitionPtr >
 
using SlotMap = AZStd::map< SlotId, SlotPtr >
 
using ConstSlotMap = AZStd::map< SlotId, const SlotPtr >
 
using ExtendableSlotSet = AZStd::set< SlotPtr, SortSlotsBySubId >
 
using ExtendableSlotMap = AZStd::map< SlotName, ExtendableSlotSet >
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (Node, AZ::SystemAllocator)
 
 AZ_RTTI (Node, "{274B4495-FDBF-45A9-9BAD-9E90269F2B73}", GraphElement)
 
 Node (GraphPtr graph)
 
virtual void PostLoadSetup (GraphPtr graph, NodeId id)
 
virtual void PostLoadSetup ()
 
virtual const char * GetTitle () const =0
 Returns the name that will be displayed as the title of the Node in the UI.
 
virtual const char * GetSubTitle () const
 Returns the name that will be displayed as the sub-title of the Node in the UI.
 
virtual NodeType GetNodeType () const
 
NodeId GetId () const
 Return the unique ID for this node in the containing graph.
 
uint32_t GetMaxInputDepth () const
 Return the greatest distance, number of connected nodes, between this node and other root nodes.
 
uint32_t GetMaxOutputDepth () const
 Return the greatest distance, number of connected nodes, between this node and other leaf nodes.
 
bool HasSlots () const
 Return true if this node contains any slots.
 
bool HasInputSlots () const
 Return true if this node contains any input slots.
 
bool HasOutputSlots () const
 Return true if this node contains any output slots.
 
bool HasConnections () const
 Returns true if the graph contains any connections referencing this node.
 
bool HasInputConnections () const
 Returns true if the graph has any connections to input slots on this node.
 
bool HasOutputConnections () const
 Returns true if the graph has any connections to output slots on this node.
 
bool HasInputConnectionFromNode (ConstNodePtr node) const
 Returns true if any of the input slots on this node have direct or indirect connections to output slots on the specified node.
 
bool HasOutputConnectionToNode (ConstNodePtr node) const
 Returns true if any of the output slots on this node have direct or indirect connections to input slots on the specified node.
 
bool Contains (ConstSlotPtr slot) const
 Returns true if this node contains the specified slot.
 
const SlotDefinitionList & GetSlotDefinitions () const
 Returns SlotDefinitions for all available Slots.
 
const SlotMap & GetSlots ()
 
ConstSlotMap GetSlots () const
 
SlotPtr GetSlot (const SlotId &slotId)
 Returns the slot with the given slotId, or nullptr if it doesn't exist.
 
ConstSlotPtr GetSlot (const SlotId &slotId) const
 
SlotPtr GetSlot (const SlotName &name)
 
ConstSlotPtr GetSlot (const SlotName &name) const
 
const ExtendableSlotSet & GetExtendableSlots (const SlotName &name)
 Returns an ordered set of the extendable slots for a given SlotName, or an empty set if there are none.
 
int GetExtendableSlotCount (const SlotName &name) const
 
void DeleteSlot (SlotPtr slot)
 
virtual bool CanDeleteSlot (ConstSlotPtr slot) const
 
virtual SlotPtr AddExtendedSlot (const SlotName &slotName)
 
void ClearCachedData ()
 Clear any data that was cached for this node.
 
- Public Member Functions inherited from GraphModel::GraphElement
 AZ_CLASS_ALLOCATOR (GraphElement, AZ::SystemAllocator)
 
 AZ_RTTI (GraphElement, "{FD83C7CA-556B-49F1-BACE-6E9C7A4D6347}")
 
 GraphElement (GraphPtr graph)
 
GraphPtr GetGraph () const
 Returns the Graph that owns this GraphElement.
 
GraphContextPtr GetGraphContext () const
 Returns the GraphContext for this GraphElement.
 

Static Public Member Functions

static void Reflect (AZ::ReflectContext *context)
 
- Static Public Member Functions inherited from GraphModel::GraphElement
static void Reflect (AZ::ReflectContext *context)
 

Static Public Attributes

static const int INVALID_NODE_ID = 0
 

Protected Member Functions

virtual bool CanExtendSlot (SlotDefinitionPtr slotDefinition) const
 
void RegisterSlot (SlotDefinitionPtr slotDefinition)
 
virtual void RegisterSlots ()
 
void CreateSlotData ()
 

Friends

class Graph
 

Additional Inherited Members

- Protected Attributes inherited from GraphModel::GraphElement
AZStd::weak_ptr< Graphm_graph
 

Detailed Description

The abstract base class for every type of node in a Graph. It consists primarily of a set of Slots. There is no functionality here beyond managing the Slots and finding Connections. Any useful functionality must be provided by subclasses in the client context where the GraphModel framework is used.

Slots are divided into two main objects: a SlotDefinition and the actual Slot. The SlotDefinition contains the predefined description of each slot that the Node contains. This information is not saved with the Node data in the Graph because it is provided by the Node subclass itself (either hard-coded or reflected from some other source). The Slot is the functional part, and contains any data related to specific instance of the Node (for example, the default value of an Input Data Slot). This data is serialized with the Node. Whenever a Node is created, either directly or by serializing in, the Node class ensures that Slots are created for each SlotDefinition defined by the Node subclass.

Every Slot in the Node has a SlotId, which is unique within the context of the Node. A specific Slot in a spectific Node is called an Endpoint and is identified by a pairing of NodeId and SlotId.

Subclasses must call RegisterSlot() to define the Node's inputs and outputs, but it shouldn't need to serialize any of its own data. This base class's Slot lists are reflected for serialization, and that's all that should be needed in most cases.

Constructor & Destructor Documentation

◆ Node()

GraphModel::Node::Node ( GraphPtr  graph)
explicit

Constructor

Parameters
graphThe Graph that will own this Node (though constructing the Node doesn't actually add it to this graph yet).

Member Function Documentation

◆ AddExtendedSlot()

virtual SlotPtr GraphModel::Node::AddExtendedSlot ( const SlotName &  slotName)
virtual

Append a new slot to an extendable slot list. This is restricted such that

  • The slot definition must be extendable
  • Creating a new slot can't increase the number of extendable slots above the configured maximum number of allowed slots for this definition This method does nothing if the slot is not extendable.

◆ CanDeleteSlot()

virtual bool GraphModel::Node::CanDeleteSlot ( ConstSlotPtr  slot) const
virtual

Check if the specified slot can be deleted, which is restricted by

  • The slot must be extendable
  • Deleting the slot can't reduce the number of extendable slots below the configured minimum number of allowed slots for this definition This method is also virtual so the client can impose any custom limitations as needed. This method does nothing if the slot is not extendable.

◆ CanExtendSlot()

virtual bool GraphModel::Node::CanExtendSlot ( SlotDefinitionPtr  slotDefinition) const
protectedvirtual

Default implementation will prevent slots from being extended past the maximum allowed configuration, but the client could override this to impose additional restrictions

◆ CreateSlotData()

void GraphModel::Node::CreateSlotData ( )
protected

Once a subclass is done calling RegisterSlot(), it can call this function to instantiate all the slot data. This should only be done when creating a new Node, not when loading a Node from serialize data (in that case Slot creation will be handled automatically by PostLoadSetup()).

◆ DeleteSlot()

void GraphModel::Node::DeleteSlot ( SlotPtr  slot)

Delete the specified slot, which is only allowed on extendable slots. This method does nothing if the slot is not extendable.

◆ GetExtendableSlotCount()

int GraphModel::Node::GetExtendableSlotCount ( const SlotName &  name) const

Returns the number of extendable slots for a given SlotName. Will return -1 if the specified slot is not extendable.

◆ GetNodeType()

virtual NodeType GraphModel::Node::GetNodeType ( ) const
virtual

Returns node type (general by default) which can be overriden for other types, such as wrapper nodes

◆ GetSlot()

SlotPtr GraphModel::Node::GetSlot ( const SlotName &  name)

Returns the slot with the given SlotName, or nullptr if it doesn't exist. This is a simplified version for normal (non-extendable) slots. It is equivalent to calling GetSlot with the given SlotName and a subId of 0. If the slot is actually extendable, it will return the first indexed slot if it exists.

◆ GetSlots()

const SlotMap & GraphModel::Node::GetSlots ( )

Returns the map of all available Slots. For the generic case, there will be one Slot for every SlotDefinition in GetSlotDefinitions(). Additionally, for extendable slots there could be 0 or more Slots per SlotDefinition

◆ GetTitle()

virtual const char * GraphModel::Node::GetTitle ( ) const
pure virtual

Returns the name that will be displayed as the title of the Node in the UI.

Implemented in GraphModel::BaseInputOutputNode, and GraphModel::ModuleNode.

◆ PostLoadSetup() [1/2]

virtual void GraphModel::Node::PostLoadSetup ( )
virtual

An alternative to the above PostLoadSetup when the nodeId isn't already known (e.g. a deserialized node that has been copy/pasted)

Reimplemented in GraphModel::ModuleNode.

◆ PostLoadSetup() [2/2]

virtual void GraphModel::Node::PostLoadSetup ( GraphPtr  graph,
NodeId  id 
)
virtual

Initializion after the Node has been serialized in. This must be called whenever the default constructor is used. Sets the m_graph pointer and caches pointers to other GraphElements. It also ensures the loaded Slot data aligns with the defined SlotDefinitions.

Reimplemented in GraphModel::ModuleNode, GraphModel::GraphInputNode, GraphModel::GraphOutputNode, and GraphModel::ModuleNode.

◆ RegisterSlot()

void GraphModel::Node::RegisterSlot ( SlotDefinitionPtr  slotDefinition)
protected

Subclasses should call this function during construction to define its slots. The slot's name must be unique among all slots in this node.

◆ RegisterSlots()

virtual void GraphModel::Node::RegisterSlots ( )
inlineprotectedvirtual

Overridden by specific nodes to register their necessary slots This is called automatically by this Node base class when PostLoadSetup is called, which occurs after a Node has been deserialized. The derived classes are stil in charge of calling it in their Node(GraphPtr graph) constructor, since their overrides aren't accessible from the base class during construction.

Reimplemented in GraphModel::GraphInputNode, GraphModel::GraphOutputNode, and GraphModel::ModuleNode.


The documentation for this class was generated from the following file: