diff --git a/GUI/DataLoaders/DataLoaderUtil.cpp b/GUI/DataLoaders/DataLoaderUtil.cpp index e789528c245de6c06998bcce49c808f82bf7741a..b95d5e4381e09bd4c1e07f94bbe49d89d6fa9419 100644 --- a/GUI/DataLoaders/DataLoaderUtil.cpp +++ b/GUI/DataLoaders/DataLoaderUtil.cpp @@ -13,6 +13,8 @@ // ************************************************************************************************ #include "GUI/DataLoaders/DataLoaderUtil.h" +#include "GUI/DataLoaders/AutomaticDataLoader1D.h" +#include "GUI/DataLoaders/QREDataLoader.h" #include "GUI/DataLoaders/UserDefinedDataLoader1D.h" #include "GUI/Models/DataLoaders1D.h" @@ -26,3 +28,29 @@ void cloneAsUserDefinedLoader(AbstractDataLoader1D* loader, const QString& name) (new UserDefinedDataLoader1D(clonedLoader, name, defaultProperties)); } + +namespace { + +//! simple factory method for a QREDataLoader +QREDataLoader* createQREDataLoader() { + return new QREDataLoader(); +} + +//! simple factory method for a AutomaticDataLoader1D +AutomaticDataLoader1D* createAutomaticDataLoader1D() { + return new AutomaticDataLoader1D(); +} + +} + +//! register the concrete data loaders with the registration facility +void register1DDataLoaders() { + // the ordering in here defines the ordering in the selection combo box in the open file dialog + // and also in the selection combo box on the format configuration page. Furthermore the first + // returned loader will be used as default in the open file dialog if it is started for the + // first time + DataLoaders1D::instance().addBuiltInLoader + (QREDataLoader().persistentClassName(), createQREDataLoader); + DataLoaders1D::instance().addBuiltInLoader + (AutomaticDataLoader1D().persistentClassName(), createAutomaticDataLoader1D); +} diff --git a/GUI/DataLoaders/DataLoaderUtil.h b/GUI/DataLoaders/DataLoaderUtil.h index efca2554d6dae0194ef4b6fcf1708c05113cdeb7..dd075533c6843f8f624455fefddce96c29cfae2d 100644 --- a/GUI/DataLoaders/DataLoaderUtil.h +++ b/GUI/DataLoaders/DataLoaderUtil.h @@ -21,4 +21,7 @@ class QString; //! clones the loader as a user defined loader and puts it in DataLoaders1D store void cloneAsUserDefinedLoader(AbstractDataLoader1D* loader, const QString& name); +//! register the concrete 1D data loaders with DataLoaders1D +void register1DDataLoaders(); + #endif // BORNAGAIN_GUI_DATALOADERS_DATALOADERUTIL_H diff --git a/GUI/DataLoaders/DataLoadersRegistration.cpp b/GUI/DataLoaders/DataLoadersRegistration.cpp deleted file mode 100644 index cbd7680906874155ecef77b38ba1cb6e78473c53..0000000000000000000000000000000000000000 --- a/GUI/DataLoaders/DataLoadersRegistration.cpp +++ /dev/null @@ -1,50 +0,0 @@ -// ************************************************************************************************ -// -// BornAgain: simulate and fit reflection and scattering -// -//! @file GUI/DataLoaders/DataLoadersRegistration.cpp -//! @brief Perform the registration of the dataloaders at the corresponding sites -//! -//! @homepage http://www.bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2021 -//! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS) -// -// ************************************************************************************************ - -#include "GUI/Models/DataLoaders1D.h" -#include "GUI/DataLoaders/AutomaticDataLoader1D.h" -#include "GUI/DataLoaders/QREDataLoader.h" - -namespace { - -//! simple factory method for a QREDataLoader -QREDataLoader* createQREDataLoader() -{ - return new QREDataLoader(); -} - -//! simple factory method for a AutomaticDataLoader1D -AutomaticDataLoader1D* createAutomaticDataLoader1D() -{ - return new AutomaticDataLoader1D(); -} - -//! register the concrete data loaders with the registration facility -bool register1DDataLoaders() { - // the ordering in here defines the ordering in the selection combo box in the open file dialog - // and also in the selection combo box on the format configuration page. Furthermore the first - // returned loader will be used as default in the open file dialog if it is started for the - // first time - DataLoaders1D::instance().addBuiltInLoader - (QREDataLoader().persistentClassName(), createQREDataLoader); - DataLoaders1D::instance().addBuiltInLoader - (AutomaticDataLoader1D().persistentClassName(), createAutomaticDataLoader1D); - - return true; -} - -// assigning the return value of register_dataloaders to the local static variable results in -// register_dataloaders being automatically called exactly once during the startup of the program -bool registration = register1DDataLoaders(); -} diff --git a/GUI/main/main.cpp b/GUI/main/main.cpp index 0f2ddbb33005abacdaf8b3b4c17952399413858d..2fc554eea5cdab5c575298e90ff4335f7b10bb28 100644 --- a/GUI/main/main.cpp +++ b/GUI/main/main.cpp @@ -13,6 +13,7 @@ // ************************************************************************************************ #include "GUI/Application/Application.h" +#include "GUI/DataLoaders/DataLoaderUtil.h" #include "GUI/main/MessageHandler.h" #include "GUI/main/appoptions.h" #include "GUI/mainwindow/mainwindow.h" @@ -37,6 +38,8 @@ int main(int argc, char* argv[]) qInstallMessageHandler(MessageHandler); + register1DDataLoaders(); + MainWindow win; if (options.find("geometry")) win.resize(options.mainWindowSize());