NorMIT-nav  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_ */
cx::logicManager
LogicManager * logicManager()
Definition: cxLogicManager.cpp:46
cx::VideoServicePtr
boost::shared_ptr< class VideoService > VideoServicePtr
Definition: cxLogicManager.h:26
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::FileManagerServicePtr
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
Definition: cxLogicManager.h:31
cx::LogicManager
Control the custusx backend.
Definition: cxLogicManager.h:60
cx::SessionStorageServicePtr
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
Definition: cxLogicManager.h:30
cx::ApplicationComponent::~ApplicationComponent
virtual ~ApplicationComponent()
Definition: cxLogicManager.h:48
cx::ApplicationComponent
Definition: cxLogicManager.h:45
cx::TrackingServicePtr
boost::shared_ptr< class TrackingService > TrackingServicePtr
Definition: cxToolFilterWidget.h:27
cx::ApplicationComponent::exists
virtual bool exists() const =0
cx::AcquisitionServicePtr
boost::shared_ptr< class AcquisitionService > AcquisitionServicePtr
Definition: cxLogicManager.h:29
cx::PatientModelServicePtr
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
Definition: cxLogicManager.h:25
cx::ViewServicePtr
boost::shared_ptr< class ViewService > ViewServicePtr
Definition: cxLogicManager.h:28
cx::ApplicationComponentPtr
boost::shared_ptr< class ApplicationComponent > ApplicationComponentPtr
Definition: cxLogicManager.h:41
cx::ApplicationComponent::destroy
virtual void destroy()=0
cx::ApplicationComponent::create
virtual void create()=0
cx::PluginFrameworkManagerPtr
boost::shared_ptr< class PluginFrameworkManager > PluginFrameworkManagerPtr
Definition: cxLogicManager.h:39
cx::SpaceProviderPtr
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
Definition: cxLogicManager.h:23
cx::StateServicePtr
boost::shared_ptr< class StateService > StateServicePtr
Definition: cxLogicManager.h:27