Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::StandaloneDataStorage Class Reference

Concrete DataStorage implementation that stores nodes in an in-memory adjacency list graph. More...

#include <mitkStandaloneDataStorage.h>

Inheritance diagram for mitk::StandaloneDataStorage:
Collaboration diagram for mitk::StandaloneDataStorage:

Public Member Functions

 mitkClassMacro (StandaloneDataStorage, mitk::DataStorage)
 
Pointer Clone () const
 
void Add (mitk::DataNode *node, const mitk::DataStorage::SetOfObjects *parents=nullptr) override
 Add a DataNode to the storage, optionally with parent (source) nodes. More...
 
void Remove (const mitk::DataNode *node) override
 Remove a node from the StandaloneDataStorage. More...
 
bool Exists (const mitk::DataNode *node) const override
 Check whether a node exists in this StandaloneDataStorage. More...
 
SetOfObjects::ConstPointer GetSources (const mitk::DataNode *node, const NodePredicateBase *condition=nullptr, bool onlyDirectSources=true) const override
 Return the source (parent) nodes of a given node, optionally filtered. More...
 
SetOfObjects::ConstPointer GetDerivations (const mitk::DataNode *node, const NodePredicateBase *condition=nullptr, bool onlyDirectDerivations=true) const override
 Return the derived (child) nodes of a given node, optionally filtered. More...
 
SetOfObjects::ConstPointer GetAll () const override
 Return all nodes managed by this StandaloneDataStorage. More...
 
virtual void Add (DataNode *node, const DataStorage::SetOfObjects *parents=nullptr)=0
 Add a DataNode to the storage, optionally with parent (source) nodes. More...
 
void Add (DataNode *node, DataNode *parent)
 Convenience method to add a node with a single parent. More...
 
void Add (DataNode *node, const ConstSetOfObjects *parents)
 Convenience overload for callers that hold only const node pointers for the parents. More...
 
- Public Member Functions inherited from mitk::DataStorage
 mitkClassMacroItkParent (DataStorage, itk::Object)
 
void Add (DataNode *node, DataNode *parent)
 Convenience method to add a node with a single parent. More...
 
void Add (DataNode *node, const ConstSetOfObjects *parents)
 Convenience overload for callers that hold only const node pointers for the parents. More...
 
void Remove (const DataStorage::SetOfObjects *nodes)
 Remove a set of nodes from the DataStorage. More...
 
void Remove (const ConstSetOfObjects *nodes)
 Remove a set of const-pointer nodes from the DataStorage. More...
 
SetOfObjects::ConstPointer GetSubset (const NodePredicateBase *condition) const
 Return all nodes that satisfy the given predicate condition. More...
 
DataNode * GetNode (const NodePredicateBase *condition=nullptr) const
 Convenience method to get the first node that matches the predicate condition. More...
 
DataNode * GetNamedNode (const char *name) const
 Convenience method to get the first node with a given name. More...
 
DataNode * GetNamedNode (const std::string &name) const
 Convenience method to get the first node with a given name (std::string overload). More...
 
DataNode * GetNamedDerivedNode (const char *name, const DataNode *sourceNode, bool onlyDirectDerivations=true) const
 Convenience method to get the first node with a given name that is derived from a source node. More...
 
template<class DataType >
DataType * GetNamedObject (const char *name) const
 Convenience method to get the first data object of a given type with a given name. More...
 
template<class DataType >
DataType * GetNamedObject (const std::string &name) const
 Convenience method to get the first data object of a given type with a given name (std::string overload). More...
 
template<class DataType >
DataType * GetNamedDerivedObject (const char *name, const DataNode *sourceNode, bool onlyDirectDerivations=true) const
 Convenience method to get the first data object of a given type with a given name, derived from a source node. More...
 
std::string GetUniqueName (const std::string &name, const DataNode *sourceNode=nullptr, bool onlyDirectDerivations=true) const
 Generate a unique node name by appending an incrementing number if necessary. More...
 
const DataNode::GroupTagList GetGroupTags () const
 Return all group tags used across all nodes in the DataStorage. More...
 
