NorMIT-nav  22.09
An IGT application
cxRegisteredService.h
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 #ifndef CXREGISTEREDSERVICE_H
13 #define CXREGISTEREDSERVICE_H
14 
15 #include "cxResourcePluginUtilitiesExport.h"
16 
17 #include "boost/shared_ptr.hpp"
18 #include <ctkPluginActivator.h>
19 
20 typedef boost::shared_ptr<class QObject> QObjectPtr;
21 
22 namespace cx
23 {
24 typedef boost::shared_ptr<class RegisteredService> RegisteredServicePtr;
25 
35 class cxResourcePluginUtilities_EXPORT RegisteredService
36 {
37 public:
38  template <class SERVICE_TYPE>
39  static RegisteredServicePtr create(ctkPluginContext* context, QString iid)
40  {
41  return RegisteredServicePtr(new RegisteredService(context, new SERVICE_TYPE(context), iid));
42  }
43  template <class SERVICE_TYPE>
44  static RegisteredServicePtr create(ctkPluginContext* context, SERVICE_TYPE* service, QString iid)
45  {
46  return RegisteredServicePtr(new RegisteredService(context, service, iid));
47  }
48 
49  explicit RegisteredService(ctkPluginContext* context, QObject* instance, QString iid);
51  template<class SERVICE_TYPE>
52  SERVICE_TYPE* get() const { return dynamic_cast<SERVICE_TYPE*>(mService.get()); }
54  ctkServiceRegistration mReference;
55 };
56 
57 } // namespace cx
58 
59 #endif // CXREGISTEREDSERVICE_H
cx::RegisteredService::mService
QObjectPtr mService
Definition: cxRegisteredService.h:53
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cx::RegisteredService::create
static RegisteredServicePtr create(ctkPluginContext *context, SERVICE_TYPE *service, QString iid)
Definition: cxRegisteredService.h:44
cx::RegisteredService::mReference
ctkServiceRegistration mReference
Definition: cxRegisteredService.h:54
cx::RegisteredService::get
SERVICE_TYPE * get() const
Definition: cxRegisteredService.h:52
cx::RegisteredServicePtr
boost::shared_ptr< class RegisteredService > RegisteredServicePtr
Definition: cxAcquisitionServicePluginActivator.h:31
QObjectPtr
boost::shared_ptr< class QObject > QObjectPtr
Definition: cxRegisteredService.h:20
cx::RegisteredService::create
static RegisteredServicePtr create(ctkPluginContext *context, QString iid)
Definition: cxRegisteredService.h:39
cx::RegisteredService
Definition: cxRegisteredService.h:35