BaslerGigEImageEventHandler.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 image event handler base class.
  10. */
  11. #ifndef INCLUDED_BASLERGIGEIMAGEEVENTHANDLER_H_8866388
  12. #define INCLUDED_BASLERGIGEIMAGEEVENTHANDLER_H_8866388
  13. #include <pylon/stdinclude.h>
  14. #ifdef _MSC_VER
  15. # pragma pack(push, PYLON_PACKING)
  16. #endif /* _MSC_VER */
  17. #include <pylon/gige/BaslerGigEGrabResultPtr.h>
  18. namespace Pylon
  19. {
  20. class CBaslerGigEInstantCamera;
  21. /** \addtogroup Pylon_InstantCameraApiGigE
  22. * @{
  23. */
  24. /**
  25. \class CBaslerGigEImageEventHandler
  26. \brief The image event handler base class.
  27. */
  28. class CBaslerGigEImageEventHandler
  29. {
  30. public:
  31. /**
  32. \brief This method is called when images have been skipped using the GrabStrategy_LatestImageOnly strategy or the GrabStrategy_LatestImages strategy.
  33. \param[in] camera The source of the call.
  34. \param[in] countOfSkippedImages The number of images skipped. This \c countOfSkippedImages does not include the number of images lost in the case of a buffer under run in the driver.
  35. \error
  36. Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered.
  37. \threading
  38. This method is called outside the lock of the camera object but inside the lock of the image event handler registry.
  39. */
  40. virtual void OnImagesSkipped( CBaslerGigEInstantCamera& camera, size_t countOfSkippedImages )
  41. {
  42. PYLON_UNUSED( &camera );
  43. PYLON_UNUSED( countOfSkippedImages );
  44. }
  45. /**
  46. \brief This method is called when an image has been grabbed.
  47. The grab result smart pointer passed does always reference a grab result data object.
  48. The status of the grab needs to be checked before accessing the grab result data.
  49. See CGrabResultData::GrabSucceeded(), CGrabResultData::GetErrorCode() and
  50. CGrabResultData::GetErrorDescription() for more information.
  51. \param[in] camera The source of the call.
  52. \param[in] grabResult The grab result data.
  53. \error
  54. Exceptions from this call will propagate through. The notification of event handlers stops when an exception is triggered.
  55. \threading
  56. This method is called outside the lock of the camera object but inside the lock of the image event handler registry.
  57. */
  58. virtual void OnImageGrabbed( CBaslerGigEInstantCamera& camera, const CBaslerGigEGrabResultPtr& grabResult )
  59. {
  60. PYLON_UNUSED( &camera );
  61. PYLON_UNUSED( grabResult );
  62. }
  63. /**
  64. \brief This method is called when the image event handler has been registered.
  65. \param[in] camera The source of the call.
  66. \error
  67. Exceptions from this call will propagate through.
  68. \threading
  69. This method is called inside the lock of the image event handler registry.
  70. */
  71. virtual void OnImageEventHandlerRegistered( CBaslerGigEInstantCamera& camera )
  72. {
  73. PYLON_UNUSED( &camera );
  74. }
  75. /**
  76. \brief This method is called when the image event handler has been deregistered.
  77. The image event handler is automatically deregistered when the Instant Camera object
  78. is destroyed.
  79. \param[in] camera The source of the call.
  80. \error
  81. C++ exceptions from this call will be caught and ignored.
  82. \threading
  83. This method is called inside the lock of the image event handler registry.
  84. */
  85. virtual void OnImageEventHandlerDeregistered( CBaslerGigEInstantCamera& camera )
  86. {
  87. PYLON_UNUSED( &camera );
  88. }
  89. /*!
  90. \brief Destroys the image event handler.
  91. \error
  92. C++ exceptions from this call will be caught and ignored.
  93. */
  94. virtual void DestroyImageEventHandler()
  95. {
  96. //If runtime errors occur here during delete, check the following:
  97. //Check that the cleanup procedure is correctly set when registering.
  98. //Ensure that the registered object has been allocated on the heap using new.
  99. //Ensure that the registered object has not already been deleted.
  100. delete this;
  101. }
  102. /// Create.
  103. CBaslerGigEImageEventHandler()
  104. : m_eventHandlerRegistrationCount( 0 )
  105. {
  106. }
  107. /// Copy.
  108. CBaslerGigEImageEventHandler( const CBaslerGigEImageEventHandler& )
  109. : m_eventHandlerRegistrationCount( 0 )
  110. {
  111. }
  112. /// Assign.
  113. CBaslerGigEImageEventHandler& operator=( const CBaslerGigEImageEventHandler& )
  114. {
  115. return *this;
  116. }
  117. /// Destruct.
  118. virtual ~CBaslerGigEImageEventHandler()
  119. {
  120. PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." );
  121. }
  122. // Internal use only. Subject to change without notice.
  123. const long& DebugGetEventHandlerRegistrationCount()
  124. {
  125. return m_eventHandlerRegistrationCount;
  126. }
  127. private:
  128. long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered.
  129. };
  130. /**
  131. * @}
  132. */
  133. }
  134. #ifdef _MSC_VER
  135. # pragma pack(pop)
  136. #endif /* _MSC_VER */
  137. #endif /* INCLUDED_BASLERGIGEIMAGEEVENTHANDLER_H_8866388 */