50 lines
1.9 KiB
C++

//======================================================================================================
// Copyright 2016, NaturalPoint Inc.
//======================================================================================================
#pragma once
#include "AnalogSystemBuildConfig.h"
#include "PluginDeviceBase.h"
namespace AnalogSystem
{
template <class T> class AnalogFrame;
/// <summary>
/// cPluginDevice is a type-specific implementation of a Plugin Device.
/// It provides type specific frame allocation and frame buffer access.
/// See Plugin Device SDK for example implementation
/// </summary>
template <typename T>
class cPluginDevice : public cPluginDeviceBase
{
public:
cPluginDevice() : cPluginDeviceBase()
{
mDataSize = sizeof( T );
}
/// <summary>Gets a pointer to next slot in the device's data buffer to write data into</summary>
/// <param name="frameID">The device frame ID the device will associate with this slot</param>
AnalogFrame<T>* BeginFrameUpdate( long frameID, bool wait = true ) override
{
return dynamic_cast<AnalogFrame<T>*>( __super::BeginFrameUpdate( frameID, wait ) );
}
/// <summary>Gets the frame by device frame identifier.</summary>
/// <param name="frameID">The device frame ID</param>
const AnalogFrame<T>* GetFrameByDeviceFrameID( long frameID ) const override
{
return dynamic_cast<const AnalogFrame<T>*>( __super::GetFrameByDeviceFrameID( frameID ) );
}
protected:
/// <summary>Allocates a frame in the plugin's memory context</summary>
/// <param name="channelCount">The channel count</param>
virtual AnalogFrame<T>* AllocateFrame( int channelCount ) override
{
return new AnalogFrame<T>( channelCount );
}
};
}