File ManagedEventHandler.h¶
File List > SpinnakerNET > ManagedEventHandler.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_EVENT_HANDLER_H
#define FLIR_SPINNAKER_MANAGED_EVENT_HANDLER_H
#include "EventHandler.h"
#include <vcclr.h>
using namespace ::System;
namespace SpinnakerNET
{
public ref class ManagedEventHandler abstract
{
public:
UINT32 GetEventPayloadDataSize()
{
if (m_pNativeEvent != nullptr)
{
#pragma warning(push)
#pragma warning(disable : 4996)
Spinnaker::DeviceEventHandler* deviceEvent = dynamic_cast<Spinnaker::DeviceEventHandler*>(m_pNativeEvent);
if (deviceEvent == nullptr)
{
return 0;
}
return (UINT32)deviceEvent->GetEventPayloadDataSize();
#pragma warning(pop)
}
else
{
return 0;
}
};
array<byte>^ GetEventPayloadData()
{
if (m_pNativeEvent != nullptr)
{
#pragma warning(push)
#pragma warning(disable : 4996)
Spinnaker::DeviceEventHandler* deviceEvent = dynamic_cast<Spinnaker::DeviceEventHandler*>(m_pNativeEvent);
if (deviceEvent == nullptr)
{
return nullptr;
}
UINT32 DataSize = GetEventPayloadDataSize();
if (DataSize == 0)
{
return nullptr;
}
// Create managed array
array<byte>^ buffer = gcnew array<Byte>(DataSize);
// Get native pointer to data
const uint8_t* data = deviceEvent->GetEventPayloadData();
void* newData = (void*)data;
// Copy native data to managed space
Marshal::Copy(IntPtr(newData), buffer, 0, DataSize);
newData = 0;
// Return managed array
return buffer;
#pragma warning(pop)
}
else
{
return nullptr;
}
};
internal:
Spinnaker::EventHandler* m_pNativeEvent;
};
}
#endif // FLIR_SPINNAKER_MANAGED_EVENT_HANDLER_H