BaslerGigECameraEventHandler.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2010-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Andreas Gau
  6. //-----------------------------------------------------------------------------
  7. /**
  8. \file
  9. \brief Contains the camera event handler base class.
  10. */
  11. #ifndef INCLUDED_BASLERGIGECAMERAEVENTHANDLER_H_3102315
  12. #define INCLUDED_BASLERGIGECAMERAEVENTHANDLER_H_3102315
  13. #include <pylon/stdinclude.h>
  14. #ifdef _MSC_VER
  15. # pragma pack(push, PYLON_PACKING)
  16. #endif /* _MSC_VER */
  17. #include <GenApi/INode.h>
  18. namespace Pylon
  19. {
  20. class CBaslerGigEInstantCamera;
  21. /** \addtogroup Pylon_InstantCameraApiGigE
  22. * @{
  23. */
  24. /**
  25. \class CBaslerGigECameraEventHandler
  26. \brief The camera event handler base class.
  27. */
  28. class CBaslerGigECameraEventHandler
  29. {
  30. public:
  31. /**
  32. \brief This method is called when a camera event has been received.
  33. Only very short processing tasks should be performed by this method. Otherwise, the event notification will block the
  34. processing of images.
  35. \param[in] camera The source of the call.
  36. \param[in] userProvidedId The ID passed when registering for the event. It can be used to distinguish between different events.
  37. \param[in] pNode The node identified by node name when registering.
  38. \error
  39. C++ exceptions from this call will be caught and ignored. All event handlers are notified.
  40. \threading
  41. This method is called outside the lock of the camera object, outside the lock of the node map, and inside the lock of the camera event handler registry.
  42. */
  43. virtual void OnCameraEvent( CBaslerGigEInstantCamera& camera, intptr_t userProvidedId, GenApi::INode* pNode )
  44. {
  45. PYLON_UNUSED( &camera );
  46. PYLON_UNUSED( userProvidedId );
  47. PYLON_UNUSED( pNode );
  48. }
  49. /**
  50. \brief This method is called when the camera event handler has been registered.
  51. \param[in] camera The source of the call.
  52. \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event.
  53. \param[in] userProvidedId This ID is passed as a parameter in CBaslerGigECameraEventHandler::OnCameraEvent and can be used to distinguish between different events.
  54. \error
  55. Exceptions from this call will propagate through.
  56. \threading
  57. This method is called inside the lock of the camera event handler registry.
  58. */
  59. virtual void OnCameraEventHandlerRegistered( CBaslerGigEInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId )
  60. {
  61. PYLON_UNUSED( &camera );
  62. PYLON_UNUSED( nodeName );
  63. PYLON_UNUSED( userProvidedId );
  64. }
  65. /**
  66. \brief This method is called when the camera event handler has been deregistered.
  67. The camera event handler is automatically deregistered when the Instant Camera object
  68. is destroyed.
  69. \param[in] camera The source of the call.
  70. \param[in] nodeName The name of the event data node updated on camera event, e.g. "ExposureEndEventTimestamp" for exposure end event.
  71. \param[in] userProvidedId This ID is passed as a parameter in CBaslerGigECameraEventHandler::OnCameraEvent and can be used to distinguish between different events.
  72. \error
  73. C++ exceptions from this call will be caught and ignored.
  74. \threading
  75. This method is called inside the lock of the camera event handler registry.
  76. */
  77. virtual void OnCameraEventHandlerDeregistered( CBaslerGigEInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId )
  78. {
  79. PYLON_UNUSED( &camera );
  80. PYLON_UNUSED( nodeName );
  81. PYLON_UNUSED( userProvidedId );
  82. }
  83. /*!
  84. \brief Destroys the camera event handler.
  85. \error
  86. C++ exceptions from this call will be caught and ignored.
  87. */
  88. virtual void DestroyCameraEventHandler()
  89. {
  90. //If runtime errors occur here during delete, check the following:
  91. //Check that the cleanup procedure is correctly set when registering.
  92. //Ensure that the registered object has been allocated on the heap using new.
  93. //Ensure that the registered object has not already been deleted.
  94. delete this;
  95. }
  96. /// Create.
  97. CBaslerGigECameraEventHandler()
  98. : m_eventHandlerRegistrationCount( 0 )
  99. {
  100. }
  101. /// Copy.
  102. CBaslerGigECameraEventHandler( const CBaslerGigECameraEventHandler& )
  103. : m_eventHandlerRegistrationCount( 0 )
  104. {
  105. }
  106. /// Assign.
  107. CBaslerGigECameraEventHandler& operator=( const CBaslerGigECameraEventHandler& )
  108. {
  109. return *this;
  110. }
  111. /// Destruct.
  112. virtual ~CBaslerGigECameraEventHandler()
  113. {
  114. PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." );
  115. }
  116. // Internal use only. Subject to change without notice.
  117. const long& DebugGetEventHandlerRegistrationCount()
  118. {
  119. return m_eventHandlerRegistrationCount;
  120. }
  121. private:
  122. long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered.
  123. };
  124. /**
  125. * @}
  126. */
  127. }
  128. #ifdef _MSC_VER
  129. # pragma pack(pop)
  130. #endif /* _MSC_VER */
  131. #endif /* INCLUDED_BASLERGIGECAMERAEVENTHANDLER_H_3102315 */