ctkActivatorSL1.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 "ctkActivatorSL1_p.h"
  16. #include "ctkFooService.h"
  17. #include <QtPlugin>
  18. #include <QStringList>
  19. //----------------------------------------------------------------------------
  20. ctkActivatorSL1::ctkActivatorSL1()
  21. : _serviceAdded(false), _serviceRemoved(false),
  22. context(0)
  23. {
  24. }
  25. //----------------------------------------------------------------------------
  26. ctkActivatorSL1::~ctkActivatorSL1()
  27. {
  28. }
  29. //----------------------------------------------------------------------------
  30. void ctkActivatorSL1::start(ctkPluginContext* context)
  31. {
  32. this->context = context;
  33. context->registerService(this->metaObject()->className(), this);
  34. tracker.reset(new FooTracker(context, this));
  35. tracker->open();
  36. }
  37. //----------------------------------------------------------------------------
  38. void ctkActivatorSL1::stop(ctkPluginContext* context)
  39. {
  40. Q_UNUSED(context)
  41. tracker->close();
  42. }
  43. //----------------------------------------------------------------------------
  44. bool ctkActivatorSL1::serviceAdded() const
  45. {
  46. return _serviceAdded;
  47. }
  48. //----------------------------------------------------------------------------
  49. bool ctkActivatorSL1::serviceRemoved() const
  50. {
  51. return _serviceRemoved;
  52. }
  53. //----------------------------------------------------------------------------
  54. ctkFooService* ctkActivatorSL1::addingService(const ctkServiceReference& reference)
  55. {
  56. _serviceAdded = true;
  57. qDebug() << "Adding reference =" << reference;
  58. ctkFooService* fooService = context->getService<ctkFooService>(reference);
  59. fooService->foo();
  60. return fooService;
  61. }
  62. //----------------------------------------------------------------------------
  63. void ctkActivatorSL1::modifiedService(const ctkServiceReference& reference, ctkFooService* service)
  64. {
  65. Q_UNUSED(reference)
  66. Q_UNUSED(service)
  67. }
  68. //----------------------------------------------------------------------------
  69. void ctkActivatorSL1::removedService(const ctkServiceReference& reference, ctkFooService* service)
  70. {
  71. Q_UNUSED(service)
  72. _serviceRemoved = true;
  73. qDebug() << "Removing reference =" << reference;
  74. }
  75. Q_EXPORT_PLUGIN2(pluginSL1_test, ctkActivatorSL1)