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)
194 this->shutdownServices();
196 this->initializeServices();
199 void LogicManager::shutdownServices()
201 CX_LOG_INFO() <<
" --- Shutting down " << qApp->applicationName() <<
"...";
206 mComponent->destroy();
208 mPluginFramework->stop();
210 this->shutdownLegacyStoredServices();
211 mPluginFramework.reset();
219 void LogicManager::shutdownLegacyStoredServices()
221 this->shutdownService(mSpaceProvider,
"SpaceProvider");
222 this->shutdownService(mStateService,
"StateService");
223 this->shutdownService(mViewService,
"ViewService");
224 this->shutdownService(mTrackingService,
"TrackingService");
225 this->shutdownService(mPatientModelService,
"PatientModelService");
226 this->shutdownService(mVideoService,
"VideoService");
227 this->shutdownService(mSessionStorageService,
"SessionStorageService");
232 void LogicManager::shutdownService(boost::shared_ptr<T>& service, QString name)
240 return mPatientModelService;
244 return mTrackingService;
248 return mVideoService;
252 return mStateService;
256 return mSpaceProvider;
264 return mSessionStorageService;
268 return mPluginFramework;
284 LogicManager::LogicManager()
288 LogicManager::~LogicManager()
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
cxResource_EXPORT ProfilePtr profile()
boost::shared_ptr< class VideoService > VideoServicePtr
boost::shared_ptr< class ApplicationComponent > ApplicationComponentPtr
void restartServicesWithProfile(QString uid)
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 ProfileManager * getInstance(QString defaultProfile=QString("Laboratory"))
returns the only instance of this class
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 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()