ctkEventAdminTestPerfActivator.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "ctkEventAdminTestPerfActivator_p.h"
  16. #include "ctkEventAdminPerfTestSuite_p.h"
  17. #include <QtPlugin>
  18. //----------------------------------------------------------------------------
  19. ctkEventAdminTestPerfActivator::ctkEventAdminTestPerfActivator()
  20. : perfTestSuite(0)
  21. {
  22. }
  23. //----------------------------------------------------------------------------
  24. ctkEventAdminTestPerfActivator::~ctkEventAdminTestPerfActivator()
  25. {
  26. delete perfTestSuite;
  27. }
  28. //----------------------------------------------------------------------------
  29. void ctkEventAdminTestPerfActivator::start(ctkPluginContext* context)
  30. {
  31. QString symbolicName = context->getProperty("event.impl").toString();
  32. if (symbolicName.isEmpty())
  33. {
  34. throw ctkRuntimeException("Framework property 'event.impl' containing the symbolic "
  35. "name of the EventAdmin implementation not found!");
  36. }
  37. long eventPluginId = -1;
  38. foreach(QSharedPointer<ctkPlugin> p, context->getPlugins())
  39. {
  40. if (p->getSymbolicName() == symbolicName)
  41. {
  42. eventPluginId = p->getPluginId();
  43. break;
  44. }
  45. }
  46. if (eventPluginId < 0)
  47. {
  48. QString msg = QString("The EventAdmin implementation '%1' is not installed.")
  49. .arg(symbolicName);
  50. throw ctkRuntimeException(msg);
  51. }
  52. perfTestSuite = new ctkEventAdminPerfTestSuite(context, eventPluginId);
  53. context->registerService<ctkTestSuiteInterface>(perfTestSuite);
  54. }
  55. //----------------------------------------------------------------------------
  56. void ctkEventAdminTestPerfActivator::stop(ctkPluginContext* context)
  57. {
  58. Q_UNUSED(context);
  59. delete perfTestSuite;
  60. perfTestSuite = 0;
  61. }
  62. #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
  63. Q_EXPORT_PLUGIN2(org_commontk_eventadmintest_perf, ctkEventAdminTestPerfActivator)
  64. #endif