Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitk::Forms::IQuestionFactory Class Referenceabstract

Register subclasses of Question to create instances of them based on their type string. More...

#include <mitkIQuestionFactory.h>

Inheritance diagram for mitk::Forms::IQuestionFactory:

Public Member Functions

virtual ~IQuestionFactory ()
 Virtual destructor. More...
 
virtual void Register (Question *question)=0
 Register a Question subclass for the instance creation based on its type string. More...
 
virtual Question * Create (const std::string &type) const =0
 Create an instance of a Question subclass based on its type string. More...
 

Static Public Member Functions

static IQuestionFactory * GetInstance ()
 Obtain a pointer to the single instance of this service. More...
 

Detailed Description

Register subclasses of Question to create instances of them based on their type string.

This is a service interface. Obtain a pointer to its single instance via GetInstance().

Each Question subclass must be registered by calling Register(), which is typically done in the module activator class. After Question subclasses are registered, instances of them can be created with Create() based on their type string. This mechanism is primarily used for the deserialization of questions.

Definition at line 34 of file mitkIQuestionFactory.h.

Constructor & Destructor Documentation

◆ ~IQuestionFactory()

virtual mitk::Forms::IQuestionFactory::~IQuestionFactory ( )
virtual

Virtual destructor.

Member Function Documentation

◆ Create()

virtual Question* mitk::Forms::IQuestionFactory::Create ( const std::string &  type) const
pure virtual

Create an instance of a Question subclass based on its type string.

Parameters
[in]typeThe type string identifying the Question subclass to instantiate.
Returns
A new Question instance. The caller takes ownership.
See also
Question::GetType(), Question::CreateAnother()

Implemented in mitk::Forms::QuestionFactory.

◆ GetInstance()

static IQuestionFactory* mitk::Forms::IQuestionFactory::GetInstance ( )
static

Obtain a pointer to the single instance of this service.

Returns
A pointer to the IQuestionFactory service, or nullptr if the service is unavailable.

◆ Register()

virtual void mitk::Forms::IQuestionFactory::Register ( Question *  question)
pure virtual

Register a Question subclass for the instance creation based on its type string.

The service takes over ownership of the passed Question pointer. The type string is obtained via Question::GetType() on the passed prototype.

Parameters
[in]questionA prototype instance of the Question subclass. Ownership is transferred.
See also
Question::GetType()

Implemented in mitk::Forms::QuestionFactory.


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