ctkEventAdminTestActivator.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 "ctkEventAdminTestActivator_p.h"
  16. #include <ctkPluginContext.h>
  17. #include <ctkPluginConstants.h>
  18. #include <QtPlugin>
  19. #include <QStringList>
  20. #include "ctkEATopicWildcardTestSuite_p.h"
  21. #include "ctkEAScenario1TestSuite_p.h"
  22. #include "ctkEAScenario2TestSuite_p.h"
  23. #include "ctkEAScenario3TestSuite_p.h"
  24. #include "ctkEAScenario4TestSuite_p.h"
  25. //----------------------------------------------------------------------------
  26. ctkEventAdminTestActivator::ctkEventAdminTestActivator()
  27. : topicWildcardTestSuite(0), topicWildcardTestSuiteSS(0),
  28. scenario1TestSuite(0), scenario1TestSuiteSS(0), scenario2TestSuite(0)
  29. {
  30. }
  31. //----------------------------------------------------------------------------
  32. ctkEventAdminTestActivator::~ctkEventAdminTestActivator()
  33. {
  34. delete topicWildcardTestSuite;
  35. delete topicWildcardTestSuiteSS;
  36. delete scenario1TestSuite;
  37. delete scenario1TestSuiteSS;
  38. delete scenario2TestSuite;
  39. }
  40. //----------------------------------------------------------------------------
  41. void ctkEventAdminTestActivator::start(ctkPluginContext* context)
  42. {
  43. QString symbolicName = context->getProperty("event.impl").toString();
  44. if (symbolicName.isEmpty())
  45. {
  46. throw ctkRuntimeException("Framework property 'event.impl' containing the symbolic "
  47. "name of the EventAdmin implementation not found!");
  48. }
  49. long eventPluginId = -1;
  50. foreach(QSharedPointer<ctkPlugin> p, context->getPlugins())
  51. {
  52. if (p->getSymbolicName() == symbolicName)
  53. {
  54. eventPluginId = p->getPluginId();
  55. break;
  56. }
  57. }
  58. if (eventPluginId < 0)
  59. {
  60. QString msg = QString("The EventAdmin implementation '%1' is not installed.")
  61. .arg(symbolicName);
  62. throw ctkRuntimeException(msg);
  63. }
  64. topicWildcardTestSuite = new ctkEATopicWildcardTestSuite(context, eventPluginId, false);
  65. context->registerService<ctkTestSuiteInterface>(topicWildcardTestSuite);
  66. topicWildcardTestSuiteSS = new ctkEATopicWildcardTestSuite(context, eventPluginId, true);
  67. context->registerService<ctkTestSuiteInterface>(topicWildcardTestSuiteSS);
  68. scenario1TestSuite = new ctkEAScenario1TestSuite(context, eventPluginId, false);
  69. context->registerService<ctkTestSuiteInterface>(scenario1TestSuite);
  70. scenario1TestSuiteSS = new ctkEAScenario1TestSuite(context, eventPluginId, true);
  71. context->registerService<ctkTestSuiteInterface>(scenario1TestSuiteSS);
  72. scenario2TestSuite = new ctkEAScenario2TestSuite(context, eventPluginId);
  73. context->registerService<ctkTestSuiteInterface>(scenario2TestSuite);
  74. scenario3TestSuite = new ctkEAScenario3TestSuite(context, eventPluginId);
  75. context->registerService<ctkTestSuiteInterface>(scenario3TestSuite);
  76. scenario4TestSuite = new ctkEAScenario4TestSuite(context, eventPluginId);
  77. context->registerService<ctkTestSuiteInterface>(scenario4TestSuite);
  78. }
  79. //----------------------------------------------------------------------------
  80. void ctkEventAdminTestActivator::stop(ctkPluginContext* context)
  81. {
  82. Q_UNUSED(context);
  83. delete topicWildcardTestSuite;
  84. delete topicWildcardTestSuiteSS;
  85. delete scenario1TestSuite;
  86. delete scenario1TestSuiteSS;
  87. delete scenario2TestSuite;
  88. delete scenario3TestSuite;
  89. delete scenario4TestSuite;
  90. topicWildcardTestSuite = 0;
  91. topicWildcardTestSuiteSS = 0;
  92. scenario1TestSuite = 0;
  93. scenario1TestSuiteSS = 0;
  94. scenario2TestSuite = 0;
  95. scenario3TestSuite = 0;
  96. scenario4TestSuite = 0;
  97. }
  98. Q_EXPORT_PLUGIN2(org_commontk_eventadmintest, ctkEventAdminTestActivator)