CustusX  22.04-rc5
An IGT application
cxStateServiceProxy.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxStateServiceProxy.h"
13 #include "boost/bind.hpp"
14 #include "cxNullDeleter.h"
15 
16 namespace cx
17 {
18 
19 StateServicePtr StateServiceProxy::create(ctkPluginContext *pluginContext)
20 {
21  return StateServicePtr(new StateServiceProxy(pluginContext));
22 }
23 
24 StateServiceProxy::StateServiceProxy(ctkPluginContext *pluginContext) :
25  mPluginContext(pluginContext),
26  mService(StateService::getNullObject())
27 {
28  this->initServiceListener();
29 }
30 
31 void StateServiceProxy::initServiceListener()
32 {
33  mServiceListener.reset(new ServiceTrackerListener<StateService>(
34  mPluginContext,
35  boost::bind(&StateServiceProxy::onServiceAdded, this, _1),
36  boost::function<void (StateService*)>(),
37  boost::bind(&StateServiceProxy::onServiceRemoved, this, _1)
38  ));
39  mServiceListener->open();
40 }
41 void StateServiceProxy::onServiceAdded(StateService* service)
42 {
43  mService.reset(service, null_deleter());
44 
48 
50  emit workflowStateChanged();
52 }
53 
54 void StateServiceProxy::onServiceRemoved(StateService *service)
55 {
59 
60  mService = StateService::getNullObject();
61 
63  emit workflowStateChanged();
65 }
66 
67 
68 
70 {
71  return mService->getVersionName();
72 }
73 
74 //QActionGroup* StateServiceProxy::getApplicationActions()
75 //{
76 // return mService->getApplicationActions();
77 //}
78 
80 {
81  return mService->getApplicationStateName();
82 }
83 
85 {
86  return mService->getAllApplicationStateNames();
87 }
88 
90 {
91  return mService->getWorkflowActions();
92 }
93 
95 {
96  mService->setWorkFlowState(uid);
97 }
98 
100 {
101  return mService->getActiveDesktop();
102 }
103 
105 {
106  mService->saveDesktop(desktop);
107 }
108 
110 {
111  mService->resetDesktop();
112 }
113 
114 
116 {
117  return mService->getWorkflow();
118 }
119 
121 {
122  return false;
123 }
124 
125 }
virtual QStringList getAllApplicationStateNames() const
void applicationStateChanged()
boost::shared_ptr< class StateService > StateServicePtr
virtual WorkflowStateMachinePtr getWorkflow()
virtual QString getVersionName()
virtual void setWorkFlowState(QString uid)
virtual QActionGroup * getWorkflowActions()
virtual QString getApplicationStateName() const
void workflowStateAboutToChange()
Workflow states for CustusX.
static StateServicePtr create(ctkPluginContext *pluginContext)
boost::shared_ptr< class WorkflowStateMachine > WorkflowStateMachinePtr
StateServiceProxy(ctkPluginContext *pluginContext)
static StateServicePtr getNullObject()
Helper class for listening to services being added, modified and removed.
void workflowStateChanged()
Data class for CustusX desktop.
virtual Desktop getActiveDesktop()
virtual void saveDesktop(Desktop desktop)
Namespace for all CustusX production code.