BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
AbstractDataLoader Class Referenceabstract

Base class for all data loaders (classes which can import real data) More...

Inheritance diagram for AbstractDataLoader:
[legend]
Collaboration diagram for AbstractDataLoader:
[legend]

Signals

void contentsProcessed ()
 Emitted whenever contents have been processed. More...
 
void importSettingsChanged ()
 Emitted whenever an import setting changed. More...
 

Public Member Functions

virtual ~AbstractDataLoader ()=default
 
virtual void applyImportSettings ()
 Read all values from the properties UI into the internal variables. More...
 
virtual AbstractDataLoaderclone () const =0
 Create a complete clone, including all internal states. More...
 
virtual AbstractDataLoaderResultModelcreateResultModel () const
 Create a table model which contains the import information like original file content, raw content, processed content The returned pointer will be owned by the caller. More...
 
virtual QByteArray defaultImportSettings () const
 Return the default import settings. More...
 
virtual void deserialize (const QByteArray &data)
 Initialize from serialization data. More...
 
virtual QByteArray fileContent () const
 Returns the original file content. More...
 
virtual void guessSettings ()
 Guess appropriate settings (for example the separator in a CSV file). More...
 
virtual void initWithDefaultImportSettings ()
 Set import settings to defaults. More...
 
virtual QStringList lineUnrelatedErrors () const
 Errors not related to a particular line. More...
 
virtual QString name () const =0
 The name shown in the format selection combo. More...
 
virtual int numErrors () const
 Number of errors found while processing the content. More...
 
virtual int numLineRelatedErrors () const
 Number of errors related to a specific line. More...
 
virtual QString persistentClassName () const =0
 A name which can be used for save/load purposes (which will not change ever more) More...
 
virtual void populateImportSettingsWidget (QWidget *parent)
 Fills the widget on the import dialog pane. More...
 
virtual void processContents ()=0
 Process the file contents. More...
 
RealDataItemrealDataItem ()
 The real data item on which the import shall work. More...
 
const RealDataItemrealDataItem () const
 The real data item on which the import shall work. More...
 
virtual QByteArray serialize () const
 Returns every internal setting so it can be restored completely. More...
 
virtual void setFileContents (const QByteArray &fileContent)=0
 Sets the file contents to be imported. More...
 
void setRealDataItem (RealDataItem *item)
 Define the real data item on which the import shall work. More...
 

Protected Types

enum class  Error { DifferendNumberOfColumns }
 

Protected Attributes

RealDataItemm_item
 

Detailed Description

Base class for all data loaders (classes which can import real data)

Definition at line 30 of file AbstractDataLoader.h.

Member Enumeration Documentation

◆ Error

enum AbstractDataLoader::Error
strongprotected
Enumerator
DifferendNumberOfColumns 

Definition at line 119 of file AbstractDataLoader.h.

119 { DifferendNumberOfColumns };

Constructor & Destructor Documentation

◆ ~AbstractDataLoader()

virtual AbstractDataLoader::~AbstractDataLoader ( )
virtualdefault

Member Function Documentation

◆ applyImportSettings()

void AbstractDataLoader::applyImportSettings ( )
virtual

Read all values from the properties UI into the internal variables.

Reimplemented in QREDataLoader.

Definition at line 20 of file AbstractDataLoader.cpp.

20 {}

Referenced by DataLoaders1D::cloneAsUserDefinedLoader(), and SpecularDataImportWidget::onPropertiesChanged().

◆ clone()

◆ contentsProcessed

void AbstractDataLoader::contentsProcessed ( )
signal

Emitted whenever contents have been processed.

Referenced by AutomaticDataLoader1D::processContents(), QREDataLoader::processContents(), and RealDataItem::setDataLoader().

◆ createResultModel()

AbstractDataLoaderResultModel * AbstractDataLoader::createResultModel ( ) const
virtual

Create a table model which contains the import information like original file content, raw content, processed content The returned pointer will be owned by the caller.

This base class' implementation does nothing (return nullptr).

Reimplemented in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 55 of file AbstractDataLoader.cpp.

56 {
57  return nullptr;
58 }

Referenced by SpecularDataImportWidget::updatePreview().

◆ defaultImportSettings()

QByteArray AbstractDataLoader::defaultImportSettings ( ) const
virtual

Return the default import settings.

Definition at line 31 of file AbstractDataLoader.cpp.

32 {
33  std::unique_ptr<AbstractDataLoader> cloned(clone());
34  cloned->initWithDefaultImportSettings();
35  return cloned->serialize();
36 }
virtual AbstractDataLoader * clone() const =0
Create a complete clone, including all internal states.

References clone().

Here is the call graph for this function:

◆ deserialize()

void AbstractDataLoader::deserialize ( const QByteArray &  data)
virtual

Initialize from serialization data.

If any error occurred, then a DeserializationException has to be thrown. The complete state has to be restored. Therefore if e.g. errors occurred in the former serialization, but errors are not serialized, then they have to be regenerated/recalculated in here.

Reimplemented in UserDefinedDataLoader1D, QREDataLoader, and AutomaticDataLoader1D.

Definition at line 29 of file AbstractDataLoader.cpp.

29 {}

Referenced by UserDefinedDataLoader1D::deserialize(), and operator>>().

◆ fileContent()

QByteArray AbstractDataLoader::fileContent ( ) const
virtual

Returns the original file content.

If not available any more (like for legacy project file import), then an empty array will be returned.

Reimplemented in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 60 of file AbstractDataLoader.cpp.

61 {
62  return {};
63 }

Referenced by SpecularDataImportWidget::onFormatSelectionChanged(), and UserDefinedDataLoader1D::setFileContents().

