NodeSystemManagerInterface Class Reference

#include <nodesgraph.h>

Inheritance diagram for NodeSystemManagerInterface:

Detailed Description

A node system manager manages a NodeSystem and several views on that NodeSystem, where each view is a NodesGraphModelRef. A node system manager is created by methods of NodesGraphModelInterface.

The task of the manager is to coordinate accesses to a shared node system from different views: It stores a single NodeSystem reference which is used by all views, a ChangeList to track changes made by any of the views, and also transaction observers which get informed about transactions made by any of the views.

NodeSystemManagerClass is the base implementation of this interface. It has to be used as base class for custom implementations.

Note
This class as well as the views are not thread-safe. This class coordinates different views, but everything has to happen within the same thread (or be properly synchronized by the callers).

Public Types

enum class  FILTER {
  NONE ,
  INCLUDE_INNER ,
  INCLUDE_HIDDEN ,
  INCLUDE_ALL ,
  READ_ONLY ,
  NO_COMPONENT_ACCESS
}
 

Public Member Functions

enum maxon::nodes::NodeSystemManagerInterface::FILTER MAXON_ENUM_FLAGS_CLASS (FILTER)
 
 MAXON_ADD_TO_REFERENCE_CLASS (using FILTER=typename NodeSystemManagerInterface::FILTER;)
 
MAXON_METHOD Result< NodesGraphModelRef > CreateView (FILTER filter, const NodePath &rootPath)
 
MAXON_METHOD const AssetRepositoryRef & GetLookupRepository () const
 
MAXON_METHOD const NodeSystemGetNodeSystem () const
 
MAXON_METHOD void TransactionStarted ()
 
MAXON_METHOD Result< void > FinalizeTransaction (const DataDictionary &userData, ChangeList *changeList)
 
MAXON_METHOD Result< void > ValidateTransaction (const DataDictionary &userData)
 
MAXON_METHOD void TransactionEnded ()
 
MAXON_METHOD TimeStamp GetModificationStamp () const
 
MAXON_METHOD const NodesGraphModelRef & GetMainView () const
 
MAXON_METHOD const ChangeList & GetChangeList ()
 
MAXON_METHOD Result< ChangeList > StartNewChangeList ()
 
