CustusX  20.03-rc1
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 
93  void setApplicationComponent(ApplicationComponentPtr component);
94 
101  void restartWithNewProfile(QString uid);
102 
103  void restartServicesWithProfile(QString uid);
104 
105  PluginFrameworkManagerPtr getPluginFramework();
106  ctkPluginContext* getPluginContext();
107 
108  TrackingServicePtr getTrackingService();
109  SpaceProviderPtr getSpaceProvider();
110  PatientModelServicePtr getPatientModelService();
111  VideoServicePtr getVideoService();
112  StateServicePtr getStateService();
113  ViewServicePtr getViewService();
114  SessionStorageServicePtr getSessionStorageService();
115  //FileManagerServicePtr getFileManagerService();
116 
117 private slots:
118  void onRestartWithNewProfile(QString uid);
119 
120 private:
124  void initializeServices();
131  void shutdownServices();
132 
133  void basicSetup();
134  void createLegacyStoredServices();
135  void shutdownLegacyStoredServices();
136 
137  template<class T>
138  void shutdownService(boost::shared_ptr<T>& service, QString name);
139 
140  static LogicManager* mInstance;
141  static void setInstance(LogicManager* instance);
142 
143  LogicManager();
144  virtual ~LogicManager();
145 
146  LogicManager(LogicManager const&); // not implemented
147  LogicManager& operator=(LogicManager const&); // not implemented
148 
149 // services:
150  SpaceProviderPtr mSpaceProvider;
151  PatientModelServicePtr mPatientModelService;
152  TrackingServicePtr mTrackingService;
153  VideoServicePtr mVideoService;
154  StateServicePtr mStateService;
155  ViewServicePtr mViewService;
156  SessionStorageServicePtr mSessionStorageService;
157 
158  PluginFrameworkManagerPtr mPluginFramework;
159  ApplicationComponentPtr mComponent;
160 
161  bool mShutdown;
162 };
163 
164 cxLogicManager_EXPORT LogicManager* logicManager(); // access the singleton
165 
169 }
170 
171 #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.