BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
itemconverterfactory.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/factories/itemconverterfactory.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 
18 
19 namespace ModelView {
20 
21 //! Creates JSON item converter intended for item cloning.
22 //! Saves full deep copy of item to JSON. When restoring from JSON, reconstruct everything,
23 //! including item's unique ID. Used for backup.
24 
25 std::unique_ptr<JsonItemConverterInterface>
27 {
28  ConverterContext context{item_factory, ConverterMode::clone};
29  return std::make_unique<JsonItemConverter>(context);
30 }
31 
32 //! Creates JSON item converter intended for item copying.
33 //! Saves full deep copy of item to JSON. When restoring from JSON, will regenerate item's ID
34 //! to make it unique. Used for copying of item together with its children.
35 
36 std::unique_ptr<JsonItemConverterInterface>
38 {
39  ConverterContext context{item_factory, ConverterMode::copy};
40  return std::make_unique<JsonItemConverter>(context);
41 }
42 
43 //! Creates JSON item converter intended for saving on disk.
44 //! When saving on disk:
45 //! + Only selected data roles of items are saved (i.e. DATA, IDENTIFIER)
46 //! + All tags with its content are saved as usual
47 //! When loading from disk:
48 //! + Only selected roles are taken from JSON (i.e. DATA, IDENTIFIER), other roles (e.g. TOOLTIPS)
49 //! are taken from memory.
50 //! + Property tags are updated, universal tags reconstructed.
51 
52 std::unique_ptr<JsonItemConverterInterface>
54 {
55  ConverterContext context{item_factory, ConverterMode::project};
56  return std::make_unique<JsonItemConverter>(context);
57 }
58 
59 } // namespace ModelView
Interface class for all factories capable of producing SessionItem's.
Defines class CLASS?
Defines class CLASS?
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
std::unique_ptr< JsonItemConverterInterface > CreateItemProjectConverter(const ItemFactoryInterface *item_factory)
Creates JSON item converter intended for saving on disk.
std::unique_ptr< JsonItemConverterInterface > CreateItemCopyConverter(const ItemFactoryInterface *item_factory)
Creates JSON item converter intended for item copying.
@ copy
full deep copying with item identifiers regenerated
@ project
selective copying for saving/loading the project (tags and data created by item, updated from JSON)
@ clone
full deep copying with item identifiers preserved
std::unique_ptr< JsonItemConverterInterface > CreateItemCloneConverter(const ItemFactoryInterface *item_factory)
Creates JSON item converter intended for item cloning.
Collection of input paramters for SessionItemConverter.