BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
DataLoaders1D.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/Support/IO/DataLoaders1D.h
6 //! @brief Defines 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 
15 #ifndef BORNAGAIN_GUI_SUPPORT_IO_DATALOADERS1D_H
16 #define BORNAGAIN_GUI_SUPPORT_IO_DATALOADERS1D_H
17 
18 #include <QVector>
19 
20 #include <functional>
21 #include <map>
22 
24 
25 //! Collection of all available data loaders for 1D files
26 
28 public:
30 
31  //! The one and only instance
32  static DataLoaders1D& instance();
33 
34  //! Register a built-in loader with the given class name and factory function
35  void addBuiltInLoader(const QString& persistentClassName,
36  const std::function<AbstractDataLoader1D*()>& create);
37 
38  //! add a user defined loader
40 
41  //! all defined loaders. A null element in the list defines a separator
42  //! The returned pointers are the same over the lifetime of the DataLoaders instance, therefore
43  //! they can be used for comparison.
44  QVector<AbstractDataLoader1D*> loaders() const;
45 
46  //! The last 10 recently used loaders.
47  QVector<AbstractDataLoader1D*> recentlyUsedLoaders() const;
48 
49  //! Notify loader was recently used
50  // void setRecentlyUsedLoader(const AbstractDataLoader1D* loader);
51 
52  //! Create loader from the given persistent name
53  AbstractDataLoader1D* createFromPersistentName(const QString& persistentClassName);
54 
55 private:
56  DataLoaders1D() = default;
57 
58  //! create all default built in loaders
60 
61 private:
62  QVector<AbstractDataLoader1D*> m_builtInLoaders;
63  QVector<AbstractDataLoader1D*> m_recentlyUsedLoaders;
64  QVector<AbstractDataLoader1D*> m_userDefinedLoaders;
65  std::map<QString, std::function<AbstractDataLoader1D*()>> m_createLoaders;
66 };
67 
68 #endif // BORNAGAIN_GUI_SUPPORT_IO_DATALOADERS1D_H
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.
void initBuiltInLoaders()
create all default built in 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
DataLoaders1D()=default