CustusX  2023.01.05-dev+develop.0da12
An IGT application
cxLogicManager.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #ifndef CXLOGICMANAGER_H_
12 #define CXLOGICMANAGER_H_
13 
14 #include "cxLogicManagerExport.h"
15 
16 #include <boost/shared_ptr.hpp>
17 #include <QObject>
18 
19 class ctkPluginContext;
20 
21 namespace cx
22 {
23 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
24 typedef boost::shared_ptr<class TrackingService> TrackingServicePtr;
25 typedef boost::shared_ptr<class PatientModelService> PatientModelServicePtr;
26 typedef boost::shared_ptr<class VideoService> VideoServicePtr;
27 typedef boost::shared_ptr<class StateService> StateServicePtr;
28 typedef boost::shared_ptr<class ViewService> ViewServicePtr;
29 typedef boost::shared_ptr<class AcquisitionService> AcquisitionServicePtr;
30 typedef boost::shared_ptr<class SessionStorageService> SessionStorageServicePtr;
31 typedef boost::shared_ptr<class FileManagerService> FileManagerServicePtr;
32 
39 typedef boost::shared_ptr<class PluginFrameworkManager> PluginFrameworkManagerPtr;
40 
41 typedef boost::shared_ptr<class ApplicationComponent> ApplicationComponentPtr;
46 {
47 public:
48  virtual ~ApplicationComponent() {}
49 
50  virtual void create() = 0;
51  virtual bool exists() const = 0;
52  virtual void destroy() = 0;
53 };
54 
60 class cxLogicManager_EXPORT LogicManager : public QObject
61 {
62  Q_OBJECT
63 public:
64  static LogicManager* getInstance();
65 
76  static void initializeBasic();
77 
81  static void initialize(ApplicationComponentPtr component=ApplicationComponentPtr());
85  static void shutdown();
86 
87 
91  static bool isUbuntu2004();
92 
99  void setApplicationComponent(ApplicationComponentPtr component);
100 
107  void restartWithNewProfile(QString uid);
108 
109  void restartServicesWithProfile(QString uid);
110 
111  PluginFrameworkManagerPtr getPluginFramework();
112  ctkPluginContext* getPluginContext();
113 
114  TrackingServicePtr getTrackingService();
115  SpaceProviderPtr getSpaceProvider();
116  PatientModelServicePtr getPatientModelService();
117  VideoServicePtr getVideoService();
118  StateServicePtr getStateService();
119  ViewServicePtr getViewService();
120  SessionStorageServicePtr getSessionStorageService();
121  //FileManagerServicePtr getFileManagerService();
122 
123 private slots:
124  void onRestartWithNewProfile(QString uid);
125 
126 private:
130  void initializeServices();
137  void shutdownServices();
138  void shutdownServicesLight();
139 
140  void basicSetup();
141  void createLegacyStoredServices();
142  void shutdownLegacyStoredServices();
143 
144  template<class T>
145  void shutdownService(boost::shared_ptr<T>& service, QString name);
146 
147  static LogicManager* mInstance;
148  static void setInstance(LogicManager* instance);
149 
150  LogicManager();
151  virtual ~LogicManager();
152 
153  LogicManager(LogicManager const&); // not implemented
154  LogicManager& operator=(LogicManager const&); // not implemented
155 
156 // services:
157  SpaceProviderPtr mSpaceProvider;
158  PatientModelServicePtr mPatientModelService;
159  TrackingServicePtr mTrackingService;
160  VideoServicePtr mVideoService;
161  StateServicePtr mStateService;
162  ViewServicePtr mViewService;
163  SessionStorageServicePtr mSessionStorageService;
164 
165  PluginFrameworkManagerPtr mPluginFramework;
166  ApplicationComponentPtr mComponent;
167 
168  bool mShutdown;
169 };
170 
171 cxLogicManager_EXPORT LogicManager* logicManager(); // access the singleton
172 
176 }
177 
178 #endif /* CXLOGICMANAGER_H_ */
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
virtual void destroy()=0
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
boost::shared_ptr< class VideoService > VideoServicePtr
boost::shared_ptr< class ApplicationComponent > ApplicationComponentPtr
boost::shared_ptr< class AcquisitionService > AcquisitionServicePtr
boost::shared_ptr< class StateService > StateServicePtr
virtual bool exists() const =0
boost::shared_ptr< class TrackingService > TrackingServicePtr
virtual void create()=0
boost::shared_ptr< class ViewService > ViewServicePtr
Control the custusx backend.
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
LogicManager * logicManager()
boost::shared_ptr< class PluginFrameworkManager > PluginFrameworkManagerPtr
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Namespace for all CustusX production code.