CustusX  18.04-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 
38 typedef boost::shared_ptr<class PluginFrameworkManager> PluginFrameworkManagerPtr;
39 
40 typedef boost::shared_ptr<class ApplicationComponent> ApplicationComponentPtr;
45 {
46 public:
47  virtual ~ApplicationComponent() {}
48 
49  virtual void create() = 0;
50  virtual bool exists() const = 0;
51  virtual void destroy() = 0;
52 };
53 
59 class cxLogicManager_EXPORT LogicManager : public QObject
60 {
61  Q_OBJECT
62 public:
63  static LogicManager* getInstance();
64 
75  static void initializeBasic();
76 
80  static void initialize(ApplicationComponentPtr component=ApplicationComponentPtr());
84  static void shutdown();
85 
92  void setApplicationComponent(ApplicationComponentPtr component);
93 
100  void restartWithNewProfile(QString uid);
101 
102  void restartServicesWithProfile(QString uid);
103 
104  PluginFrameworkManagerPtr getPluginFramework();
105  ctkPluginContext* getPluginContext();
106 
107  TrackingServicePtr getTrackingService();
108  SpaceProviderPtr getSpaceProvider();
109  PatientModelServicePtr getPatientModelService();
110  VideoServicePtr getVideoService();
111  StateServicePtr getStateService();
112  ViewServicePtr getViewService();
113  SessionStorageServicePtr getSessionStorageService();
114 
115 private slots:
116  void onRestartWithNewProfile(QString uid);
117 
118 private:
122  void initializeServices();
129  void shutdownServices();
130 
131  void basicSetup();
132  void createLegacyStoredServices();
133  void shutdownLegacyStoredServices();
134 
135  template<class T>
136  void shutdownService(boost::shared_ptr<T>& service, QString name);
137 
138  static LogicManager* mInstance;
139  static void setInstance(LogicManager* instance);
140 
141  LogicManager();
142  virtual ~LogicManager();
143 
144  LogicManager(LogicManager const&); // not implemented
145  LogicManager& operator=(LogicManager const&); // not implemented
146 
147 // services:
148  SpaceProviderPtr mSpaceProvider;
149  PatientModelServicePtr mPatientModelService;
150  TrackingServicePtr mTrackingService;
151  VideoServicePtr mVideoService;
152  StateServicePtr mStateService;
153  ViewServicePtr mViewService;
154  SessionStorageServicePtr mSessionStorageService;
155 
156  PluginFrameworkManagerPtr mPluginFramework;
157  ApplicationComponentPtr mComponent;
158 };
159 
160 cxLogicManager_EXPORT LogicManager* logicManager(); // access the singleton
161 
165 }
166 
167 #endif /* CXLOGICMANAGER_H_ */
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
virtual void destroy()=0
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.