MAXON_METHOD Result< ChangeList > Apply (const ChangeList &list, Bool inverse)
 
 MAXON_OBSERVABLE (void, ObservableTransactionStarted,(const NodeSystemManagerRef &manager, const DataDictionary &userData), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (void, ObservableTransactionCommitted,(const NodeSystemManagerRef &manager, const DataDictionary &transactionUserData), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (void, ObservableTransactionRolledBack,(const NodeSystemManagerRef &manager), ObservableCombinerRunAllComponent)
 
MAXON_METHOD Result< void > SetNodeSystem (const NodeSystem &sys)
 
MAXON_METHOD TimeStamp IncSystemStamp ()
 

Protected Member Functions

MAXON_METHOD Result< NodesGraphModelRef > CreateGraphModel () const
 

Private Member Functions

 MAXON_INTERFACE (NodeSystemManagerInterface, MAXON_REFERENCE_NORMAL, "net.maxon.node.interface.nodesystemmanager", MAXON_IMPLEMENTATION_MODULE("net.maxon.nodes"))
 
MAXON_METHOD Result< void > Update (const Block< const Tuple< AssetReference, AssetBase >> &updates)
 

Member Enumeration Documentation

◆ FILTER

enum FILTER
strong

Filter flags for views, see CreateView.

Enumerator
NONE 

No flags set.

INCLUDE_INNER 

Includes inner nodes in the view.

INCLUDE_HIDDEN 

Includes hidden nodes in the view.

INCLUDE_ALL 

Combination of all include flags.

READ_ONLY 

Creates a read-only view.

NO_COMPONENT_ACCESS 

All the unused component access ports will not be part of the graph.

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( NodeSystemManagerInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.node.interface.nodesystemmanager"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.nodes")   
)
private

◆ MAXON_ENUM_FLAGS_CLASS()

enum maxon::nodes::NodeSystemManagerInterface::FILTER MAXON_ENUM_FLAGS_CLASS ( FILTER  )

◆ MAXON_ADD_TO_REFERENCE_CLASS()

MAXON_ADD_TO_REFERENCE_CLASS ( using  FILTER = typename NodeSystemManagerInterface::FILTER;)

◆ CreateView()

MAXON_METHOD Result<NodesGraphModelRef> CreateView ( FILTER  filter,
const NodePath &  rootPath 
)

Creates a view of the node system of this manager using the given settings.

Parameters
[in]filterThe filter to use for the view.
[in]rootPathThe path to the root node of the view. Use this if the view shall not represent the whole graph, but only a node and its inner parts.
Returns
A new view.

◆ GetLookupRepository()

MAXON_METHOD const AssetRepositoryRef& GetLookupRepository ( ) const

Returns the asset repository to use for lookups within graph models created by this manager. This repository is used whenever an asset is looked up.

Returns
The asset repository for lookup.

◆ GetNodeSystem()

MAXON_METHOD const NodeSystem& GetNodeSystem ( ) const

Returns the node system reference of this manager. The node system itself may change over time due to its copy-on-write nature.

Returns
The managed node system.

◆ TransactionStarted()

MAXON_METHOD void TransactionStarted ( )

This method gets called when the outmost transaction has started (observers will be informed afterwards). You can override this method in subclasses of to trigger special actions. It is guaranteed that a matching call to TransactionEnded will happen.

◆ FinalizeTransaction()

MAXON_METHOD Result<void> FinalizeTransaction ( const DataDictionary &  userData,
ChangeList *  changeList 
)

This method gets called during a commit, immediately before observers and TransactionEnded(). You can override this method in subclasses to do some clean-up.

Parameters
[in]userDataThe user data passed to GraphTransaction::Commit.
[in]changeListThe optional change list to track changes.

◆ ValidateTransaction()

MAXON_METHOD Result<void> ValidateTransaction ( const DataDictionary &  userData)

This method gets called during a commit, immediately before observers and TransactionEnded(), but after FinalizeTransaction(). You can override this method in subclasses to do some validation. The persistent state of the graph must not be modified, this has to be done in FinalizeTransaction().

Parameters
[in]userDataThe user data passed to GraphTransaction::Commit.

◆ TransactionEnded()

MAXON_METHOD void TransactionEnded ( )

This method gets called when the outmost transaction has ended by a commit or rollback (observers have been informed before). You can override this method in subclasses to trigger special actions. It is guaranteed that a matching call to TransactionStarted has happened before.

◆ GetModificationStamp()

MAXON_METHOD TimeStamp GetModificationStamp ( ) const

Returns a time stamp of this manager which can be used to test for modifications, see GraphModelInterface::GetModificationStamp. All views use this time stamp too.

The time stamp doesn't coincide with the time stamp of the node system, because the manager also manages user state attributes which aren't stored at the node system.

Returns
Modification time stamp of the manager.

◆ GetMainView()

MAXON_METHOD const NodesGraphModelRef& GetMainView ( ) const

Returns the main view of this manager. This is the initial view which has been created in conjunction with this manager by NodesGraphModelInterface::Create (unless that view has been freed in the mean time, then the returned view is one of the other views or a null reference if there is no view left).

Returns
Main view of this manager.

◆ GetChangeList()

MAXON_METHOD const ChangeList& GetChangeList ( )

Returns the change list to which this manager currently logs modifications. A newly created manager doesn't automatically create a change list, so to start logging you need to call StartNewChangeList() once. The change list can be used to undo or redo the changes or even to apply them to a different node system, see Apply().

Returns
Current change list, may be a null reference.

◆ StartNewChangeList()

MAXON_METHOD Result<ChangeList> StartNewChangeList ( )

Starts a new change list and returns the previous one. Afterwards this manager will log all modifications to the newly created change list. The new change list can be obtained with GetChangeList() or as the result of the next call to StartNewChangeList(). The returned change list contains all modifications which have been made since the previous call to StartNewChangeList(). You can pass it to Apply() to undo or redo the changes.

Returns
Change list which contains the modifications since the previous call to StartNewChangeList().

◆ Apply()

MAXON_METHOD Result<ChangeList> Apply ( const ChangeList &  list,
Bool  inverse 
)

Applies the given change list to the node system of this manager.

Parameters
[in]listChange list to apply.
[in]inverseUse true if the inverse of the change list shall be applied (for an undo), false otherwise.
Returns
A new change list which contains those changes of list which couldn't be applied, for example the change of an attribute value at a node which doesn't exist in the node system.

◆ MAXON_OBSERVABLE() [1/3]

MAXON_OBSERVABLE ( void  ,
ObservableTransactionStarted  ,
(const NodeSystemManagerRef &manager, const DataDictionary &userData ,
ObservableCombinerRunAllComponent   
)

Informs about the start of a transaction. This is called during BeginTransaction(), but only for outmost transactions (which aren't nested within other transactions).

Parameters
[in]managerThe manager at which the observer was registered.
[in]userDataThe user data given to GraphModelRef::BeginTransaction(). In case of nested transactions, this is the user data of the outmost (i.e. first) invocation.

◆ MAXON_OBSERVABLE() [2/3]

MAXON_OBSERVABLE ( void  ,
ObservableTransactionCommitted  ,
(const NodeSystemManagerRef &manager, const DataDictionary &transactionUserData)  ,
ObservableCombinerRunAllComponent   
)

Informs about the commit of a transaction. This is called during GraphTransaction::Commit(), but only for outmost transactions (which aren't nested within other transactions).

Parameters
[in]managerThe manager at which the observer was registered.
[in]userDataThe user data given to GraphTransaction::Commit(). In case of nested transactions, this is the merger of the user datas given to all commits.

◆ MAXON_OBSERVABLE() [3/3]

MAXON_OBSERVABLE ( void  ,
ObservableTransactionRolledBack  ,
(const NodeSystemManagerRef &manager)  ,
ObservableCombinerRunAllComponent   
)

Informs about the rollback of a transaction. This is called during GraphTransaction::Rollback(), but only for outmost transactions (which aren't nested within other transactions).

Parameters
[in]managerThe manager at which the observer was registered.

◆ Update()

MAXON_METHOD Result<void> Update ( const Block< const Tuple< AssetReference, AssetBase >> &  updates)
private

◆ SetNodeSystem()

MAXON_METHOD Result<void> SetNodeSystem ( const NodeSystem sys)

◆ IncSystemStamp()

MAXON_METHOD TimeStamp IncSystemStamp ( )

Forces the manager to increment it's TimeStamp. This will force the GraphModel to validate all the outdated GNodeHandle.

See also
GraphModelInterface::GetModificationStamp.
Returns
The incremented stamp value.

◆ CreateGraphModel()

MAXON_METHOD Result<NodesGraphModelRef> CreateGraphModel ( ) const
protected

Creates a new graph model instance of an implementation class which is suitable for this manager. Initialization methods will be called later.

Returns
New graph model instance.