pylon/PixelTypeMapper.h#
Namespaces#
Name |
---|
Pylon Contains definitions of pylon types. |
Classes#
Name | |
---|---|
class | Pylon::CPixelTypeMapper A simple pixeltypemapper (maps device specific pixelformats read from device-node map to pylon pixeltypes by their name). |
class | Pylon::CCameraPixelTypeMapperT A camera specific pixeltypemapper (maps device specific pixelformats contained in the generated camera classes to pylon pixeltypes by their name). |
Source code#
//-----------------------------------------------------------------------------
// Basler pylon SDK
// Copyright (c) 2010-2022 Basler AG
// http://www.baslerweb.com
// Author: JS
//-----------------------------------------------------------------------------
#ifndef PYLON_PIXEL_TYPE_MAPPER_H_INCLUDED_
#define PYLON_PIXEL_TYPE_MAPPER_H_INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif
#include <pylon/Platform.h>
#ifdef _MSC_VER
# pragma pack(push, PYLON_PACKING)
#endif /* _MSC_VER */
#include <GenApi/IEnumerationT.h>
#include <pylon/PylonBase.h>
#include <pylon/PixelType.h>
namespace Pylon
{
class CPixelTypeMapperImpl;
enum SFNCVersion
{
SFNCVersion_Invalid = 0,
SFNCVersion_pre2_0 = 1,
SFNCVersion_2_0 = 200
// if you ad entries here you must change GetStartIndexForSFNC accordingly
};
// -------------------------------------------------------------------------
// class CPixelTypeMapper
// -------------------------------------------------------------------------
class PYLONBASE_API CPixelTypeMapper
{
public:
CPixelTypeMapper( void );
explicit CPixelTypeMapper( GenApi::IEnumeration* pEnum );
virtual ~CPixelTypeMapper( void );
public:
bool IsValid() const;
void SetPixelFormatEnumNode( GenApi::IEnumeration* pEnum );
public:
EPixelType GetPylonPixelTypeFromNodeValue( int64_t nodeValue ) const;
public:
static EPixelType GetPylonPixelTypeByName( const char* pszSymbolicName );
static EPixelType GetPylonPixelTypeByName( const String_t& symbolicName )
{
return GetPylonPixelTypeByName( symbolicName.c_str() );
}
static const char* GetNameByPixelType( EPixelType pixelType, SFNCVersion sfncVer = SFNCVersion_pre2_0 );
private:
CPixelTypeMapperImpl* m_pImpl;
};
// -------------------------------------------------------------------------
// class CCameraPixelTypeMapperT
// -------------------------------------------------------------------------
template <typename EnumT>
class CCameraPixelTypeMapperT : protected CPixelTypeMapper
{
public:
CCameraPixelTypeMapperT( void )
: m_pEnumT( NULL )
{
}
explicit CCameraPixelTypeMapperT( GenApi::IEnumerationT<EnumT>* pEnumT )
: m_pEnumT( NULL )
{
SetPixelFormatEnumNode( pEnumT );
}
virtual ~CCameraPixelTypeMapperT( void )
{
m_pEnumT = NULL;
}
public:
bool IsValid() const
{
return m_pEnumT != NULL && CPixelTypeMapper::IsValid();
}
void SetPixelFormatEnumNode( GenApi::IEnumerationT<EnumT>* pEnumT )
{
// remember a reference to the EnumerationT node. Needed for enum->nodeValue lookup
m_pEnumT = pEnumT;
if (pEnumT != NULL)
{
CPixelTypeMapper::SetPixelFormatEnumNode( pEnumT );
}
else
{
CPixelTypeMapper::SetPixelFormatEnumNode( NULL );
}
}
public:
EPixelType GetPylonPixelTypeFromPixelFormatEnum( EnumT pixelFormatEnumValue ) const
{
if (!IsValid())
{
throw RUNTIME_EXCEPTION( "SetPixelFormatEnumNode not called." );
}
EPixelType pt = PixelType_Undefined;
GenApi::IEnumEntry* pE = m_pEnumT->GetEntry( pixelFormatEnumValue );
if (pE != NULL)
{
pt = CPixelTypeMapper::GetPylonPixelTypeFromNodeValue( pE->GetValue() );
}
return pt;
}
public:
static EPixelType GetPylonPixelTypeByName( const char* pszSymbolicName )
{
return CPixelTypeMapper::GetPylonPixelTypeByName( pszSymbolicName );
}
static EPixelType GetPylonPixelTypeByName( const String_t& symbolicName )
{
return CPixelTypeMapper::GetPylonPixelTypeByName( symbolicName.c_str() );
}
static const char* GetNameByPixelType( EPixelType pixelType, SFNCVersion sfncVer = SFNCVersion_pre2_0 )
{
return CPixelTypeMapper::GetNameByPixelType( pixelType, sfncVer );
}
private:
GenApi::IEnumerationT<EnumT>* m_pEnumT;
};
}
#ifdef _MSC_VER
# pragma pack(pop)
#endif /* _MSC_VER */
#endif // #ifndef PYLON_PIXEL_TYPE_MAPPER_H_INCLUDED_
Updated on 5 July 2022 at 15:30:01