Files
2024-05-18 23:53:26 +08:00

134 lines
4.6 KiB
C++

/**
* @file KglBuffer.h
*
* Copyright (c) 2019 Keyence Corporation.
* All rights reserved.
*
*/
#pragma once
#include <stdint.h>
#include <KglDefine.h>
#include <KglResult.h>
namespace Keyence
{
//-------------------------------------------------------------------------
namespace Impl
{
class KglStreamImpl;
class KglBufferImpl;
};
//------------------------------------------------------------
/**
* \~English @brief Buffer for receiving data sent from the camera.
* \~Japanese @brief カメラから送信されたデータを受け取るためのバッファです。
*/
class KGLLIB_API KglBuffer
{
public:
friend class Impl::KglBufferImpl;
friend class Impl::KglStreamImpl;
//-------------------------------------------------------------------------
/**
* @brief \~English Constructor
* @brief \~Japanese コンストラクタ。
*/
KglBuffer();
//-------------------------------------------------------------------------
/**
* @brief \~English Destructor.
* @brief \~Japanese デストラクタ。
*/
~KglBuffer();
//------------------------------------------------------------
/**
* \~English @brief Allocates memory to this buffer.
* \~Japanese @brief メモリを確保してこのバッファに割り当てます。
* \~English @param [in] size Memory size (in bytes).
* \~Japanese @param [in] size メモリサイズ(バイト単位)。
* \~English @retval KGL_SUCCESS Success.
* \~Japanese @retval KGL_SUCCESS 成功。
* \~English @retval KGL_NOT_ENOUGH_MEMORY Allocation failed due to insufficient memory.
* \~Japanese @retval KGL_NOT_ENOUGH_MEMORY メモリ不足のためにアロケート失敗しました。
* \~English @retval KGL_GENERIC_ERROR An unexpected error has occurred.
* \~Japanese @retval KGL_GENERIC_ERROR 予期せぬエラーが発生しました。
*/
KglResult allocate(uint32_t size);
//------------------------------------------------------------
/**
* \~English @brief Release the allocated memory area.
* \~Japanese @brief 確保されたメモリ領域を解放します。
*/
void free();
//------------------------------------------------------------
/**
* \~English @brief Allocates to this buffer the memory allocated outside KglBuffer.
* \~Japanese @brief KglBuffer外で確保したメモリをこのバッファへ割り当てます。
* \~English @param [in] pBuffer Pointer to the buffer.
* \~Japanese @param [in] pBuffer バッファのポインタ。
* \~English @param [in] size Memory size (in bytes).
* \~Japanese @param [in] size メモリサイズ(バイト単位)。
* \~English @retval KGL_SUCCESS Success.
* \~Japanese @retval KGL_SUCCESS 成功。
* \~English @retval KGL_ERR_INVALID_PARAMETER An invalid parameter.
* \~Japanese @retval KGL_ERR_INVALID_PARAMETER 不正なパラメータです。
* \~English @retval KGL_GENERIC_ERROR An unexpected error has occurred.
* \~Japanese @retval KGL_GENERIC_ERROR 予期せぬエラーが発生しました。
*/
KglResult attach(void* pBuffer, uint32_t size);
//------------------------------------------------------------
/**
* \~English @brief Detaches the attached buffer.
* \~Japanese @brief アタッチされたバッファをデタッチします。
* \~English @retval KGL_SUCCESS Success.
* \~Japanese @retval KGL_SUCCESS 成功。
* \~English @retval KGL_GENERIC_ERROR An unexpected error has occurred.
* \~Japanese @retval KGL_GENERIC_ERROR 予期せぬエラーが発生しました。
*/
KglResult detach();
//------------------------------------------------------------
/**
* \~English @brief Returns the size of the buffer (bytes) allocated or attached.
* \~Japanese @brief アロケートあるいはアタッチされたバッファのサイズ(bytes)を返します。
* \~English @return Size (in bytes).
* \~Japanese @return サイズ(バイト単位)。
*/
uint32_t getSize() const;
//------------------------------------------------------------
/**
* \~English @brief Returns the size of the received data (bytes).
* \~Japanese @brief 受信したデータのサイズ(bytes)を返します。
* \~English @return Size (in bytes).
* \~Japanese @return サイズ(バイト単位)。
*/
uint32_t getAcquiredSize() const;
//------------------------------------------------------------
/**
* \~English @brief Retrieves the pointer to the buffer.
* \~Japanese @brief バッファのポインタを取得します。
*
* \~English @return A pointer to the buffer.
* \~Japanese @return バッファのデータへのポインタ。
*/
uint8_t* getDataPointer();
private:
Impl::KglBufferImpl* _pImpl;
};
}; //end of namespace Keyence