Medical Imaging Interaction Toolkit  2024.06.99-ccaff7ce
Medical Imaging Interaction Toolkit
mitk::Forms Namespace Reference

Namespaces

 UI
 

Classes

class  CheckboxesQuestion
 A Question whose possible responses are represented by checkboxes. More...
 
class  DropdownQuestion
 A Question whose possible responses are represented by a combo box. More...
 
class  Form
 
class  IQuestionFactory
 Register subclasses of Question to create instances of them based on their type string. More...
 
class  LinearScaleQuestion
 A Question whose possible responses are represented by a discrete linear scale. More...
 
class  ModuleActivator
 
class  MultipleChoiceQuestion
 A Question whose possible responses are represented by radio buttons. More...
 
class  ParagraphQuestion
 A Question whose possible response is free text. More...
 
class  Question
 Abstract base class for all types of questions used in a Form. More...
 
class  QuestionFactory
 
class  QuestionWithOptions
 Base class for questions with options to choose from as response. More...
 
class  QuestionWithOtherOption
 Base class for questions with options that may also have a free text option. More...
 
class  ScreenshotQuestion
 
class  ShortAnswerQuestion
 A Question whose possible response is a short single-line free text. More...
 
class  TextQuestion
 

Functions

MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, CheckboxesQuestion &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const CheckboxesQuestion &q)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, DropdownQuestion &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const DropdownQuestion &q)
 
MITKFORMS_EXPORT void SubmitToCSV (const Form &form, const fs::path &csvPath)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, Form &f)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const Form &f)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, LinearScaleQuestion &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const LinearScaleQuestion &q)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, MultipleChoiceQuestion &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const MultipleChoiceQuestion &q)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, ParagraphQuestion &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const ParagraphQuestion &q)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, Question &q)
 Deserialize from JSON. More...
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const Question &q)
 Serialize to JSON. More...
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, QuestionWithOptions &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const QuestionWithOptions &q)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, QuestionWithOtherOption &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const QuestionWithOtherOption &q)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, ScreenshotQuestion &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const ScreenshotQuestion &q)
 
MITKFORMS_EXPORT void from_json (const nlohmann::ordered_json &j, ShortAnswerQuestion &q)
 
MITKFORMS_EXPORT void to_json (nlohmann::ordered_json &j, const ShortAnswerQuestion &q)
 

Function Documentation

◆ from_json() [1/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
CheckboxesQuestion q 
)

◆ from_json() [2/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
DropdownQuestion q 
)

◆ from_json() [3/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
Form f 
)

◆ from_json() [4/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
LinearScaleQuestion q 
)

◆ from_json() [5/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
MultipleChoiceQuestion q 
)

◆ from_json() [6/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
ParagraphQuestion q 
)

◆ from_json() [7/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
Question q 
)

Deserialize from JSON.

Polymorphism and the use of base class pointers make it necessary to implement serialization through member functions. Using the pure native approach of the "JSON for Modern C++" library via free functions would lead to partially serialized instances of derived classes.

The actual implementation can and should still be located in a from_json() free function but we also need the indirection through a corresponding member function.

Overloaded functions for derived Question classes should reuse their base class versions of the function.

void mitk::Forms::from_json(const ordered_json& j, RhetoricalQuestion& q)
{
from_json(j, static_cast<Question&>(q));
// TODO: Deserialization of members exclusive to the derived class...
}
See also
Question::FromJSON()

◆ from_json() [8/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
QuestionWithOptions q 
)

◆ from_json() [9/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
QuestionWithOtherOption q 
)

◆ from_json() [10/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
ScreenshotQuestion q 
)

◆ from_json() [11/11]

MITKFORMS_EXPORT void mitk::Forms::from_json ( const nlohmann::ordered_json &  j,
ShortAnswerQuestion q 
)

◆ SubmitToCSV()

MITKFORMS_EXPORT void mitk::Forms::SubmitToCSV ( const Form form,
const fs::path &  csvPath 
)

◆ to_json() [1/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const CheckboxesQuestion q 
)

◆ to_json() [2/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const DropdownQuestion q 
)

◆ to_json() [3/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const Form f 
)

◆ to_json() [4/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const LinearScaleQuestion q 
)

◆ to_json() [5/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const MultipleChoiceQuestion q 
)

◆ to_json() [6/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const ParagraphQuestion q 
)

◆ to_json() [7/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const Question q 
)

Serialize to JSON.

Polymorphism and the use of base class pointers make it necessary to implement serialization through member functions. Using the pure native approach of the "JSON for Modern C++" library via free functions would lead to partially serialized instances of derived classes.

The actual implementation can and should still be located in a to_json() free function but we also need the indirection through a corresponding member function.

Overloaded functions for derived Question classes should reuse their base class versions of the function.

void mitk::Forms::to_json(nlohmann::ordered_json& j, const RhetoricalQuestion& q)
{
to_json(j, static_cast<Question&>(q));
// TODO: Serialization of members exclusive to the derived class...
}
See also
Question::ToJSON()

◆ to_json() [8/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const QuestionWithOptions q 
)

◆ to_json() [9/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const QuestionWithOtherOption q 
)

◆ to_json() [10/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const ScreenshotQuestion q 
)

◆ to_json() [11/11]

MITKFORMS_EXPORT void mitk::Forms::to_json ( nlohmann::ordered_json &  j,
const ShortAnswerQuestion q 
)
mitk::Forms::to_json
MITKFORMS_EXPORT void to_json(nlohmann::ordered_json &j, const CheckboxesQuestion &q)
mitk::Forms::from_json
MITKFORMS_EXPORT void from_json(const nlohmann::ordered_json &j, CheckboxesQuestion &q)