BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ItemFactory.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/Models/ItemFactory.cpp
6 //! @brief Implements class ItemFactory
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
18 
19 namespace {
20 
21 //! Returns the single instance of ItemCatalog.
22 const ItemCatalog& catalog()
23 {
24  static ItemCatalog item_catalog;
25  return item_catalog;
26 }
27 
28 } // namespace
29 
30 SessionItem* ItemFactory::CreateItem(const QString& model_name, SessionItem* parent)
31 {
32  SessionItem* result = catalog().createItemPtr(model_name).release();
33  if (parent)
34  parent->insertItem(-1, result);
35 
36  return result;
37 }
38 
40 {
41  return new SessionItem("ROOT_ITEM");
42 }
43 
45 {
46  return catalog().validTopItemTypes();
47 }
Defines class ItemCatalog.
Defines class ItemFactory.
Defines class SessionItem.
Catalog of SessionItems. A single instance is created and used in ItemFactory.cpp.
Definition: ItemCatalog.h:26
bool insertItem(int row, SessionItem *item, const QString &tag="")
Insert item into given tag into given row.
QStringList ValidTopItemTypes()
retrieve list of all possible item types suitable for
Definition: ItemFactory.cpp:44
SessionItem * CreateEmptyItem()
create empty SessionItem that serves as a root item
Definition: ItemFactory.cpp:39
SessionItem * CreateItem(const QString &model_name, SessionItem *parent=nullptr)
create SessionItem of specific type and parent
Definition: ItemFactory.cpp:30