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()