ctkConfigAdminTestActivator.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 "ctkConfigAdminTestActivator_p.h"
  16. #include <ctkPluginContext.h>
  17. #include <ctkPluginConstants.h>
  18. #include <QtPlugin>
  19. #include <QStringList>
  20. #include "ctkConfigurationAdminTestSuite_p.h"
  21. #include "ctkManagedServiceTestSuite_p.h"
  22. #include "ctkManagedServiceFactoryTestSuite_p.h"
  23. #include "ctkConfigurationPluginTestSuite_p.h"
  24. #include "ctkConfigurationListenerTestSuite_p.h"
  25. //----------------------------------------------------------------------------
  26. void ctkConfigAdminTestActivator::start(ctkPluginContext* context)
  27. {
  28. QString symbolicName = context->getProperty("cm.impl").toString();
  29. if (symbolicName.isEmpty())
  30. {
  31. throw ctkRuntimeException("Framework property 'cm.impl' containing the symbolic "
  32. "name of the ConfigAdmin implementation not found!");
  33. }
  34. long cmPluginId = -1;
  35. foreach(QSharedPointer<ctkPlugin> p, context->getPlugins())
  36. {
  37. if (p->getSymbolicName() == symbolicName)
  38. {
  39. cmPluginId = p->getPluginId();
  40. break;
  41. }
  42. }
  43. if (cmPluginId < 0)
  44. {
  45. QString msg = QString("The ConfigAdmin implementation '%1' is not installed.")
  46. .arg(symbolicName);
  47. throw ctkRuntimeException(msg);
  48. }
  49. ctkDictionary props;
  50. configAdminTestSuite = new ctkConfigurationAdminTestSuite(context, cmPluginId);
  51. props.clear();
  52. props.insert(ctkPluginConstants::SERVICE_PID, configAdminTestSuite->metaObject()->className());
  53. context->registerService<ctkTestSuiteInterface>(configAdminTestSuite, props);
  54. managedServiceTestSuite = new ctkManagedServiceTestSuite(context, cmPluginId);
  55. props.clear();
  56. props.insert(ctkPluginConstants::SERVICE_PID, managedServiceTestSuite->metaObject()->className());
  57. context->registerService<ctkTestSuiteInterface>(managedServiceTestSuite, props);
  58. managedServiceFactoryTestSuite = new ctkManagedServiceFactoryTestSuite(context, cmPluginId);
  59. props.clear();
  60. props.insert(ctkPluginConstants::SERVICE_PID, managedServiceFactoryTestSuite->metaObject()->className());
  61. context->registerService<ctkTestSuiteInterface>(managedServiceFactoryTestSuite, props);
  62. configPluginTestSuite = new ctkConfigurationPluginTestSuite(context, cmPluginId);
  63. props.clear();
  64. props.insert(ctkPluginConstants::SERVICE_PID, configPluginTestSuite->metaObject()->className());
  65. context->registerService<ctkTestSuiteInterface>(configPluginTestSuite, props);
  66. configListenerTestSuite = new ctkConfigurationListenerTestSuite(context, cmPluginId);
  67. props.clear();
  68. props.insert(ctkPluginConstants::SERVICE_PID, configListenerTestSuite->metaObject()->className());
  69. context->registerService<ctkTestSuiteInterface>(configListenerTestSuite, props);
  70. }
  71. //----------------------------------------------------------------------------
  72. void ctkConfigAdminTestActivator::stop(ctkPluginContext* context)
  73. {
  74. Q_UNUSED(context);
  75. delete configAdminTestSuite;
  76. delete managedServiceTestSuite;
  77. delete managedServiceFactoryTestSuite;
  78. delete configPluginTestSuite;
  79. delete configListenerTestSuite;
  80. configAdminTestSuite = 0;
  81. managedServiceTestSuite = 0;
  82. managedServiceFactoryTestSuite = 0;
  83. configPluginTestSuite = 0;
  84. configListenerTestSuite = 0;
  85. }
  86. #if QT_VERSION < QT_VERSION_CHECK(5,0,0)
  87. Q_EXPORT_PLUGIN2(org_commontk_configadmintest, ctkConfigAdminTestActivator)
  88. #endif