ctkEAHandlerTask_p.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. class _GetAndUngetEventHandler;
  36. public:
  37. /**
  38. * Construct a delivery task for the given service and event.
  39. *
  40. * @param eventHandlerRef The servicereference of the handler
  41. * @param event The event to deliver
  42. * @param handlerTasks Used to blacklist the service or get the service object
  43. * for the reference
  44. */
  45. ctkEAHandlerTask(const ctkServiceReference& eventHandlerRef,
  46. const ctkEvent& event, BlacklistingHandlerTasks* handlerTasks);
  47. ctkEAHandlerTask(const Self& task);
  48. ctkEAHandlerTask& operator=(const Self& task);
  49. /**
  50. * Return the class name of the handler
  51. */
  52. QString getHandlerClassName() const;
  53. /**
  54. * Deliver the event to the handler.
  55. */
  56. void execute();
  57. /**
  58. * Blacklist the handler.
  59. */
  60. void blackListHandler();
  61. };
  62. #include "ctkEAHandlerTask.tpp"
  63. #endif // CTKEAHANDLERTASK_P_H