14 #include <sys/utsname.h> 17 #include <QApplication> 18 #include <ctkPluginContext.h> 43 LogicManager* LogicManager::mInstance = NULL;
84 struct utsname uname_pointer;
85 uname(&uname_pointer);
86 CX_LOG_DEBUG() <<
"System info: " << uname_pointer.sysname <<
", " << uname_pointer.version <<
", " << uname_pointer.release;
88 QString systemVersion(uname_pointer.version);
91 if(!systemVersion.contains(
"Ubuntu"))
96 QString systemKernel(uname_pointer.release);
97 if(systemVersion.contains(
"20.04"))
99 else if (systemKernel.contains(
"5.4."))
106 void LogicManager::initializeServices()
108 CX_LOG_INFO() <<
" --- Initialize services for " << qApp->applicationName() <<
"...";
112 mPluginFramework->loadState();
115 mComponent->create();
121 void LogicManager::basicSetup()
127 mPluginFramework->start();
128 mPluginFramework->setSearchPaths(QStringList());
130 this->createLegacyStoredServices();
133 void LogicManager::createLegacyStoredServices()
153 mComponent->destroy();
155 mComponent = component;
158 mComponent->create();
163 QMetaObject::invokeMethod(
this,
"onRestartWithNewProfile",
164 Qt::QueuedConnection,
165 Q_ARG(QString, uid));
168 void LogicManager::onRestartWithNewProfile(QString uid)
177 this->shutdownServices();
179 this->initializeServices();
182 void LogicManager::shutdownServices()
186 CX_LOG_ERROR() <<
"Trying to shutdown logicmanager when it already shutdown. Aborting shutdown, fix code.";
190 CX_LOG_INFO() <<
" --- Shutting down " << qApp->applicationName() <<
"...";
191 CX_LOG_DEBUG() <<
"Skipping some shutdown procedures in LogicManager, because of CTK issues";
196 mComponent->destroy();
198 mPluginFramework->stop();
200 this->shutdownLegacyStoredServices();
201 mPluginFramework.reset();
210 void LogicManager::shutdownServicesLight()
214 CX_LOG_ERROR() <<
"Trying to shutdown logicmanager when it already shutdown. Aborting shutdown, fix code.";
218 CX_LOG_INFO() <<
" --- Shutting down (Light) " << qApp->applicationName() <<
"...";
223 mComponent->destroy();
225 this->shutdownLegacyStoredServices();
235 void LogicManager::shutdownLegacyStoredServices()
237 this->shutdownService(mSpaceProvider,
"SpaceProvider");
238 this->shutdownService(mStateService,
"StateService");
239 this->shutdownService(mViewService,
"ViewService");
240 this->shutdownService(mTrackingService,
"TrackingService");
241 this->shutdownService(mPatientModelService,
"PatientModelService");
242 this->shutdownService(mVideoService,
"VideoService");
243 this->shutdownService(mSessionStorageService,
"SessionStorageService");
247 void LogicManager::shutdownService(boost::shared_ptr<T>& service, QString name)
255 return mPatientModelService;
259 return mTrackingService;
263 return mVideoService;
267 return mStateService;
271 return mSpaceProvider;
279 return mSessionStorageService;
289 return mPluginFramework;
305 LogicManager::LogicManager()
309 LogicManager::~LogicManager()
boost::shared_ptr< class SpaceProvider > SpaceProviderPtr
cxResource_EXPORT ProfilePtr profile()
static bool isUbuntu2004()
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. ...
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)
static LogicManager * getInstance()
boost::shared_ptr< class PatientModelService > PatientModelServicePtr
void restartWithNewProfile(QString uid)
LogicManager * logicManager()
boost::shared_ptr< class PluginFrameworkManager > PluginFrameworkManagerPtr
ViewServicePtr getViewService()
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()
Namespace for all CustusX production code.