Fraxinus  17.12-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) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 #ifndef CXLOGICMANAGER_H_
33 #define CXLOGICMANAGER_H_
34 
35 #include "cxLogicManagerExport.h"
36 
37 #include <boost/shared_ptr.hpp>
38 #include <QObject>
39 
40 class ctkPluginContext;
41 
42 namespace cx
43 {
44 typedef boost::shared_ptr<class SpaceProvider> SpaceProviderPtr;
45 typedef boost::shared_ptr<class TrackingService> TrackingServicePtr;
46 typedef boost::shared_ptr<class PatientModelService> PatientModelServicePtr;
47 typedef boost::shared_ptr<class VideoService> VideoServicePtr;
48 typedef boost::shared_ptr<class StateService> StateServicePtr;
49 typedef boost::shared_ptr<class ViewService> ViewServicePtr;
50 typedef boost::shared_ptr<class AcquisitionService> AcquisitionServicePtr;
51 typedef boost::shared_ptr<class SessionStorageService> SessionStorageServicePtr;
52 
59 typedef boost::shared_ptr<class PluginFrameworkManager> PluginFrameworkManagerPtr;
60 
61 typedef boost::shared_ptr<class ApplicationComponent> ApplicationComponentPtr;
66 {
67 public:
68  virtual ~ApplicationComponent() {}
69 
70  virtual void create() = 0;
71  virtual bool exists() const = 0;
72  virtual void destroy() = 0;
73 };
74 
80 class cxLogicManager_EXPORT LogicManager : public QObject
81 {
82  Q_OBJECT
83 public:
84  static LogicManager* getInstance();
85 
96  static void initializeBasic();
97 
101  static void initialize(ApplicationComponentPtr component=ApplicationComponentPtr());
105  static void shutdown();
106 
113  void setApplicationComponent(ApplicationComponentPtr component);
114 
121  void restartWithNewProfile(QString uid);
122 
123  void restartServicesWithProfile(QString uid);
124 
125  PluginFrameworkManagerPtr getPluginFramework();
126  ctkPluginContext* getPluginContext();
127 
128  TrackingServicePtr getTrackingService();
129  SpaceProviderPtr getSpaceProvider();
130  PatientModelServicePtr getPatientModelService();
131  VideoServicePtr getVideoService();
132  StateServicePtr getStateService();
133  ViewServicePtr getViewService();
134  SessionStorageServicePtr getSessionStorageService();
135 
136 private slots:
137  void onRestartWithNewProfile(QString uid);
138 
139 private:
143  void initializeServices();
150  void shutdownServices();
151 
152  void basicSetup();
153  void createLegacyStoredServices();
154  void shutdownLegacyStoredServices();
155 
156  template<class T>
157  void shutdownService(boost::shared_ptr<T>& service, QString name);
158 
159  static LogicManager* mInstance;
160  static void setInstance(LogicManager* instance);
161 
162  LogicManager();
163  virtual ~LogicManager();
164 
165  LogicManager(LogicManager const&); // not implemented
166  LogicManager& operator=(LogicManager const&); // not implemented
167 
168 // services:
169  SpaceProviderPtr mSpaceProvider;
170  PatientModelServicePtr mPatientModelService;
171  TrackingServicePtr mTrackingService;
172  VideoServicePtr mVideoService;
173  StateServicePtr mStateService;
174  ViewServicePtr mViewService;
175  SessionStorageServicePtr mSessionStorageService;
176 
177  PluginFrameworkManagerPtr mPluginFramework;
178  ApplicationComponentPtr mComponent;
179 };
180 
181 cxLogicManager_EXPORT LogicManager* logicManager(); // access the singleton
182 
186 }
187 
188 #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.