CTL
0.6.1
Computed Tomography Library
|
The AbstractDataModel class is the base class for basic data models. More...
#include <abstractdatamodel.h>
Public Types | |
enum | { Type = 0 } |
![]() | |
enum | { Type = -1, UserType = 65536 } |
Public Member Functions | |
int | type () const override |
virtual float | valueAt (float position) const =0 |
virtual AbstractDataModel * | clone () const =0 |
virtual QVariant | parameter () const |
virtual void | setParameter (const QVariant ¶meter) |
void | fromVariant (const QVariant &variant) override |
QVariant | toVariant () const override |
bool | isIntegrable () const |
void | setName (const QString &name) |
const QString & | name () const |
![]() | |
virtual | ~SerializationInterface ()=default |
Protected Member Functions | |
AbstractDataModel (const AbstractDataModel &)=default | |
AbstractDataModel (AbstractDataModel &&)=default | |
AbstractDataModel & | operator= (const AbstractDataModel &)=default |
AbstractDataModel & | operator= (AbstractDataModel &&)=default |
![]() | |
SerializationInterface ()=default | |
SerializationInterface (const SerializationInterface &)=default | |
SerializationInterface (SerializationInterface &&)=default | |
SerializationInterface & | operator= (const SerializationInterface &)=default |
SerializationInterface & | operator= (SerializationInterface &&)=default |
Private Attributes | |
QString | _name |
Friends | |
template<class > | |
struct | SerializationHelper::RegisterWithSerializationHelper |
Related Functions | |
(Note that these are not member functions.) | |
DataModelPtr | |
Template alias name for CopyableUniquePtr<ModelType> to a suitable ModelType. | |
AbstractDataModelPtr | |
Alias name for DataModelPtr<AbstractDataModel>. More... | |
std::unique_ptr< ModelType > | makeDataModel (ConstructorArguments &&... arguments) |
using DataModelPtr | CopyableUniquePtr |
Alias name for CopyableUniquePtr<ModelType> to a suitable ModelType. | |
The AbstractDataModel class is the base class for basic data models.
Sub-classes must implement the method to sample a value at a given position (valueAt()).
Parameters can be set by passing a QVariant that contains all necessary information. Re-implement the setParameter() method to parse the QVariant into your required format within sub-classes of AbstractDataModel.
To enable de-/serialization of sub-class objects, also reimplement the parameter() method such that it stores all parameters of the model in a QVariant. Additionally, call the macro DECLARE_SERIALIZABLE_TYPE(YourNewClassName) within the .cpp file of your new class (substitute "YourNewClassName" with the actual class name). Objects of the new class can then be de-/serialized with any of the serializer classes (see also AbstractSerializer).
Alternatively, the de-/serialization interface methods toVariant() and fromVariant() can be reimplemented directly. This might be required in some specific situations (usually when polymorphic class members are in use). For the majority of cases, using the parameter() / setParameter() approach should be sufficient and is recommended.
|
pure virtual |
Creates a copy of this instance and returns a base class pointer to the new object.
Implemented in CTL::TASMIPSpectrumModel, CTL::HeuristicCubicSpectrumModel, CTL::KramersLawSpectrumModel, CTL::FixedXraySpectrumModel, CTL::GaussianModel1D, CTL::IdentityModel, CTL::RectFunctionModel, CTL::XrayLaserSpectrumModel, CTL::ConstantModel, CTL::IntegrableDataModelSub, CTL::IntegrableDataModelAdd, CTL::AbstractIntegrableDataModel, CTL::StepFunctionModel, CTL::DataModelCat, CTL::XraySpectrumTabulatedModel, CTL::DataModelDiv, CTL::SaturatedSplineModel, CTL::DataModelMul, CTL::DataModelSub, CTL::TabulatedDataModel, CTL::DataModelAdd, CTL::AbstractXraySpectrumModel, CTL::SaturatedLinearModel, and CTL::NumericalIntegrationDecorator.
|
overridevirtual |
Decodes all information required to describe this instance from variant. Required to provide de-/serialization functionality.
Reimplemented from CTL::SerializationInterface.
bool CTL::AbstractDataModel::isIntegrable | ( | ) | const |
Convenience function that returns true
if a dynamic_cast
to AbstractIntegrableDataModel
is successful and false
otherwise.
Returns true if this instance allows integration of data (i.e. it provides the binIntegral() method).
Same as dynamic_cast<const AbstractIntegrableDataModel*>(this).
const QString & CTL::AbstractDataModel::name | ( | ) | const |
Returns the name of this model.
|
virtual |
Returns the parameters of this instance as a QVariant.
Re-implement this method within your sub-class such that it encapsulates all necessary information into a QVariant.
Best practice is to invoke the base class version of this method to take care of all content originating from underlying base classes.
A typical reimplementation in sub-classes might look like this:
Reimplemented in CTL::FixedXraySpectrumModel, CTL::GaussianModel1D, CTL::RectFunctionModel, CTL::ConstantModel, CTL::StepFunctionModel, CTL::AbstractIntegrableDataModelOperation, CTL::XraySpectrumTabulatedModel, CTL::SaturatedSplineModel, CTL::TabulatedDataModel, CTL::SaturatedLinearModel, CTL::AbstractXraySpectrumModel, CTL::NumericalIntegrationDecorator, and CTL::AbstractDataModelOperation.
void CTL::AbstractDataModel::setName | ( | const QString & | name | ) |
Sets the name of this model to name.
|
virtual |
Passes parameter to this instance.
Encapsulate all necessary information into the passed QVariant and re-implement this method within your sub-class to parse it into your required format.
Best practice is to invoke the base class version of this method to take care of all content originating from underlying base classes.
A typical reimplementation in sub-classes might look like this:
Reimplemented in CTL::TASMIPSpectrumModel, CTL::FixedXraySpectrumModel, CTL::GaussianModel1D, CTL::RectFunctionModel, CTL::ConstantModel, CTL::StepFunctionModel, CTL::AbstractIntegrableDataModelOperation, CTL::XraySpectrumTabulatedModel, CTL::SaturatedSplineModel, CTL::TabulatedDataModel, CTL::SaturatedLinearModel, CTL::NumericalIntegrationDecorator, CTL::AbstractXraySpectrumModel, and CTL::AbstractDataModelOperation.
|
overridevirtual |
Encodes all information required to describe this instance into a QVariant.
Required to provide de-/serialization functionality.
Reimplemented from CTL::SerializationInterface.
Reimplemented in CTL::GaussianModel1D.
|
inlineoverridevirtual |
Returns the type id of this instance.
Reimplemented from CTL::SerializationInterface.
Reimplemented in CTL::TASMIPSpectrumModel, CTL::HeuristicCubicSpectrumModel, CTL::KramersLawSpectrumModel, CTL::FixedXraySpectrumModel, CTL::GaussianModel1D, CTL::IdentityModel, CTL::RectFunctionModel, CTL::ConstantModel, CTL::XrayLaserSpectrumModel, CTL::IntegrableDataModelSub, CTL::IntegrableDataModelAdd, CTL::StepFunctionModel, CTL::DataModelCat, CTL::XraySpectrumTabulatedModel, CTL::DataModelDiv, CTL::SaturatedSplineModel, CTL::DataModelMul, CTL::DataModelSub, CTL::TabulatedDataModel, CTL::DataModelAdd, CTL::SaturatedLinearModel, and CTL::NumericalIntegrationDecorator.
|
pure virtual |
Returns the value sampled from the model at the given position.
Implemented in CTL::HeuristicCubicSpectrumModel, CTL::KramersLawSpectrumModel, CTL::FixedXraySpectrumModel, CTL::GaussianModel1D, CTL::IdentityModel, CTL::RectFunctionModel, CTL::XrayLaserSpectrumModel, CTL::ConstantModel, CTL::IntegrableDataModelSub, CTL::IntegrableDataModelAdd, CTL::StepFunctionModel, CTL::DataModelCat, CTL::XraySpectrumTabulatedModel, CTL::DataModelDiv, CTL::SaturatedSplineModel, CTL::DataModelMul, CTL::DataModelSub, CTL::TabulatedDataModel, CTL::DataModelAdd, CTL::SaturatedLinearModel, and CTL::NumericalIntegrationDecorator.
|
related |
Alias name for DataModelPtr<AbstractDataModel>.
It provide unique_ptr
like behavior for subclasses of AbstractDataModel with option to copy by means of deep copying (provided by clone()).
|
related |
Global (free) make function that creates a new AbstractDataModel from the constructor arguments. The component is returned as a std::unique_ptr<ModelType>
, whereas ModelType
is the template argument of this function that needs to be specified.