BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
itempool.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/itempool.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_ITEMPOOL_H
16 #define BORNAGAIN_MVVM_MODEL_MVVM_MODEL_ITEMPOOL_H
17 
18 #include "mvvm/model/mvvm_types.h"
19 #include "mvvm/model_export.h"
20 #include <map>
21 
22 namespace ModelView {
23 
24 class SessionItem;
25 
26 //! Provides registration of SessionItem pointers and their unique identifiers
27 //! in global memory pool.
28 
29 class MVVM_MODEL_EXPORT ItemPool {
30 public:
31  ItemPool() = default;
32  ItemPool(const ItemPool&) = delete;
33  ItemPool(ItemPool&&) = delete;
34  ItemPool& operator=(const ItemPool&) = delete;
35  ItemPool& operator=(ItemPool&&) = delete;
36 
37  size_t size() const;
38 
39  identifier_type register_item(SessionItem* item, identifier_type key = {});
40  void unregister_item(SessionItem* item);
41 
42  identifier_type key_for_item(const SessionItem* item) const;
43 
44  SessionItem* item_for_key(const identifier_type& key) const;
45 
46 private:
47  std::map<identifier_type, SessionItem*> m_key_to_item;
48  std::map<const SessionItem*, identifier_type> m_item_to_key;
49 };
50 
51 } // namespace ModelView
52 
53 #endif // BORNAGAIN_MVVM_MODEL_MVVM_MODEL_ITEMPOOL_H
Provides registration of SessionItem pointers and their unique identifiers in global memory pool.
Definition: itempool.h:29
ItemPool(ItemPool &&)=delete
ItemPool & operator=(ItemPool &&)=delete
ItemPool & operator=(const ItemPool &)=delete
ItemPool(const ItemPool &)=delete
std::map< const SessionItem *, identifier_type > m_item_to_key
Definition: itempool.h:48
std::map< identifier_type, SessionItem * > m_key_to_item
Definition: itempool.h:47
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