◆ guessSettings()

void AbstractDataLoader::guessSettings ( )
virtual

Guess appropriate settings (for example the separator in a CSV file).

Is called only once, directly after setting the file content.

Reimplemented in UserDefinedDataLoader1D, and QREDataLoader.

Definition at line 38 of file AbstractDataLoader.cpp.

38 {}

Referenced by UserDefinedDataLoader1D::guessSettings(), ImportDataUtils::Import1dData(), and SpecularDataImportWidget::onFormatSelectionChanged().

◆ importSettingsChanged

void AbstractDataLoader::importSettingsChanged ( )
signal

◆ initWithDefaultImportSettings()

void AbstractDataLoader::initWithDefaultImportSettings ( )
virtual

Set import settings to defaults.

Reimplemented in UserDefinedDataLoader1D, and QREDataLoader.

Definition at line 22 of file AbstractDataLoader.cpp.

22 {}

Referenced by ImportDataUtils::Import1dData(), and SpecularDataImportWidget::onFormatSelectionChanged().

◆ lineUnrelatedErrors()

QStringList AbstractDataLoader::lineUnrelatedErrors ( ) const
virtual

Errors not related to a particular line.

Reimplemented in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 50 of file AbstractDataLoader.cpp.

51 {
52  return {};
53 }

Referenced by SpecularDataImportWidget::updatePreview().

◆ name()

virtual QString AbstractDataLoader::name ( ) const
pure virtual

◆ numErrors()

int AbstractDataLoader::numErrors ( ) const
virtual

Number of errors found while processing the content.

An error means that either a particular content (line) can't be used or may be suspicious (line related error), or that the whole content can't be used (e.g. only 1 line present).

Reimplemented in QREDataLoader, and AutomaticDataLoader1D.

Definition at line 40 of file AbstractDataLoader.cpp.

41 {
42  return 0;
43 }

Referenced by RealDataItem::hasImportErrors(), and SpecularDataImportWidget::updatePreview().

◆ numLineRelatedErrors()

int AbstractDataLoader::numLineRelatedErrors ( ) const
virtual

Number of errors related to a specific line.

Such an error means that a particular content (line) can't be used or may be suspicious.

Reimplemented in QREDataLoader.

Definition at line 45 of file AbstractDataLoader.cpp.

46 {
47  return 0;
48 }

◆ persistentClassName()

virtual QString AbstractDataLoader::persistentClassName ( ) const
pure virtual

A name which can be used for save/load purposes (which will not change ever more)

Implemented in UserDefinedDataLoader1D, QREDataLoader, and AutomaticDataLoader1D.

Referenced by UserDefinedDataLoader1D::persistentClassName().

◆ populateImportSettingsWidget()

void AbstractDataLoader::populateImportSettingsWidget ( QWidget *  parent)
virtual

Fills the widget on the import dialog pane.

This base class' implementation does nothing (meaning "no editable properties")

Reimplemented in UserDefinedDataLoader1D, and QREDataLoader.

Definition at line 18 of file AbstractDataLoader.cpp.

18 {}

Referenced by UserDefinedDataLoader1D::populateImportSettingsWidget(), and SpecularDataImportWidget::updatePropertiesEdits().

◆ processContents()

virtual void AbstractDataLoader::processContents ( )
pure virtual

Process the file contents.

Can be called more than once, e.g. if the import settings have changed. Any error has to be stored in the loader (see numErrors()).

Implemented in UserDefinedDataLoader1D, QREDataLoader, and AutomaticDataLoader1D.

Referenced by ImportDataUtils::Import1dData(), SpecularDataImportWidget::onFormatSelectionChanged(), SpecularDataImportWidget::onPropertiesChanged(), and UserDefinedDataLoader1D::processContents().

◆ realDataItem() [1/2]

RealDataItem * AbstractDataLoader::realDataItem ( )

The real data item on which the import shall work.

Definition at line 70 of file AbstractDataLoader.cpp.

71 {
72  return m_item;
73 }

References m_item.

◆ realDataItem() [2/2]

const RealDataItem * AbstractDataLoader::realDataItem ( ) const

The real data item on which the import shall work.

Definition at line 75 of file AbstractDataLoader.cpp.

76 {
77  return m_item;
78 }

References m_item.

◆ serialize()

QByteArray AbstractDataLoader::serialize ( ) const
virtual

Returns every internal setting so it can be restored completely.

Reimplemented in UserDefinedDataLoader1D, QREDataLoader, and AutomaticDataLoader1D.

Definition at line 24 of file AbstractDataLoader.cpp.

25 {
26  return QByteArray();
27 }

Referenced by DataLoaders1D::cloneAsUserDefinedLoader(), operator<<(), and UserDefinedDataLoader1D::serialize().

◆ setFileContents()

virtual void AbstractDataLoader::setFileContents ( const QByteArray &  fileContent)
pure virtual

Sets the file contents to be imported.

If the file was a compressed file, here already the decompressed content will be overhanded.

Implemented in UserDefinedDataLoader1D, QREDataLoader, and AutomaticDataLoader1D.

Referenced by ImportDataUtils::Import1dData(), SpecularDataImportWidget::onFormatSelectionChanged(), and UserDefinedDataLoader1D::setFileContents().

◆ setRealDataItem()

void AbstractDataLoader::setRealDataItem ( RealDataItem item)

Define the real data item on which the import shall work.

Definition at line 65 of file AbstractDataLoader.cpp.

66 {
67  m_item = item;
68 }

References m_item.

Referenced by ImportDataUtils::Import1dData(), and SpecularDataImportWidget::onFormatSelectionChanged().

Member Data Documentation

◆ m_item


The documentation for this class was generated from the following files: