Skip to content

pylon/BaslerUniversalImageEventHandler.h#

Contains the image event handler base class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CBaslerUniversalImageEventHandler
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_BASLERUNIVERSALIMAGEEVENTHANDLER_H
#define INCLUDED_BASLERUNIVERSALIMAGEEVENTHANDLER_H

#pragma once

#include <pylon/stdinclude.h>

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

#include <pylon/BaslerUniversalGrabResultPtr.h>

namespace Pylon
{
    class CBaslerUniversalInstantCamera;

    class CBaslerUniversalImageEventHandler
    {
    public:

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

        virtual void OnImageGrabbed( CBaslerUniversalInstantCamera& camera, const CBaslerUniversalGrabResultPtr& grabResult )
        {
            PYLON_UNUSED( &camera );
            PYLON_UNUSED( grabResult );
        }

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

        virtual void OnImageEventHandlerDeregistered( CBaslerUniversalInstantCamera& 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;
        }

        CBaslerUniversalImageEventHandler()
            : m_eventHandlerRegistrationCount( 0 )
        {
        }

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

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

        virtual ~CBaslerUniversalImageEventHandler()
        {
            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_BASLERUNIVERSALIMAGEEVENTHANDLER_H */

Updated on 5 July 2022 at 15:30:01