BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
jsonitembackupstrategy.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/model/mvvm/serialization/jsonitembackupstrategy.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
17 #include "mvvm/model/sessionitem.h"
18 #include <QJsonObject>
19 
20 using namespace ModelView;
21 
23  std::unique_ptr<JsonItemConverterInterface> m_converter;
24  QJsonObject m_json;
25 };
26 
28  : p_impl(std::make_unique<JsonItemBackupStrategyImpl>())
29 {
30  p_impl->m_converter = CreateItemCloneConverter(item_factory);
31 }
32 
34 
35 std::unique_ptr<SessionItem> JsonItemBackupStrategy::restoreItem() const
36 {
37  return p_impl->m_converter->from_json(p_impl->m_json);
38 }
39 
41 {
42  p_impl->m_json = p_impl->m_converter->to_json(item);
43 }
Interface class for all factories capable of producing SessionItem's.
std::unique_ptr< SessionItem > restoreItem() const override
Restore item from saved content.
JsonItemBackupStrategy(const ItemFactoryInterface *item_factory)
void saveItem(const SessionItem *item) override
Save item's content.
std::unique_ptr< JsonItemBackupStrategyImpl > p_impl
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
Defines class CLASS?
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
std::unique_ptr< JsonItemConverterInterface > CreateItemCloneConverter(const ItemFactoryInterface *item_factory)
Creates JSON item converter intended for item cloning.
Definition: filesystem.h:81
Defines class CLASS?
std::unique_ptr< JsonItemConverterInterface > m_converter