ctkActivatorSL3.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkActivatorSL3_p.h"
  16. #include <ctkFooService.h>
  17. #include <QtPlugin>
  18. #include <QStringList>
  19. //----------------------------------------------------------------------------
  20. ctkActivatorSL3::ctkActivatorSL3()
  21. : _serviceAdded(false), _serviceRemoved(false), context(0)
  22. {
  23. }
  24. //----------------------------------------------------------------------------
  25. ctkActivatorSL3::~ctkActivatorSL3()
  26. {
  27. }
  28. //----------------------------------------------------------------------------
  29. void ctkActivatorSL3::start(ctkPluginContext* context)
  30. {
  31. this->context = context;
  32. context->registerService(this->metaObject()->className(), this);
  33. tracker.reset(new FooTracker(context, this));
  34. tracker->open();
  35. }
  36. //----------------------------------------------------------------------------
  37. void ctkActivatorSL3::stop(ctkPluginContext* context)
  38. {
  39. Q_UNUSED(context)
  40. tracker->close();
  41. }
  42. //----------------------------------------------------------------------------
  43. bool ctkActivatorSL3::serviceAdded() const
  44. {
  45. return _serviceAdded;
  46. }
  47. //----------------------------------------------------------------------------
  48. bool ctkActivatorSL3::serviceRemoved() const
  49. {
  50. return _serviceRemoved;
  51. }
  52. //----------------------------------------------------------------------------
  53. ctkFooService* ctkActivatorSL3::addingService(const ctkServiceReference& reference)
  54. {
  55. _serviceAdded = true;
  56. qDebug() << "SL3: Adding reference =" << reference;
  57. ctkFooService* fooService = context->getService<ctkFooService>(reference);
  58. fooService->foo();
  59. return fooService;
  60. }
  61. //----------------------------------------------------------------------------
  62. void ctkActivatorSL3::modifiedService(const ctkServiceReference& reference, ctkFooService* service)
  63. {
  64. Q_UNUSED(reference)
  65. Q_UNUSED(service)
  66. }
  67. //----------------------------------------------------------------------------
  68. void ctkActivatorSL3::removedService(const ctkServiceReference& reference, ctkFooService* service)
  69. {
  70. Q_UNUSED(service)
  71. _serviceRemoved = true;
  72. qDebug() << "SL3: Removing reference =" << reference;
  73. }
  74. Q_EXPORT_PLUGIN2(pluginSL3_test, ctkActivatorSL3)