Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::IDataStorageService Class Referenceabstract

Service interface for managing DataStorage instances. More...

#include <mitkIDataStorageService.h>

Inheritance diagram for mitk::IDataStorageService:

Public Member Functions

virtual ~IDataStorageService ()
 
virtual DataStorage::Pointer GetDefaultDataStorage () const =0
 Get the default (primary) DataStorage. More...
 
virtual DataStorage::Pointer GetActiveDataStorage () const =0
 Get the currently active DataStorage. More...
 
virtual DataStorageReference GetActiveDataStorageReference () const =0
 Get info about the currently active DataStorage. More...
 
virtual bool SetActiveDataStorage (const std::string &label)=0
 Set the active DataStorage by label. More...
 
virtual bool AddDataStorage (const std::string &label, DataStorage::Pointer storage)=0
 Register an existing DataStorage with this service. More...
 
virtual std::optional< DataStorageReference > CreateDataStorage (const std::string &label)=0
 Create a new DataStorage with the given label. More...
 
virtual std::optional< DataStorageReference > GetDataStorageReference (const std::string &label) const =0
 Get info about a specific DataStorage by label. More...
 
virtual std::optional< std::string > GetLabel (const DataStorage *storage) const =0
 Get the label of a registered DataStorage. More...
 
virtual std::vector< std::string > GetAllLabels () const =0
 Get all labels of registered DataStorages. More...
 
virtual std::vector< DataStorageReference > GetAllDataStorages () const =0
 Get information about all registered DataStorages. More...
 
virtual bool HasDataStorage (const std::string &label) const =0
 Check if a DataStorage with the given label exists. More...
 
virtual bool RemoveDataStorage (const std::string &label)=0
 Remove a DataStorage from the service by label. More...
 
virtual StorageThreadDispatcherBase * GetDispatcher () const =0
 Get the configured thread dispatcher (if any). More...
 

Detailed Description

Service interface for managing DataStorage instances.

This service provides access to one or more DataStorage instances within the application. For most use cases, GetDefaultDataStorage() or GetActiveDataStorage() is sufficient.

The service supports multiple labeled DataStorage instances for advanced scenarios like multi-document applications, though typical Workbench usage only uses the default storage.

Access this service via CoreServices::GetDataStorageService().

if (dsService != nullptr)
{
auto storage = servicePtr->GetActiveDataStorage();
// ...
}
RAII wrapper for core service objects.
static IDataStorageService * GetDataStorageService(us::ModuleContext *context=us::GetModuleContext())
Get an IDataStorageService instance.
See also
CoreServices::GetDataStorageService()
DataStorageReference

Definition at line 56 of file mitkIDataStorageService.h.

Constructor & Destructor Documentation

◆ ~IDataStorageService()

virtual mitk::IDataStorageService::~IDataStorageService ( )
virtual

Member Function Documentation

◆ AddDataStorage()

virtual bool mitk::IDataStorageService::AddDataStorage ( const std::string &  label,
DataStorage::Pointer  storage 
)
pure virtual

Register an existing DataStorage with this service.

Use this method to add a DataStorage that was created elsewhere to the service's management. The service takes shared ownership.

