ctkEAHandlerTask_p.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 CTKEAHANDLERTASK_P_H
  16. #define CTKEAHANDLERTASK_P_H
  17. #include <QAtomicInt>
  18. #include <ctkServiceReference.h>
  19. #include <service/event/ctkEvent.h>
  20. /**
  21. * A task that will deliver its event to its <tt>ctkEventHandler</tt> when executed
  22. * or blacklist the handler, respectively.
  23. */
  24. template<class BlacklistingHandlerTasks>
  25. class ctkEAHandlerTask
  26. {
  27. private:
  28. typedef ctkEAHandlerTask<BlacklistingHandlerTasks> Self;
  29. // The service reference of the handler
  30. ctkServiceReference eventHandlerRef;
  31. // The event to deliver to the handler
  32. ctkEvent event;
  33. // Used to blacklist the service or get the service object for the reference
  34. BlacklistingHandlerTasks* handlerTasks;
  35. // Is this handler finished
  36. mutable QAtomicInt finishedTask;
  37. class _GetAndUngetEventHandler;
  38. public:
  39. /**
  40. * Construct a delivery task for the given service and event.
  41. *
  42. * @param eventHandlerRef The servicereference of the handler
  43. * @param event The event to deliver
  44. * @param handlerTasks Used to blacklist the service or get the service object
  45. * for the reference
  46. */
  47. ctkEAHandlerTask(const ctkServiceReference& eventHandlerRef,
  48. const ctkEvent& event, BlacklistingHandlerTasks* handlerTasks);
  49. ctkEAHandlerTask(const Self& task);
  50. ctkEAHandlerTask& operator=(const Self& task);
  51. /**
  52. * Return the class name of the handler
  53. */
  54. QString getHandlerClassName() const;
  55. /**
  56. * Deliver the event to the handler.
  57. */
  58. void execute();
  59. /**
  60. * Blacklist the handler.
  61. */
  62. void blackListHandler();
  63. /**
  64. * Is the delivery finished
  65. */
  66. bool finished() const;
  67. };
  68. #include "ctkEAHandlerTask.tpp"
  69. #endif // CTKEAHANDLERTASK_P_H