34 #include <QApplication>
35 #include <ctkPluginContext.h>
95 LogicManager* LogicManager::mInstance = NULL;
125 void LogicManager::initializeServices()
127 CX_LOG_INFO() <<
" --- Initialize services for " << qApp->applicationName() <<
"...";
131 mPluginFramework->loadState();
134 mComponent->create();
139 void LogicManager::basicSetup()
145 mPluginFramework->start();
146 mPluginFramework->setSearchPaths(QStringList());
148 this->createLegacyStoredServices();
151 void LogicManager::createLegacyStoredServices()
170 mComponent->destroy();
172 mComponent = component;
175 mComponent->create();
180 QMetaObject::invokeMethod(
this,
"onRestartWithNewProfile",
181 Qt::QueuedConnection,
182 Q_ARG(QString, uid));
185 void LogicManager::onRestartWithNewProfile(QString uid)
189 this->shutdownServices();
191 this->initializeServices();
194 void LogicManager::shutdownServices()
196 CX_LOG_INFO() <<
" --- Shutting down " << qApp->applicationName() <<
"...";
201 mComponent->destroy();
203 mPluginFramework->stop();
205 this->shutdownLegacyStoredServices();
206 mPluginFramework.reset();
214 void LogicManager::shutdownLegacyStoredServices()
216 this->shutdownService(mSpaceProvider,
"SpaceProvider");
217 this->shutdownService(mStateService,
"StateService");
218 this->shutdownService(mViewService,
"ViewService");
219 this->shutdownService(mTrackingService,
"TrackingService");
220 this->shutdownService(mPatientModelService,
"PatientModelService");
221 this->shutdownService(mVideoService,
"VideoService");
222 this->shutdownService(mSessionStorageService,
"SessionStorageService");
227 void LogicManager::shutdownService(boost::shared_ptr<T>& service, QString name)
235 return mPatientModelService;
239 return mTrackingService;
243 return mVideoService;
247 return mStateService;
251 return mSpaceProvider;
259 return mSessionStorageService;
263 return mPluginFramework;
279 LogicManager::LogicManager()
283 LogicManager::~LogicManager()
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
cxResource_EXPORT ProfilePtr profile()
boost::shared_ptr< class VideoService > VideoServicePtr
boost::shared_ptr< class ApplicationComponent > ApplicationComponentPtr
boost::shared_ptr< class StateService > StateServicePtr
ctkPluginContext * getPluginContext()
static void initializeBasic()
boost::shared_ptr< class TrackingService > TrackingServicePtr
TrackingServicePtr getTrackingService()
static void shutdown()
shutdown service, destroy static object if none holds a reference.
static void initialize()
Initialize logging, static object is guaranteed to exist at least until shutdown. ...
cxLogicManager_EXPORT StateServicePtr stateService()
static SessionStorageServicePtr create(ctkPluginContext *pluginContext)
static VideoServicePtr create(ctkPluginContext *pluginContext)
void setActiveProfile(QString uid)
static TrackingServicePtr create(ctkPluginContext *pluginContext)
Control the custusx backend.
static PatientModelServicePtr create(ctkPluginContext *pluginContext)
SessionStorageServicePtr getSessionStorageService()
VideoServicePtr getVideoService()
static ProfileManager * getInstance()
returns the only instance of this class
static StateServicePtr create(ctkPluginContext *pluginContext)
cxLogicManager_EXPORT SessionStorageServicePtr sessionStorageService()
static LogicManager * getInstance()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void restartWithNewProfile(QString uid)
cxLogicManager_EXPORT SpaceProviderPtr spaceProvider()
LogicManager * logicManager()
cxLogicManager_EXPORT ViewServicePtr viewService()
cxLogicManager_EXPORT VideoServicePtr videoService()
cxLogicManager_EXPORT PatientModelServicePtr patientService()
boost::shared_ptr< class PluginFrameworkManager > PluginFrameworkManagerPtr
ViewServicePtr getViewService()
cxLogicManager_EXPORT TrackingServicePtr trackingService()
static ViewServicePtr create(ctkPluginContext *pluginContext)
static PluginFrameworkManagerPtr create()
virtual void aboutToStop()=0
void setApplicationComponent(ApplicationComponentPtr component)
PluginFrameworkManagerPtr getPluginFramework()
void requireUnique(int use_count, QString objectName)
SpaceProviderPtr getSpaceProvider()
boost::shared_ptr< class SessionStorageService > SessionStorageServicePtr
static void initialize(ApplicationComponentPtr component=ApplicationComponentPtr())
PatientModelServicePtr getPatientModelService()
StateServicePtr getStateService()