BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DataLoaders1D.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/IO/DataLoaders1D.cpp
6 //! @brief Implements class DataLoaders1D
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 
17 
19 {
20  qDeleteAll(m_builtInLoaders);
21  qDeleteAll(m_userDefinedLoaders);
22 }
23 
25 {
26  static DataLoaders1D inst;
27 
28  return inst;
29 }
30 
32  const std::function<AbstractDataLoader1D*()>& create)
33 {
34  m_createLoaders.emplace(name, create);
35  m_builtInLoaders.push_back(create());
36 }
37 
39 {
40  m_userDefinedLoaders.push_back(loader);
41 }
42 
43 QVector<AbstractDataLoader1D*> DataLoaders1D::loaders() const
44 {
46 }
47 
48 QVector<AbstractDataLoader1D*> DataLoaders1D::recentlyUsedLoaders() const
49 {
50  return m_recentlyUsedLoaders;
51 }
52 
54 {
55  auto it = m_createLoaders.find(persistentClassName);
56 
57  if (it != m_createLoaders.end())
58  return it->second();
59  return nullptr;
60 }
Defines class AbstractDataLoader1D.
Defines class DataLoaders1D.
Abstract base class for reflectometry data loaders.
Collection of all available data loaders for 1D files.
Definition: DataLoaders1D.h:27
QVector< AbstractDataLoader1D * > m_userDefinedLoaders
Definition: DataLoaders1D.h:64
QVector< AbstractDataLoader1D * > m_builtInLoaders
Definition: DataLoaders1D.h:62
void addBuiltInLoader(const QString &persistentClassName, const std::function< AbstractDataLoader1D *()> &create)
Register a built-in loader with the given class name and factory function.
void addUserDefinedLoader(AbstractDataLoader1D *loader)
add a user defined loader
QVector< AbstractDataLoader1D * > recentlyUsedLoaders() const
The last 10 recently used loaders.
std::map< QString, std::function< AbstractDataLoader1D *()> > m_createLoaders
Definition: DataLoaders1D.h:65
static DataLoaders1D & instance()
The one and only instance.
QVector< AbstractDataLoader1D * > loaders() const
all defined loaders. A null element in the list defines a separator The returned pointers are the sam...
AbstractDataLoader1D * createFromPersistentName(const QString &persistentClassName)
Notify loader was recently used.
QVector< AbstractDataLoader1D * > m_recentlyUsedLoaders
Definition: DataLoaders1D.h:63
QString const & name(EShape k)
Definition: particles.cpp:20