Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
mitkQuestionFactory.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef mitkQuestionFactory_h
14 #define mitkQuestionFactory_h
15 
16 #include <mitkIQuestionFactory.h>
17 
18 #include <memory>
19 #include <string>
20 #include <unordered_map>
21 
22 namespace mitk::Forms
23 {
31  {
32  public:
34  ~QuestionFactory() override;
35 
40  void Register(Question* question) override;
41 
47  Question* Create(const std::string& type) const override;
48 
49  private:
50  std::unordered_map<std::string, std::unique_ptr<Question>> m_Prototypes;
51  };
52 }
53 
54 #endif
Register subclasses of Question to create instances of them based on their type string.
Default implementation of IQuestionFactory using prototype-based creation.
Question * Create(const std::string &type) const override
Create a new question instance by cloning the registered prototype for the given type.
void Register(Question *question) override
Register a question prototype. Takes ownership of the pointer.
Abstract base class for all types of questions used in a Form.
Definition: mitkQuestion.h:38