Skip to content

pylon/BaslerUniversalCameraEventHandler.h#

Contains the camera event handler base class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CBaslerUniversalCameraEventHandler
The camera event handler base class.

Source code#

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

#pragma once

#include <pylon/stdinclude.h>

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

#include <GenApi/INode.h>

namespace Pylon
{
    class CBaslerUniversalInstantCamera;

    class CBaslerUniversalCameraEventHandler
    {
    public:

        virtual void OnCameraEvent( CBaslerUniversalInstantCamera& camera, intptr_t userProvidedId, GenApi::INode* pNode )
        {
            PYLON_UNUSED( &camera );
            PYLON_UNUSED( userProvidedId );
            PYLON_UNUSED( pNode );
        }

        virtual void OnCameraEventHandlerRegistered( CBaslerUniversalInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId )
        {
            PYLON_UNUSED( &camera );
            PYLON_UNUSED( nodeName );
            PYLON_UNUSED( userProvidedId );
        }

        virtual void OnCameraEventHandlerDeregistered( CBaslerUniversalInstantCamera& camera, const String_t& nodeName, intptr_t userProvidedId )
        {
            PYLON_UNUSED( &camera );
            PYLON_UNUSED( nodeName );
            PYLON_UNUSED( userProvidedId );
        }

        virtual void DestroyCameraEventHandler()
        {
            //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;
        }

        CBaslerUniversalCameraEventHandler()
            : m_eventHandlerRegistrationCount( 0 )
        {
        }

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

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

        virtual ~CBaslerUniversalCameraEventHandler()
        {
            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_BASLERUNIVERSALCAMERAEVENTHANDLER_H */

Updated on 27 July 2022 at 19:03:47