ImFusion SDK 4.3
Element< T > Class Template Reference

#include <ImFusion/Dicom/DicomElement.h>

Dicom Element with a concrete value type. More...

+ Inheritance diagram for Element< T >:

Detailed Description

template<typename T>
class ImFusion::Dicom::Element< T >

Dicom Element with a concrete value type.

Currently the following template specializations are implemented:

DcmDataset& dataset = ...
Dicom::Element<int> rowsEl(dataset, DCM_Rows);
int rows = rowsEl.value(0);
Dicom::Element<std::string> modalityEl(dataset, DCM_Modality);
try {
std::string modality = modality.value();
} catch (const Dicom::value_error&) {
LOG_ERROR("Modality is missing or has invalid value");
}
Dicom::Element<std::vector<double>> privateEl(dataset, DcmTag(DcmTagKey(0x2000, 0x5000), EVR_UL));
std::vector<double> something = privateEl.value({0.0, 1.0});
Dicom Element with a concrete value type.
Definition VolumeReconstruction.h:20
Exception specialization for DICOM element retrieval.
Definition DicomElement.h:51
#define LOG_ERROR(...)
Emits a log message of Log::Level::Error, optionally with a category.
Definition Log.h:257
Examples
DicomExtensionExample2.cpp.

Public Member Functions

 Element (ElementList &module, DcmTag tag, Type type=ElementBase::Conditional, bool searchIntoSubs=false)
 Creates a new Element instance, to be used from a Module (or other ElementList as parent).
 
 Element (DcmItem &item, DcmTag tag, Type type=ElementBase::Conditional, bool searchIntoSubs=false)
 Creates a new Element instance, to be used from anywhere which is not a ElementList.
 
value () const
 Retrieves the value from the dataset.
 
value (const T &defaultValue) const
 Tries retrieving the value from the dataset.
 
void setValue (T value)
 Sets the value in the dataset.
 
void setValidator (std::function< bool(const T &)> isValid)
 Assigns an optional callback function to determine if the element's value is valid in the current context.
 
bool isValid () const override
 Returns whether the element contains valid data (wrt. to the set validator).
 
void insertEmptyElement ()
 Inserts an empty element, forcing the tag to be written into the dataset.
 
- Public Member Functions inherited from ElementBase
 ElementBase (ElementList &parent, DcmTag tag, Type type=Conditional, bool searchIntoSubs=false)
 
 ElementBase (DcmItem &item, DcmTag tag, Type type=Conditional, bool searchIntoSubs=false)
 
void setCondition (std::function< bool()> predicate)
 Sets a callback function that determines if a conditional element is mandatory.
 
virtual DcmTag tag () const
 DICOM tag wrapped by this Element.
 
virtual bool isMandatory () const
 Evaluates whether this element is mandatory (based on the specified type and optionally condition).
 
virtual bool exists () const
 Returns true if the elements exists in the dataset.
 
void remove ()
 Removes the element from the dataset.
 
std::string valueString () const
 Returns the value of the element as a string.
 
void setTargetSequence (DcmItem *sequence)
 Sets an optional sequence item where this elements will write its value.
 

Additional Inherited Members

- Public Types inherited from ElementBase
enum  Type { Mandatory , Conditional }
 Conditionality of an Element. More...
 
- Protected Attributes inherited from ElementBase
DcmItem & m_dataset
 DICOM data set/base element to retrieve element data from.
 
DcmItem * m_targetSeq
 Optional sequence to write element data to; only used for setValue().
 
DcmTag m_tag
 DICOM tag the Element refers to.
 
Type m_type
 Conditionality of the Element.
 
bool m_searchIntoSubs
 Flag whether to search into sub sequences or not.
 
std::function< bool()> m_typeCondition
 Optional predicate function to evaluate conditionality.
 

Constructor & Destructor Documentation

◆ Element() [1/2]

template<typename T>
Element ( ElementList & module,
DcmTag tag,
Type type = ElementBase::Conditional,
bool searchIntoSubs = false )

Creates a new Element instance, to be used from a Module (or other ElementList as parent).

Parameters
moduleParent Module/ElementList holding this element.
tagDICOM tag the Element refers to.
typeConditionality of the Element.
searchIntoSubsFlag whether to search into sub sequences or not.

◆ Element() [2/2]

template<typename T>
Element ( DcmItem & item,
DcmTag tag,
Type type = ElementBase::Conditional,
bool searchIntoSubs = false )

Creates a new Element instance, to be used from anywhere which is not a ElementList.

Parameters
itemDICOM data set/parent item to retrieve element data from.
tagDICOM tag the Element refers to.
typeConditionality of the Element.
searchIntoSubsFlag whether to search into sub sequences or not.

Member Function Documentation

◆ value() [1/2]

template<typename T>
T value ( ) const

Retrieves the value from the dataset.

Throws a value_error if the value could not be retrieved from the dataset (e.g. when it does not exist).

◆ value() [2/2]

template<typename T>
T value ( const T & defaultValue) const

Tries retrieving the value from the dataset.

In contrast to the value() overload, this method returns defaultValue instead of throwing an exception if the value could not be retrieved from the dataset (e.g. when it does not exist).

◆ setValue()

template<typename T>
void setValue ( T value)

Sets the value in the dataset.

Overrides existing values or creates new element in dataset otherwise.

◆ setValidator()

template<typename T>
void setValidator ( std::function< bool(const T &)> isValid)

Assigns an optional callback function to determine if the element's value is valid in the current context.

The default validator (nullptr) always returns true (i.e. element is always valid).

◆ isValid()

template<typename T>
bool isValid ( ) const
overridevirtual

Returns whether the element contains valid data (wrt. to the set validator).

Implements ElementBase.


The documentation for this class was generated from the following files:
Search Tab / S to search, Esc to close