ctkApplicationRunnable.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifndef CTKAPPLICATIONRUNNABLE_H
  16. #define CTKAPPLICATIONRUNNABLE_H
  17. #include <ctkPluginFrameworkExport.h>
  18. class QVariant;
  19. /**
  20. * Like a QRunnable, an object which captures a block of code which can
  21. * be passed around and executed as well as stopped. Unlike standard runnables,
  22. * paramaterized runnables allow an arbitrary QVariant to be passed in when the
  23. * block is evaluated.
  24. * <p>
  25. * Clients may implement this interface.
  26. * </p>
  27. */
  28. struct CTK_PLUGINFW_EXPORT ctkApplicationRunnable
  29. {
  30. virtual ~ctkApplicationRunnable();
  31. /**
  32. * Executes the block of code encapsulated by this runnable in the context of
  33. * the given object and returns the result. The result may be an invalid QVariant.
  34. *
  35. * @param context the context for evaluating the runnable
  36. * @return the result of evaluating the runnable in the given context
  37. * @throws std::exception if there is a problem running this runnable
  38. */
  39. virtual QVariant run(const QVariant& context) = 0;
  40. /**
  41. * Forces this runnable to stop.
  42. */
  43. virtual void stop() = 0;
  44. };
  45. #endif // CTKAPPLICATIONRUNNABLE_H