Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::IRestServerService Struct Referenceabstract

Service interface for the REST API server. More...

#include <mitkIRestServerService.h>

Inheritance diagram for mitk::IRestServerService:

Public Member Functions

virtual ~IRestServerService ()
 
virtual bool Start ()=0
 Start the REST server with the pending configuration. More...
 
virtual void Stop ()=0
 Stop the REST server. More...
 
virtual bool IsRunning () const =0
 Check if the server is currently running. More...
 
virtual void SetConfig (const RestServerConfig &config)=0
 Set the pending server configuration. More...
 
virtual RestServerConfig GetPendingConfig () const =0
 Get the pending server configuration. More...
 
virtual std::optional< RestServerConfig > GetRunningConfig () const =0
 Get the configuration the server is currently running with. More...
 
virtual RenderWindowBridge * GetRenderWindowBridge ()=0
 Return the server-owned RenderWindowBridge. More...
 
virtual void SetDataStorage (DataStorage *dataStorage)=0
 Set the DataStorage for REST API operations. More...
 
virtual DataStorage::Pointer GetDataStorage () const =0
 Get the currently connected DataStorage. More...
 
virtual std::optional< std::string > GetServerUrl () const =0
 Get the full URL where the server is listening. More...
 
virtual std::optional< std::string > GetLastError () const =0
 Get the last error message. More...
 
virtual std::vector< std::string > GetClientIPs () const =0
 Get the list of client IP addresses that have sent requests. More...
 
virtual std::optional< RequestInfo > GetLastRequestInfo () const =0
 Get information about the last request processed. More...
 
virtual void SetLogLimit (std::optional< unsigned int > limit)=0
 Set the request log limit. More...
 
virtual std::optional< unsigned int > GetLogLimit () const =0
 Get the current request log limit. More...
 
virtual std::vector< RequestInfo > GetRequestLog () const =0
 Get all logged requests. More...
 
virtual void ClearRequestLog ()=0
 Clear all logged requests. More...
 
virtual uint64_t GetRequestLogVersion () const =0
 Get the request log version counter. More...
 
virtual std::optional< int64_t > GetUptimeSeconds () const =0
 Get the server uptime in seconds. More...
 

Detailed Description

Service interface for the REST API server.

Allows other modules and plugins to:

  • Start/stop the server
  • Configure server settings
  • Connect a DataStorage instance
  • Query server status

Configuration Semantics

The server maintains two configuration states:

  • Pending configuration: Set via SetConfig(), takes effect on next Start()
  • Running configuration: The configuration the server is actually running with

GetPendingConfig() returns the configuration that will be used on next Start(). GetRunningConfig() returns the configuration the server is currently running with, or std::nullopt if the server is not running.

Definition at line 63 of file mitkIRestServerService.h.

Constructor & Destructor Documentation

◆ ~IRestServerService()

virtual mitk::IRestServerService::~IRestServerService ( )
virtual

Member Function Documentation

◆ ClearRequestLog()

virtual void mitk::IRestServerService::ClearRequestLog ( )
pure virtual

Clear all logged requests.

Implemented in mitk::RestServer.

◆ GetClientIPs()

virtual std::vector<std::string> mitk::IRestServerService::GetClientIPs ( ) const
pure virtual

Get the list of client IP addresses that have sent requests.

Returns a list of unique IP addresses from clients that have made requests to the server since it was started.

Returns
Vector of client IP addresses, empty if no requests have been made.

Implemented in mitk::RestServer.

◆ GetDataStorage()

virtual DataStorage::Pointer mitk::IRestServerService::GetDataStorage ( ) const
pure virtual

Get the currently connected DataStorage.

Returns
The connected DataStorage, or nullptr if none.

Implemented in mitk::RestServer.

◆ GetLastError()

virtual std::optional<std::string> mitk::IRestServerService::GetLastError ( ) const
pure virtual

Get the last error message.

Returns
The last error message, or std::nullopt if no error occurred since last Start().

Implemented in mitk::RestServer.

◆ GetLastRequestInfo()

virtual std::optional<RequestInfo> mitk::IRestServerService::GetLastRequestInfo ( ) const
pure virtual

Get information about the last request processed.

Returns
The last request info, or std::nullopt if no requests have been processed.

Implemented in mitk::RestServer.

◆ GetLogLimit()

virtual std::optional<unsigned int> mitk::IRestServerService::GetLogLimit ( ) const
pure virtual

Get the current request log limit.

Returns
The limit, or std::nullopt if unlimited.

