BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
AbstractDataLoader.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/IO/AbstractDataLoader.cpp
6 //! @brief Implements class AbstractDataLoader
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2021
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include <QString>
17 
19 
21 
23 
25 {
26  return QByteArray();
27 }
28 
29 void AbstractDataLoader::deserialize(const QByteArray&) {}
30 
32 {
33  std::unique_ptr<AbstractDataLoader> cloned(clone());
34  cloned->initWithDefaultImportSettings();
35  return cloned->serialize();
36 }
37 
39 
41 {
42  return 0;
43 }
44 
46 {
47  return 0;
48 }
49 
51 {
52  return {};
53 }
54 
56 {
57  return nullptr;
58 }
59 
61 {
62  return {};
63 }
64 
66 {
67  m_item = item;
68 }
69 
71 {
72  return m_item;
73 }
74 
76 {
77  return m_item;
78 }
79 
80 QDataStream& operator<<(QDataStream& stream, const AbstractDataLoader& s)
81 {
82  stream << s.serialize();
83  return stream;
84 }
85 
86 QDataStream& operator>>(QDataStream& stream, AbstractDataLoader& s)
87 {
88  QByteArray b;
89  stream >> b;
90  s.deserialize(b);
91  return stream;
92 }
QDataStream & operator>>(QDataStream &stream, AbstractDataLoader &s)
QDataStream & operator<<(QDataStream &stream, const AbstractDataLoader &s)
Defines class AbstractDataLoader.
Base class for result tables of data loaders. Derive from this class and return an instance in YourDa...
Abstract base class for all data loaders (classes to import real data).
virtual QByteArray serialize() const
Returns every internal setting so it can be restored completely.
virtual void applyImportSettings()
Read all values from the properties UI into the internal variables.
virtual void populateImportSettingsWidget(QWidget *parent)
Fills the widget on the import dialog pane. The implementation here in the base class does nothing (m...
virtual AbstractDataLoaderResultModel * createResultModel() const
Create a table model which contains the import information like original file content,...
virtual void guessSettings()
Guess appropriate settings (for example the separator in a CSV file). Is called only once,...
virtual void deserialize(const QByteArray &data)
Initialize from serialization data. If any error occurred, then a DeserializationException has to be ...
virtual int numErrors() const
Number of errors found while processing the content. An error means that either a particular content ...
virtual void initWithDefaultImportSettings()
Set import settings to defaults.
virtual QByteArray fileContent() const
Returns the original file content. If not available any more (like for legacy project file import),...
virtual QStringList lineUnrelatedErrors() const
Errors not related to a particular line.
virtual AbstractDataLoader * clone() const =0
Create a complete clone, including all internal states.
RealDataItem * m_item
The real-data-item which owns this loader. Never delete this!
RealDataItem * realDataItem()
The real data item on which the import shall work.
virtual QByteArray defaultImportSettings() const
Return the default import settings.
void setRealDataItem(RealDataItem *item)
Define the real data item on which the import shall work.
virtual int numLineRelatedErrors() const
Number of errors related to a specific line. Such an error means that a particular content (line) can...
Provides access to experimental data, for display and fitting. Owns an AbstractDataLoader.
Definition: RealDataItem.h:33