NorMIT-nav  2023.01.05-dev+develop.0da12
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 }
cx::StateService::workflowStateAboutToChange
void workflowStateAboutToChange()
cx::StateServiceProxy::isNull
virtual bool isNull()
Definition: cxStateServiceProxy.cpp:120
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::StateServiceProxy::StateServiceProxy
StateServiceProxy(ctkPluginContext *pluginContext)
Definition: cxStateServiceProxy.cpp:24
cx::ServiceTrackerListener
Helper class for listening to services being added, modified and removed.
Definition: cxServiceTrackerListener.h:53
cx::StateServiceProxy::getVersionName
virtual QString getVersionName()
Definition: cxStateServiceProxy.cpp:69
cx::WorkflowStateMachinePtr
boost::shared_ptr< class WorkflowStateMachine > WorkflowStateMachinePtr
Definition: cxStateServiceImpl.h:21
cxStateServiceProxy.h
cx::StateServiceProxy::getActiveDesktop
virtual Desktop getActiveDesktop()
Definition: cxStateServiceProxy.cpp:99
cx::StateService::workflowStateChanged
void workflowStateChanged()
cx::StateService::applicationStateChanged
void applicationStateChanged()
cxNullDeleter.h
cx::StateServiceProxy::resetDesktop
virtual void resetDesktop()
Definition: cxStateServiceProxy.cpp:109
cx::StateServiceProxy::getAllApplicationStateNames
virtual QStringList getAllApplicationStateNames() const
Definition: cxStateServiceProxy.cpp:84
cx::StateService::getNullObject
static StateServicePtr getNullObject()
Definition: cxStateService.cpp:43
cx::Desktop
Data class for CustusX desktop.
Definition: cxStateService.h:43
cx::StateServiceProxy::create
static StateServicePtr create(ctkPluginContext *pluginContext)
Definition: cxStateServiceProxy.cpp:19
cx::StateServiceProxy::setWorkFlowState
virtual void setWorkFlowState(QString uid)
Definition: cxStateServiceProxy.cpp:94
cx::StateServiceProxy::saveDesktop
virtual void saveDesktop(Desktop desktop)
Definition: cxStateServiceProxy.cpp:104
cx::StateServiceProxy::getWorkflowActions
virtual QActionGroup * getWorkflowActions()
Definition: cxStateServiceProxy.cpp:89
cx::StateServiceProxy::getApplicationStateName
virtual QString getApplicationStateName() const
Definition: cxStateServiceProxy.cpp:79
cx::StateServiceProxy::getWorkflow
virtual WorkflowStateMachinePtr getWorkflow()
Definition: cxStateServiceProxy.cpp:115
cx::StateService
Workflow states for CustusX.
Definition: cxStateService.h:102
cx::StateServicePtr
boost::shared_ptr< class StateService > StateServicePtr
Definition: cxLogicManager.h:27