diff --git a/GUI/View/Loader/ComponentRW.cpp b/GUI/View/Loader/ComponentRW.cpp index f5db8e1027f3e40f302502c27cc70bb9c6ccfaea..58e616bc49570ec9d7a8ca5fe2c14736c18a88dd 100644 --- a/GUI/View/Loader/ComponentRW.cpp +++ b/GUI/View/Loader/ComponentRW.cpp @@ -21,37 +21,37 @@ namespace { -template <class T> void save(const QString& fname, const T* t); -template <class T> T* load(const QString& fname); +template <class T> void saveToXML(const QString& fname, const T* t); +template <class T> T* loadFromXML(const QString& fname); -template <> void save<InstrumentItem>(const QString& fname, const InstrumentItem* t) +template <> void saveToXML<InstrumentItem>(const QString& fname, const InstrumentItem* t) { InstrumentXML::save(fname, t); } -template <> InstrumentItem* load<InstrumentItem>(const QString& fname) +template <> InstrumentItem* loadFromXML<InstrumentItem>(const QString& fname) { return InstrumentXML::load(fname); } -} // namespace +// Force instantiation by assigning the function to a global variable that will never be used: +auto dummy_saveXML_InstrumentItem = &RW::saveComponentToXML<class InstrumentItem>; +auto dummy_loadXML_InstrumentItem = &RW::loadComponentFromXML<class InstrumentItem>; +} // namespace -// Force instantiation by assigning the function to a global variable that will never be used: -auto dummy_saveComponent_InstrumentItem = &RW::saveComponent<class InstrumentItem>; -auto dummy_loadComponent_InstrumentItem = &RW::loadComponent<class InstrumentItem>; -template <class T> void RW::saveComponent(const QString& type, const T* t) +template <class T> void RW::saveComponentToXML(const QString& type, const T* t) { if (!t) return; QString fname = GUI::Dialog::fileSaveDialog("Save " + type, appSettings->xml_dir, - "XML Files (*.xml)", t->name() + ".xml"); + "XML files (*.xml)", t->name() + ".xml"); if (fname.isEmpty()) return; try { - ::save<T>(fname, t); + ::saveToXML<T>(fname, t); } catch (const std::exception& ex) { QMessageBox(QMessageBox::Warning, "BornAgain: failed saving", ex.what(), QMessageBox::Ok, nullptr) @@ -59,15 +59,15 @@ template <class T> void RW::saveComponent(const QString& type, const T* t) } } -template <class T> T* RW::loadComponent(const QString& type) +template <class T> T* RW::loadComponentFromXML(const QString& type) { QString fname = - GUI::Dialog::fileOpenDialog("Load " + type, appSettings->xml_dir, "XML Files (*.xml)"); + GUI::Dialog::fileOpenDialog("Load " + type, appSettings->xml_dir, "XML files (*.xml)"); if (fname.isEmpty()) return nullptr; try { - return ::load<T>(fname); + return ::loadFromXML<T>(fname); } catch (const std::exception& ex) { QMessageBox(QMessageBox::Warning, "BornAgain: failed loading", ex.what(), QMessageBox::Ok, nullptr) diff --git a/GUI/View/Loader/ComponentRW.h b/GUI/View/Loader/ComponentRW.h index a191249df7160e45a1e6b4d51e13f9d585716db6..e15a166c333f4539286f41ae413902534270507b 100644 --- a/GUI/View/Loader/ComponentRW.h +++ b/GUI/View/Loader/ComponentRW.h @@ -19,8 +19,8 @@ namespace RW { -template <class T> void saveComponent(const QString& type, const T* t); -template <class T> T* loadComponent(const QString& type); +template <class T> void saveComponentToXML(const QString& type, const T* t); +template <class T> T* loadComponentFromXML(const QString& type); } // namespace RW diff --git a/GUI/View/Views/InstrumentView.cpp b/GUI/View/Views/InstrumentView.cpp index 1d2d61ba8763135e231e9ec063f704143a0a458a..0ea19abff94fd5ae1bd1f868f806be317fab150c 100644 --- a/GUI/View/Views/InstrumentView.cpp +++ b/GUI/View/Views/InstrumentView.cpp @@ -96,10 +96,10 @@ InstrumentView::InstrumentView() &InstrumentView::createWidgetsForCurrentInstrument); connect(gActions->store_in_library_instrument, &QAction::triggered, - [] { RW::saveComponent("instrument", gDoc->instruments()->currentItem()); }); + [] { RW::saveComponentToXML("instrument", gDoc->instruments()->currentItem()); }); connect(gActions->load_from_library_instrument, &QAction::triggered, [this] { - m_qlistmodel->pushInstrument(RW::loadComponent<InstrumentItem>("instrument")); + m_qlistmodel->pushInstrument(RW::loadComponentFromXML<InstrumentItem>("instrument")); }); updateActions();