TimeGeometry::ConstPointer ComputeBoundingGeometry3D (const SetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
 Compute the axis-parallel bounding geometry encompassing the given set of nodes. More...
 
TimeGeometry::ConstPointer ComputeBoundingGeometry3D (const ConstSetOfObjects *input, const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
 Compute the axis-parallel bounding geometry for a set of const node pointers. More...
 
TimeGeometry::ConstPointer ComputeBoundingGeometry3D (const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr) const
 Compute the axis-parallel bounding geometry of all nodes in the DataStorage. More...
 
TimeGeometry::ConstPointer ComputeVisibleBoundingGeometry3D (const BaseRenderer *renderer=nullptr, const char *boolPropertyKey=nullptr)
 Compute the axis-parallel bounding geometry of all visible nodes. More...
 
BoundingBox::Pointer ComputeBoundingBox (const char *boolPropertyKey=nullptr, const BaseRenderer *renderer=nullptr, const char *boolPropertyKey2=nullptr)
 Compute the axis-parallel bounding box of all nodes in the DataStorage. More...
 
BoundingBox::Pointer ComputeVisibleBoundingBox (const BaseRenderer *renderer=nullptr, const char *boolPropertyKey=nullptr)
 Compute the bounding box of all visible nodes. More...
 
TimeBounds ComputeTimeBounds (const char *boolPropertyKey, const BaseRenderer *renderer, const char *boolPropertyKey2)
 Compute the time bounds of all nodes in the DataStorage. More...
 
TimeBounds ComputeTimeBounds (const BaseRenderer *renderer, const char *boolPropertyKey)
 Compute the time bounds of all visible nodes. More...
 
void BlockNodeModifiedEvents (bool block)
 Enable or disable suppression of ChangedNodeEvent emission. More...
 

Static Public Member Functions

static Pointer New ()
 

Public Attributes

std::mutex m_Mutex
 Mutex protecting the internal adjacency lists for thread-safe access. More...
 
- Public Attributes inherited from mitk::DataStorage
std::mutex m_MutexOne
 Mutex for thread-safe operations on the DataStorage. More...
 
DataStorageEvent AddNodeEvent
 Event emitted after a new node has been added to the DataStorage. More...
 
DataStorageEvent RemoveNodeEvent
 Event emitted directly before a node is removed from the DataStorage. More...
 
DataStorageEvent ChangedNodeEvent
 Event emitted after a managed node has been modified. More...
 
DataStorageEvent DeleteNodeEvent
 Event emitted directly before a managed node is deleted. More...
 
DataStorageEvent InteractorChangedNodeEvent
 Event emitted when the DataInteractor of a managed node changes. More...
 

Protected Types

typedef std::map< mitk::DataNode::ConstPointer, SetOfObjects::ConstPointer > AdjacencyList
 noncyclical directed graph data structure to store the nodes with their relation More...
 

Protected Member Functions

 StandaloneDataStorage ()
 
 ~StandaloneDataStorage () override
 
bool IsInitialized () const
 convenience method to check if the object has been initialized (i.e. a data tree has been set) More...
 
SetOfObjects::ConstPointer GetRelations (const mitk::DataNode *node, const AdjacencyList &relation, const NodePredicateBase *condition=nullptr, bool onlyDirectlyRelated=true) const
 Traverses the Relation graph and extracts a list of related elements (e.g. Sources or Derivations) More...
 
void RemoveFromRelation (const mitk::DataNode *node, AdjacencyList &relation)
 deletes all references to a node in a given relation (used in Remove() and TreeListener) More...
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 Prints the contents of the StandaloneDataStorage to os. Do not call directly, call ->Print() instead. More...
 
- Protected Member Functions inherited from mitk::DataStorage
void EmitAddNodeEvent (const DataNode *node)
 EmitAddNodeEvent emits the AddNodeEvent. More...
 
void EmitRemoveNodeEvent (const DataNode *node)
 EmitRemoveNodeEvent emits the RemoveNodeEvent. More...
 
void OnNodeInteractorChanged (itk::Object *caller, const itk::EventObject &event)
 
void OnNodeModifiedOrDeleted (const itk::Object *caller, const itk::EventObject &event)
 OnNodeModified listens to modified events of DataNodes. More...
 
void AddListeners (const DataNode *_Node)
 Adds a Modified-Listener to the given Node. More...
 
void RemoveListeners (const DataNode *_Node)
 Removes a Modified-Listener from the given Node. More...
 
 DataStorage ()
 
 ~DataStorage () override
 
SetOfObjects::ConstPointer FilterSetOfObjects (const SetOfObjects *set, const NodePredicateBase *condition) const
 Filters a SetOfObjects by the condition. If no condition is provided, the original set is returned. More...
 
void PrintSelf (std::ostream &os, itk::Indent indent) const override
 Prints the contents of the DataStorage to os. Do not call directly, call ->Print() instead. More...
 

Protected Attributes

AdjacencyList m_SourceNodes
 Nodes and their relation are stored in m_SourceNodes. More...
 
AdjacencyList m_DerivedNodes
 Nodes are stored in reverse relation for easier traversal in the opposite direction of the relation. More...
 
- Protected Attributes inherited from mitk::DataStorage
std::map< const DataNode *, unsigned long > m_NodeModifiedObserverTags
 Saves Modified-Observer Tags for each node in order to remove the event listeners again. More...
 
std::map< const DataNode *, unsigned long > m_NodeInteractorChangedObserverTags
 
std::map< const DataNode *, unsigned long > m_NodeDeleteObserverTags
 Saves Delete-Observer Tags for each node in order to remove the event listeners again. More...
 
bool m_BlockNodeModifiedEvents
 If this class changes nodes itself, set this to TRUE in order to suppress NodeChangedEvent to be emitted. More...
 

Additional Inherited Members

- Public Types inherited from mitk::DataStorage
typedef itk::VectorContainer< unsigned int, DataNode::Pointer > SetOfObjects
 Container type used as a result set of query operations such as GetSubset(). More...
 
typedef itk::VectorContainer< unsigned int, DataNode::ConstPointer > ConstSetOfObjects
 Container type for const node pointers, used for input parameters where nodes are read-only. More...
 
typedef Message1< const DataNode * > DataStorageEvent
 Event type used for all DataStorage notifications, carrying a const DataNode pointer. More...
 

Detailed Description

Concrete DataStorage implementation that stores nodes in an in-memory adjacency list graph.

StandaloneDataStorage is the standard implementation of mitk::DataStorage. It manages 'was created by' relationships by maintaining two adjacency lists: one for source (parent) nodes and one for derived (child) nodes. The graph structure is non-cyclical and directed.

This class is fully thread-safe; all public methods that access the internal data structures are protected by a mutex.

See also
DataStorage, DataNode

Definition at line 41 of file mitkStandaloneDataStorage.h.

Member Typedef Documentation

◆ AdjacencyList

typedef std::map<mitk::DataNode::ConstPointer, SetOfObjects::ConstPointer> mitk::StandaloneDataStorage::AdjacencyList
protected

noncyclical directed graph data structure to store the nodes with their relation

Definition at line 129 of file mitkStandaloneDataStorage.h.

Constructor & Destructor Documentation

◆ StandaloneDataStorage()

mitk::StandaloneDataStorage::StandaloneDataStorage ( )
protected

◆ ~StandaloneDataStorage()

mitk::StandaloneDataStorage::~StandaloneDataStorage ( )
overrideprotected

Member Function Documentation

◆ Add() [1/4]

void mitk::DataStorage::Add

Convenience overload for callers that hold only const node pointers for the parents.

Converts the ConstSetOfObjects to a SetOfObjects internally and delegates to the virtual Add() method.

Parameters
[in]nodeThe DataNode to add. Must not be nullptr.
[in]parentsOptional set of const parent node pointers. May be nullptr.
Exceptions
std::invalid_argumentif node is nullptr or already exists in the DataStorage.
See also
Add(DataNode*, const SetOfObjects*)

◆ Add() [2/4]

virtual void mitk::DataStorage::Add

Add a DataNode to the storage, optionally with parent (source) nodes.

The node is added to the internal graph structure. If parents is provided, 'was created from' relationships are established between the node and its parents. After a successful addition, AddNodeEvent is emitted.

Parameters
[in]nodeThe DataNode to add. Must not be nullptr.
[in]parentsOptional set of parent nodes. May be nullptr.
Exceptions
std::invalid_argumentif node is nullptr or already exists in the DataStorage.
See also
Remove, AddNodeEvent

◆ Add() [3/4]

void mitk::DataStorage::Add

Convenience method to add a node with a single parent.

Parameters
[in]nodeThe DataNode to add. Must not be nullptr.
[in]parentThe parent node. May be nullptr (equivalent to adding without parents).
Exceptions
std::invalid_argumentif node is nullptr or already exists in the DataStorage.
See also
Add(DataNode*, const SetOfObjects*)

◆ Add() [4/4]

void mitk::StandaloneDataStorage::Add ( mitk::DataNode *  node,
const mitk::DataStorage::SetOfObjects *  parents = nullptr 
)
overridevirtual

Add a DataNode to the storage, optionally with parent (source) nodes.

Inserts the node into the internal adjacency lists and establishes 'was created from' relationships. Emits AddNodeEvent upon successful addition.

Parameters
[in]nodeThe DataNode to add. Must not be nullptr.
[in]parentsOptional set of parent nodes. May be nullptr.
Exceptions
std::logic_errorif the DataStorage is not initialized.
std::invalid_argumentif node is its own parent or already exists.
See also
Remove, DataStorage::Add

Implements mitk::DataStorage.

◆ Clone()

Pointer mitk::StandaloneDataStorage::Clone ( ) const

◆ Exists()

bool mitk::StandaloneDataStorage::Exists ( const mitk::DataNode *  node) const
overridevirtual

Check whether a node exists in this StandaloneDataStorage.

Parameters
[in]nodeThe node to check.
Returns
true if the node is present.

Implements mitk::DataStorage.

◆ GetAll()

SetOfObjects::ConstPointer mitk::StandaloneDataStorage::GetAll ( ) const
overridevirtual

Return all nodes managed by this StandaloneDataStorage.

Returns
A set containing all DataNodes.
Exceptions
std::logic_errorif the DataStorage is not initialized.

Implements mitk::DataStorage.

◆ GetDerivations()

SetOfObjects::ConstPointer mitk::StandaloneDataStorage::GetDerivations ( const mitk::DataNode *  node,
const NodePredicateBase *  condition = nullptr,
bool  onlyDirectDerivations = true 
) const
overridevirtual

Return the derived (child) nodes of a given node, optionally filtered.

Returns nodes that were created from (derived from) the given node.

Parameters
[in]nodeThe node whose derivations are queried.
[in]conditionOptional predicate to filter results.
[in]onlyDirectDerivationsIf true (default), only direct children are returned. If false, all transitive derivations are traversed.
Returns
A set of derived DataNodes.
Exceptions
std::invalid_argumentif node is nullptr.
See also
GetSources

Implements mitk::DataStorage.

◆ GetRelations()

SetOfObjects::ConstPointer mitk::StandaloneDataStorage::GetRelations ( const mitk::DataNode *  node,
const AdjacencyList &  relation,
const NodePredicateBase *  condition = nullptr,
bool  onlyDirectlyRelated = true 
) const
protected

Traverses the Relation graph and extracts a list of related elements (e.g. Sources or Derivations)

◆ GetSources()

SetOfObjects::ConstPointer mitk::StandaloneDataStorage::GetSources ( const mitk::DataNode *  node,
const NodePredicateBase *  condition = nullptr,
bool  onlyDirectSources = true 
) const
overridevirtual

Return the source (parent) nodes of a given node, optionally filtered.

Parameters
[in]nodeThe node whose sources are queried.
[in]conditionOptional predicate to filter results.
[in]onlyDirectSourcesIf true (default), only direct parents are returned. If false, all transitive sources are traversed.
Returns
A set of source DataNodes.
Exceptions
std::invalid_argumentif node is nullptr.
See also
GetDerivations

Implements mitk::DataStorage.

◆ IsInitialized()

bool mitk::StandaloneDataStorage::IsInitialized ( ) const
protected

convenience method to check if the object has been initialized (i.e. a data tree has been set)

◆ mitkClassMacro()

mitk::StandaloneDataStorage::mitkClassMacro ( StandaloneDataStorage  ,
mitk::DataStorage   
)

◆ New()

static Pointer mitk::StandaloneDataStorage::New ( )
static

◆ PrintSelf()

void mitk::StandaloneDataStorage::PrintSelf ( std::ostream &  os,
itk::Indent  indent 
) const
overrideprotected

Prints the contents of the StandaloneDataStorage to os. Do not call directly, call ->Print() instead.

◆ Remove()

void mitk::StandaloneDataStorage::Remove ( const mitk::DataNode *  node)
overridevirtual

Remove a node from the StandaloneDataStorage.

Removes the node from both adjacency lists and emits RemoveNodeEvent before removal. If node is nullptr, the call is ignored.

Parameters
[in]nodeThe node to remove.
Exceptions
std::logic_errorif the DataStorage is not initialized.
See also
Add

Implements mitk::DataStorage.

◆ RemoveFromRelation()

void mitk::StandaloneDataStorage::RemoveFromRelation ( const mitk::DataNode *  node,
AdjacencyList &  relation 
)
protected

deletes all references to a node in a given relation (used in Remove() and TreeListener)

Member Data Documentation

◆ m_DerivedNodes

AdjacencyList mitk::StandaloneDataStorage::m_DerivedNodes
protected

Nodes are stored in reverse relation for easier traversal in the opposite direction of the relation.

Definition at line 158 of file mitkStandaloneDataStorage.h.

◆ m_Mutex

std::mutex mitk::StandaloneDataStorage::m_Mutex
mutable

Mutex protecting the internal adjacency lists for thread-safe access.

Definition at line 124 of file mitkStandaloneDataStorage.h.

◆ m_SourceNodes

AdjacencyList mitk::StandaloneDataStorage::m_SourceNodes
protected

Nodes and their relation are stored in m_SourceNodes.

Definition at line 155 of file mitkStandaloneDataStorage.h.


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