Implemented in mitk::RestServer.

◆ GetPendingConfig()

virtual RestServerConfig mitk::IRestServerService::GetPendingConfig ( ) const
pure virtual

Get the pending server configuration.

This is the configuration that will be used on the next Start() call.

Returns
The pending configuration.

Implemented in mitk::RestServer.

◆ GetRenderWindowBridge()

virtual RenderWindowBridge* mitk::IRestServerService::GetRenderWindowBridge ( )
pure virtual

Return the server-owned RenderWindowBridge.

The bridge is owned by the server. UI-layer plugins (e.g. the Qt workbench plugin) configure it by setting callbacks for screenshot capture and crosshair position access. Callbacks must be cleared before the objects they reference are destroyed.

Returns
Pointer to the bridge. Never null.

Implemented in mitk::RestServer.

◆ GetRequestLog()

virtual std::vector<RequestInfo> mitk::IRestServerService::GetRequestLog ( ) const
pure virtual

Get all logged requests.

Returns the request log in chronological order (oldest first).

Returns
Vector of request info entries.

Implemented in mitk::RestServer.

◆ GetRequestLogVersion()

virtual uint64_t mitk::IRestServerService::GetRequestLogVersion ( ) const
pure virtual

Get the request log version counter.

Incremented on every log mutation (new entry, clear, trim). Allows consumers to detect changes without copying the full log.

Returns
Monotonically increasing version number.

Implemented in mitk::RestServer.

◆ GetRunningConfig()

virtual std::optional<RestServerConfig> mitk::IRestServerService::GetRunningConfig ( ) const
pure virtual

Get the configuration the server is currently running with.

Returns
The running configuration, or std::nullopt if server is not running.

Implemented in mitk::RestServer.

◆ GetServerUrl()

virtual std::optional<std::string> mitk::IRestServerService::GetServerUrl ( ) const
pure virtual

Get the full URL where the server is listening.

Returns
The server URL (e.g., "http://127.0.0.1:8080"), or std::nullopt if not running.

Implemented in mitk::RestServer.

◆ GetUptimeSeconds()

virtual std::optional<int64_t> mitk::IRestServerService::GetUptimeSeconds ( ) const
pure virtual

Get the server uptime in seconds.

Returns
Uptime in seconds, or std::nullopt if server is not running.

Implemented in mitk::RestServer.

◆ IsRunning()

virtual bool mitk::IRestServerService::IsRunning ( ) const
pure virtual

Check if the server is currently running.

Returns
true if the server is running, false otherwise.

Implemented in mitk::RestServer.

◆ SetConfig()

virtual void mitk::IRestServerService::SetConfig ( const RestServerConfig &  config)
pure virtual

Set the pending server configuration.

The configuration will take effect on the next Start() call. If the server is currently running, this only changes the pending config; the running config remains unchanged until Restart().

Parameters
configThe new configuration to use on next start.

Implemented in mitk::RestServer.

◆ SetDataStorage()

virtual void mitk::IRestServerService::SetDataStorage ( DataStorage *  dataStorage)
pure virtual

Set the DataStorage for REST API operations.

The server can operate without a DataStorage (graceful degradation), but data storage operations will return appropriate error responses. Can be called while the server is running.

Parameters
dataStorageThe DataStorage to use, or nullptr to disconnect.

Implemented in mitk::RestServer.

◆ SetLogLimit()

virtual void mitk::IRestServerService::SetLogLimit ( std::optional< unsigned int >  limit)
pure virtual

Set the request log limit.

Controls how many request entries are kept in the log. The log is cleared when the server starts.

Parameters
limitMaximum number of entries to keep, or std::nullopt for unlimited.

Implemented in mitk::RestServer.

◆ Start()

virtual bool mitk::IRestServerService::Start ( )
pure virtual

Start the REST server with the pending configuration.

If the server is already running, this is a no-op and returns true. The pending configuration becomes the running configuration upon successful start.

Warning
Blocks until the server's listen loop is ready. Do not call it synchronously while a platform loader / plugin-activation lock is held: the blocking wait under that lock deadlocks. Defer the call onto the dispatch thread via StorageThreadDispatcherBase::Post() in that case.
Returns
true if the server started successfully (or was already running), false otherwise.

Implemented in mitk::RestServer.

◆ Stop()

virtual void mitk::IRestServerService::Stop ( )
pure virtual

Stop the REST server.

Blocks until the server is fully stopped. If the server is not running, this is a no-op.

Implemented in mitk::RestServer.


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