BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
AppSvc.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file GUI/coregui/mainwindow/AppSvc.cpp
6 //! @brief Implements class AppSvc
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 
17 
19 {
20  return instance().this_projectManager();
21 }
22 
23 void AppSvc::subscribe(ProjectManager* projectManager)
24 {
26 }
27 
28 void AppSvc::unsubscribe(ProjectManager* projectManager)
29 {
31 }
32 
34 {
35  return instance().this_materialModel();
36 }
37 
38 void AppSvc::subscribe(MaterialModel* materialModel)
39 {
41 }
42 
43 void AppSvc::unsubscribe(MaterialModel* materialModel)
44 {
46 }
47 
48 AppSvc::AppSvc() : m_projectManager(nullptr), m_materialModel(nullptr) {}
49 
51 {
52  if (!m_projectManager)
53  throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to access "
54  "non existing ProjectManager.");
55 
56  return m_projectManager;
57 }
58 
60 {
61  return m_materialModel;
62 }
63 
65 {
66  if (m_projectManager != nullptr)
67  throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to subscribe "
68  "ProjectManager twice.");
69 
71 }
72 
74 {
76  throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe "
77  "ProjectManager before it was subscribed.");
78 
79  m_projectManager = nullptr;
80 }
81 
83 {
84  if (m_materialModel)
85  throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to subscribe "
86  "MaterialModel twice.");
87 
89 }
90 
92 {
94  throw GUIHelpers::Error("AppSvc::projectManager() -> Error. Attempt to unsubscribe "
95  "MaterialModel before it was subscribed.");
96 
97  m_materialModel = nullptr;
98 }
Defines class AppSvc.
Defines class GUIHelpers functions.
static void unsubscribe(ProjectManager *projectManager)
Definition: AppSvc.cpp:28
void this_unsubscribe(ProjectManager *projectManager)
Definition: AppSvc.cpp:73
void this_subscribe(ProjectManager *projectManager)
Definition: AppSvc.cpp:64
AppSvc()
Definition: AppSvc.cpp:48
static ProjectManager * projectManager()
Definition: AppSvc.cpp:18
MaterialModel * this_materialModel()
Definition: AppSvc.cpp:59
MaterialModel * m_materialModel
Definition: AppSvc.h:47
static MaterialModel * materialModel()
Definition: AppSvc.cpp:33
ProjectManager * m_projectManager
Definition: AppSvc.h:46
ProjectManager * this_projectManager()
Definition: AppSvc.cpp:50
static void subscribe(ProjectManager *projectManager)
Definition: AppSvc.cpp:23
static AppSvc & instance()
Definition: ISingleton.h:23
Handles activity related to opening/save projects.