Skip to content

pylon/CameraEventHandler.h#

Contains the camera event handler base class.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CCameraEventHandler
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_CAMERAEVENTHANDLER_H_3102315
#define INCLUDED_CAMERAEVENTHANDLER_H_3102315

#include <pylon/stdinclude.h>

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

#include <GenApi/INode.h>

namespace Pylon
{
    class CInstantCamera;

    class CCameraEventHandler
    {
    public:

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

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

        virtual void OnCameraEventHandlerDeregistered( CInstantCamera& 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;
        }

        CCameraEventHandler()
            : m_eventHandlerRegistrationCount( 0 )
        {
        }

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

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

        virtual ~CCameraEventHandler()
        {
            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_CAMERAEVENTHANDLER_H_3102315 */

Updated on 5 July 2022 at 15:30:01