![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Dicom/DicomModule.h>
Base class for Dicom Modules. More...
A module is a logical group of elements. Modules are not directly part of a Dicom file but the standard structures all elements that are part of an IOD into modules. The module description contains the exact specification of an element. The same element can be specified differently in multiple modules, e.g. the samplesPerPixel element in the ImagePixel module allows values 1 and 3, but the CT Image module only allows a value of 1.
The Module class represents a single Dicom module definition and provides all relevant elements. It also applies certain restriction to its elements in order to check if mandatory elements are missing or if the element value is in a valid range. Additionally, most modules provide helper methods to apply the module content to the actual image data.
A module is best be implemented by following the corresponding table in the Dicom standard (e.g. for the ImagePixel Module: http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.3.html) and adding an Element per (relevant) attribute (see also PS 3.6 6 and PS 3.5 6.2 to derive a suitable element template type).
Public Types | |
enum | Type { Mandatory , UserOption , Conditional } |
Conditionality of the module. | |
![]() | |
using | ErrorCallback = std::function<void(const Error&)> |
Alias for a function to call for each error recorded. | |
Public Member Functions | |
Module (ModuleList &parent, Type type) | |
Creates a new Dicom Module, registers it with the given parent and sets the given type/conditionality. | |
virtual bool | isMandatory () const |
Evaluates whether this module is mandatory (based on the specified type and optionally condition). | |
void | setCondition (std::function< bool()> predicate) |
Sets a callback function that determines if a conditional module is mandatory. | |
virtual void | checkErrors (bool ignoreMandatory=false) const |
Checks the module for errors. | |
DcmItem & | dataset () override |
Returns the data set this module corresponds to. | |
![]() | |
const std::vector< ElementBase * > & | elements () const |
List of all elements. | |
![]() | |
virtual void * | registerErrorHandler (ErrorCallback handler) |
Registers a new handler callback function. | |
virtual void | unregisterErrorHandler (void *handler) |
Removes a previously registered handler again. | |
void * | forwardErrors (const ErrorRecorder *otherRecorder) |
Convenient function to forward all errors registered to this recorder to another recorder. | |
virtual void | registerError (const Error &error) const |
Sends the given error to all error handler callbacks. | |
void | registerError (Error::Code code, Error::Type type, const std::string &details, TagProxy tag=TagProxy()) const |
Protected Attributes | |
ModuleList & | m_parent |
List this module is part of. | |
DcmItem & | m_dataset |
The data set this module corresponds to. | |
Type | m_type |
Conditionality of this module. | |
std::function< bool()> | m_typeCondition |
Optional predicate function to evaluate mandatoriness. | |
![]() | |
std::vector< ElementBase * > | m_elements |
List of all elements. | |
Additional Inherited Members | |
![]() | |
NotCopyable (NotCopyable &&) noexcept=default | |
NotCopyable & | operator= (NotCopyable &&) noexcept=default |
NotCopyable (const NotCopyable &)=delete | |
NotCopyable & | operator= (const NotCopyable &)=delete |
void setCondition | ( | std::function< bool()> | predicate | ) |
Sets a callback function that determines if a conditional module is mandatory.
It is ignored if the type is set to Mandatory
or UserOption
.
predicate | Predicate callback function to determine whether the element has to be present or not. If set to nullptr, the condition is always false (i.e. never mandatory). The default value is nullptr (correlates to DICOM's 'User Option' type). |
|
virtual |
Checks the module for errors.
This assures that all mandatory and conditional elements are present and that all existing elements have a valid value. If ignoreMandatory is true, missing mandatory elements are not counted as errors (e.g. useful when the Module itself is optional).
|
overridevirtual |
Returns the data set this module corresponds to.
Implements ElementList.