Parameters
labelHuman-readable label for the storage. Must be unique and not an empty string (as empty labels always indicate default storage).
storageThe DataStorage to register.
Returns
true if registered successfully, false if label already exists (then the state of the service isn't changed and no storage is added.)

Implemented in mitk::DataStorageService.

◆ CreateDataStorage()

virtual std::optional<DataStorageReference> mitk::IDataStorageService::CreateDataStorage ( const std::string &  label)
pure virtual

Create a new DataStorage with the given label.

Creates a new StandaloneDataStorage and registers it with this service. For registering an existing DataStorage, use AddDataStorage() instead.

Parameters
labelHuman-readable label for the storage. Must be unique.
Returns
Info about the newly created DataStorage, or null option if label exists.

Implemented in mitk::DataStorageService.

◆ GetActiveDataStorage()

virtual DataStorage::Pointer mitk::IDataStorageService::GetActiveDataStorage ( ) const
pure virtual

Get the currently active DataStorage.

Returns the active DataStorage if one has been set via SetActiveDataStorage(), otherwise returns the default.

This is the recommended method for most use cases where you need the "current" DataStorage.

Returns
The active DataStorage, or default if none is active.

Implemented in mitk::DataStorageService.

◆ GetActiveDataStorageReference()

virtual DataStorageReference mitk::IDataStorageService::GetActiveDataStorageReference ( ) const
pure virtual

Get info about the currently active DataStorage.

Similar to GetActiveDataStorage() but returns full info including label.

Returns
Info about the active DataStorage.

Implemented in mitk::DataStorageService.

◆ GetAllDataStorages()

virtual std::vector<DataStorageReference> mitk::IDataStorageService::GetAllDataStorages ( ) const
pure virtual

Get information about all registered DataStorages.

The returned vector always contains at least the default DataStorage.

Returns
Vector of all DataStorageReference objects.

Implemented in mitk::DataStorageService.

◆ GetAllLabels()

virtual std::vector<std::string> mitk::IDataStorageService::GetAllLabels ( ) const
pure virtual

Get all labels of registered DataStorages.

Returns
Vector of all labels. Always contains at least the default label.

Implemented in mitk::DataStorageService.

◆ GetDataStorageReference()

virtual std::optional<DataStorageReference> mitk::IDataStorageService::GetDataStorageReference ( const std::string &  label) const
pure virtual

Get info about a specific DataStorage by label.

Parameters
labelThe label to search for.
Returns
Info about the storage, or std::nullopt if not found.

Implemented in mitk::DataStorageService.

◆ GetDefaultDataStorage()

virtual DataStorage::Pointer mitk::IDataStorageService::GetDefaultDataStorage ( ) const
pure virtual

Get the default (primary) DataStorage.

The default DataStorage is created when the service starts and persists for the lifetime of the application.

Returns
The default DataStorage. Never nullptr after initialization.

Implemented in mitk::DataStorageService.

◆ GetDispatcher()

virtual StorageThreadDispatcherBase* mitk::IDataStorageService::GetDispatcher ( ) const
pure virtual

Get the configured thread dispatcher (if any).

Returns the dispatcher that marshals tasks to the thread owning the DataStorage. Consumers use this to dispatch DataStorage operations from background threads.

Returns
The dispatcher, or nullptr if none configured (headless/test scenarios).

Implemented in mitk::DataStorageService.

◆ GetLabel()

virtual std::optional<std::string> mitk::IDataStorageService::GetLabel ( const DataStorage *  storage) const
pure virtual

Get the label of a registered DataStorage.

Reverse lookup: given a DataStorage pointer, find its label.

Parameters
storageThe DataStorage to look up.
Returns
The label, or std::nullopt if the storage is not registered.

Implemented in mitk::DataStorageService.

◆ HasDataStorage()

virtual bool mitk::IDataStorageService::HasDataStorage ( const std::string &  label) const
pure virtual

Check if a DataStorage with the given label exists.

Parameters
labelThe label to check.
Returns
true if a storage with this label exists, false otherwise.

Implemented in mitk::DataStorageService.

◆ RemoveDataStorage()

virtual bool mitk::IDataStorageService::RemoveDataStorage ( const std::string &  label)
pure virtual

Remove a DataStorage from the service by label.

The default DataStorage cannot be removed. If the removed storage was the active storage, the active storage is reset to the default.

Parameters
labelThe label of the storage to remove.
Returns
true if removed, false if not found or is default.

Implemented in mitk::DataStorageService.

◆ SetActiveDataStorage()

virtual bool mitk::IDataStorageService::SetActiveDataStorage ( const std::string &  label)
pure virtual

Set the active DataStorage by label.

Selects a registered DataStorage as the active one.

Parameters
labelThe label of the storage to make active. Use empty string to revert to the default.
Returns
true if the storage was found and set as active, false otherwise.

Implemented in mitk::DataStorageService.


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