BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
itemmanager.h
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/model/itemmanager.h
6 //! @brief Defines 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 
15 #ifndef BORNAGAIN_MVVM_MODEL_MVVM_MODEL_ITEMMANAGER_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_MODEL_ITEMMANAGER_H
17 
18 #include "mvvm/model/mvvm_types.h"
19 #include "mvvm/model_export.h"
20 #include <memory>
21 
22 namespace ModelView {
23 
24 class SessionItem;
25 class ItemPool;
26 class ItemFactoryInterface;
27 
28 //! Manages item creation/registration for SessionModel.
29 
30 class MVVM_MODEL_EXPORT ItemManager {
31 public:
32  ItemManager();
34 
35  void setItemFactory(std::unique_ptr<ItemFactoryInterface> factory);
36  void setItemPool(std::shared_ptr<ItemPool> pool);
37 
38  std::unique_ptr<SessionItem> createItem(const model_type& modelType = {}) const;
39 
40  std::unique_ptr<SessionItem> createRootItem() const;
41 
42  SessionItem* findItem(const identifier_type& id) const;
43 
44  identifier_type findIdentifier(const SessionItem* item) const;
45 
46  const ItemPool* itemPool() const;
47  ItemPool* itemPool();
48 
49  void registerInPool(SessionItem* item);
50  void unregisterFromPool(SessionItem* item);
51 
52  const ItemFactoryInterface* factory() const;
53 
54  ItemFactoryInterface* factory();
55 
56 private:
57  std::shared_ptr<ItemPool> m_item_pool;
58  std::unique_ptr<ItemFactoryInterface> m_item_factory;
59 };
60 
61 } // namespace ModelView
62 
63 #endif // BORNAGAIN_MVVM_MODEL_MVVM_MODEL_ITEMMANAGER_H
Interface class for all factories capable of producing SessionItem's.
Manages item creation/registration for SessionModel.
Definition: itemmanager.h:30
std::shared_ptr< ItemPool > m_item_pool
Definition: itemmanager.h:57
std::unique_ptr< ItemFactoryInterface > m_item_factory
Definition: itemmanager.h:58
Provides registration of SessionItem pointers and their unique identifiers in global memory pool.
Definition: itempool.h:29
The main object representing an editable/displayable/serializable entity.
Definition: sessionitem.h:38
Defines class CLASS?
materialitems.h Collection of materials to populate MaterialModel.
std::string identifier_type
Definition: types.h:22
std::string model_type
Definition: types.h:23