Skip to content

pylon/ImageEventHandler.h#

Contains the image event handler base class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CImageEventHandler
The image event handler base class.

Source code#

//-----------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2010-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  Andreas Gau
//-----------------------------------------------------------------------------
#ifndef INCLUDED_IMAGEEVENTHANDLER_H_8866388
#define INCLUDED_IMAGEEVENTHANDLER_H_8866388

#include <pylon/stdinclude.h>

#ifdef _MSC_VER
#   pragma pack(push, PYLON_PACKING)
#endif /* _MSC_VER */

#include <pylon/GrabResultPtr.h>

namespace Pylon
{
    class CInstantCamera;

    class CImageEventHandler
    {
    public:

        virtual void OnImagesSkipped( CInstantCamera& camera, size_t countOfSkippedImages )
        {
            PYLON_UNUSED( &camera );
            PYLON_UNUSED( countOfSkippedImages );
        }

        virtual void OnImageGrabbed( CInstantCamera& camera, const CGrabResultPtr& grabResult )
        {
            PYLON_UNUSED( &camera );
            PYLON_UNUSED( grabResult );
        }

        virtual void OnImageEventHandlerRegistered( CInstantCamera& camera )
        {
            PYLON_UNUSED( &camera );
        }

        virtual void OnImageEventHandlerDeregistered( CInstantCamera& camera )
        {
            PYLON_UNUSED( &camera );
        }

        virtual void DestroyImageEventHandler()
        {
            //If runtime errors occur here during delete, check the following:
            //Check that the cleanup procedure is correctly set when registering.
            //Ensure that the registered object has been allocated on the heap using new.
            //Ensure that the registered object has not already been deleted.
            delete this;
        }

        CImageEventHandler()
            : m_eventHandlerRegistrationCount( 0 )
        {
        }

        CImageEventHandler( const CImageEventHandler& )
            : m_eventHandlerRegistrationCount( 0 )
        {
        }

        CImageEventHandler& operator=( const CImageEventHandler& )
        {
            return *this;
        }

        virtual ~CImageEventHandler()
        {
            PYLON_ASSERT2( DebugGetEventHandlerRegistrationCount() == 0, "Error: The event handler must not be destroyed while it is registered." );
        }

        // Internal use only. Subject to change without notice.
        const long& DebugGetEventHandlerRegistrationCount()
        {
            return m_eventHandlerRegistrationCount;
        }

    private:
        long m_eventHandlerRegistrationCount; // Counts how many times the event handler is registered.
    };

}

#ifdef _MSC_VER
#   pragma pack(pop)
#endif /* _MSC_VER */

#endif /* INCLUDED_IMAGEEVENTHANDLER_H_8866388 */

Updated on 5 July 2022 at 15:30:01