pylon/EnumParameterT.h#
Namespaces#
Name |
---|
Pylon Contains definitions of pylon types. |
Classes#
Name | |
---|---|
struct | Pylon::IEnumParameterT A template class that is used to create classes derived from CEnumParameter. |
class | Pylon::CEnumParameterT |
Detailed Description#
Contains a template class that is used to create classes derived from CEnumParameter.
The derived classes use C++ enums instead of strings as enumeration values. They are used for native parameter access.
Source code#
//------------------------------------------------------------------------------
// Basler pylon SDK
// Copyright (c) 2018-2022 Basler AG
// http://www.baslerweb.com
//------------------------------------------------------------------------------
#ifndef INCLUDED_BASLER_PYLON_CENUMPARAMETERT_H
#define INCLUDED_BASLER_PYLON_CENUMPARAMETERT_H
#pragma once
#include <pylon/EnumParameter.h>
#ifdef _MSC_VER
# pragma pack(push, PYLON_PACKING)
#endif /* _MSC_VER */
#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class.
#pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance
#endif
namespace Pylon
{
template<typename EnumT>
interface IEnumParameterT : virtual public IEnumerationEx
{
public:
using IEnumerationEx::SetValue;
using IEnumerationEx::TrySetValue;
using IEnumerationEx::GetValueOrDefault;
using IEnumerationEx::CanSetValue;
using IEnumeration::operator=;
virtual void SetValue( EnumT value, bool verify = true ) = 0;
virtual IEnumParameterT<EnumT>& operator=( EnumT value ) = 0;
virtual EnumT GetValue( bool verify = false, bool ignoreCache = false ) = 0;
virtual EnumT operator()() = 0;
virtual GenApi::IEnumEntry* GetEntry( const EnumT value ) = 0;
virtual EnumT GetValueOrDefault( EnumT defaultValue ) = 0;
virtual bool TrySetValue( EnumT value ) = 0;
virtual bool CanSetValue( EnumT value ) = 0;
};
// A template class that is used to create classes derived from CEnumParameter.
template<typename EnumT>
class CEnumParameterT : public CEnumParameter, virtual public IEnumParameterT<EnumT>
{
public:
using IEnumeration::operator=;
CEnumParameterT()
{
}
CEnumParameterT( GenApi::INode* pNode )
: CEnumParameter( pNode )
{
}
using CEnumParameter::SetValue;
// Implements IEnumParameterT<EnumT>
virtual void SetValue( EnumT value, bool verify = true )
{
SetValue( GetTable(), static_cast<size_t>(value), verify );
}
// Implements IEnumParameterT<EnumT>
virtual CEnumParameterT<EnumT>& operator=( EnumT value )
{
SetValue( value );
return *this;
}
// Implements IEnumParameterT<EnumT>
virtual EnumT GetValue( bool verify = false, bool ignoreCache = false )
{
EnumT result = static_cast<EnumT>(CEnumParameter::GetValue( GetTable(), verify, ignoreCache ));
return result;
}
// Implements IEnumParameterT<EnumT>
virtual EnumT operator()()
{
EnumT result = GetValue();
return result;
}
// Implements IEnumParameterT<EnumT>
virtual GenApi::IEnumEntry* GetEntry( const EnumT value )
{
GenApi::IEnumEntry* result = CEnumParameter::GetEntry( GetTable(), static_cast<size_t>(value) );
return result;
}
// Implements IEnumParameterT<EnumT>
virtual EnumT GetValueOrDefault( EnumT defaultValue )
{
if (this->IsReadable())
{
EnumT result = GetValue();
return result;
}
return defaultValue;
}
// Implements IEnumParameterT<EnumT>
virtual bool TrySetValue( EnumT value )
{
if (this->IsWritable() && CEnumParameter::CanSetValue( GetTable(), static_cast<size_t>(value) ))
{
SetValue( value );
return true;
}
return false;
}
// Implements IEnumParameterT<EnumT>
virtual bool CanSetValue( EnumT value )
{
bool result = CEnumParameter::CanSetValue( GetTable(), static_cast<size_t>(value) );
return result;
}
protected:
// Must be provided by the specific enum instance class
virtual const Table_t& GetTable() const = 0;
};
}
#ifdef _MSC_VER
#pragma warning( pop )
#endif
#ifdef _MSC_VER
# pragma pack(pop)
#endif /* _MSC_VER */
#endif /* INCLUDED_BASLER_PYLON_CENUMPARAMETERT_H */
Updated on 5 July 2022 at 15:30:01