Fraxinus  2023.01.05-dev+develop.0da12
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
static RegisteredServicePtr create(ctkPluginContext *context, SERVICE_TYPE *service, QString iid)
boost::shared_ptr< class QObject > QObjectPtr
boost::shared_ptr< class RegisteredService > RegisteredServicePtr
ctkServiceRegistration mReference
static RegisteredServicePtr create(ctkPluginContext *context, QString iid)
Namespace for all CustusX production code.