File ManagedSystemEventHandler.h¶
File List > SpinnakerNET > ManagedSystemEventHandler.h
Go to the documentation of this file
//=============================================================================
// Copyright (c) 2026 FLIR Integrated Imaging Solutions, Inc. All Rights Reserved.
//
// This software is the confidential and proprietary information of FLIR
// Integrated Imaging Solutions, Inc. ("Confidential Information"). You
// shall not disclose such Confidential Information and shall use it only in
// accordance with the terms of the license agreement you entered into
// with FLIR Integrated Imaging Solutions, Inc. (FLIR).
//
// FLIR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
// SOFTWARE, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE, OR NON-INFRINGEMENT. FLIR SHALL NOT BE LIABLE FOR ANY DAMAGES
// SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
// THIS SOFTWARE OR ITS DERIVATIVES.
//=============================================================================
#ifndef FLIR_SPINNAKER_MANAGED_SYSTEM_EVENT_H
#define FLIR_SPINNAKER_MANAGED_SYSTEM_EVENT_H
#include "ManagedEventHandler.h"
#include "ManagedInterface.h"
#include "SystemEventHandler.h"
#include <vcclr.h>
using namespace ::System;
namespace SpinnakerNET
{
// forward declaration
ref class ManagedSystemEvent;
// Intermediate delegate and function pointer for InterfaceArrivalEvent
delegate void OnInterfaceArrivalDelegate(Spinnaker::InterfacePtr);
typedef void(__stdcall *OnInterfaceArrivalNative)(Spinnaker::InterfacePtr);
// Intermediate delegate and function pointer for InterfaceRemovalEvent
delegate void OnInterfaceRemovalDelegate(Spinnaker::InterfacePtr);
typedef void(__stdcall *OnInterfaceRemovalNative)(Spinnaker::InterfacePtr);
// We declare an intermediate class which inherits from SystemEvent (unmanaged abstract class).
// We provide definitions for the virtual functions. These functions are the callbacks that
// will be called from the unmanaged library. These functions call into the managed abstract
// class.
class SystemEventRedirector : public Spinnaker::SystemEventHandler
{
public:
SystemEventRedirector(OnInterfaceArrivalDelegate^ delegate1, OnInterfaceRemovalDelegate^ delegate2)
{
// Assign delegates
m_OnInterfaceArrivalDelegate = delegate1;
m_OnInterfaceRemovalDelegate = delegate2;
// Fetch function pointers.
m_OnInterfaceArrivalNative = (OnInterfaceArrivalNative)Marshal::GetFunctionPointerForDelegate(m_OnInterfaceArrivalDelegate).ToPointer();
m_OnInterfaceRemovalNative = (OnInterfaceRemovalNative)Marshal::GetFunctionPointerForDelegate(m_OnInterfaceRemovalDelegate).ToPointer();
}
protected:
virtual void OnInterfaceArrival(Spinnaker::InterfacePtr);
virtual void OnInterfaceRemoval(Spinnaker::InterfacePtr);
private:
gcroot<OnInterfaceArrivalDelegate^> m_OnInterfaceArrivalDelegate;
OnInterfaceArrivalNative m_OnInterfaceArrivalNative;
gcroot<OnInterfaceRemovalDelegate^> m_OnInterfaceRemovalDelegate;
OnInterfaceRemovalNative m_OnInterfaceRemovalNative;
};
// Managed abstract interface event base class
// The event callbacks, ie. On<Event>() functions will be called via the internal
// CallOn<Event>() calls.
public ref class ManagedSystemEventHandler abstract : public ManagedEventHandler
{
public:
ManagedSystemEventHandler();
~ManagedSystemEventHandler();
!ManagedSystemEventHandler();
protected:
// Empty body so user can override only the one's they need
virtual void OnInterfaceArrival(IManagedInterface^ /*iface*/) {};
virtual void OnInterfaceRemoval(IManagedInterface^ /*iface*/) {};
internal:
void CallOnInterfaceArrival(Spinnaker::InterfacePtr);
void CallOnInterfaceRemoval(Spinnaker::InterfacePtr);
};
}
#endif // FLIR_SPINNAKER_MANAGED_SYSTEM_EVENT_H