Skip to content

pylon/EnumParameter.h#

Contains the class CEnumParameter used to simplify access to GenApi parameters.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
struct Pylon::IEnumerationEx
Extends the GenApi::IEnumeration interface with convenience methods.
class Pylon::CEnumParameter
CEnumParameter class used to simplify access to GenApi parameters.
class Pylon::CEnumParameter::TableItem_t
class Pylon::CEnumParameter::Table_t

Source code#

//------------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2018-2022 Basler AG
//  http://www.baslerweb.com
//------------------------------------------------------------------------------
#ifndef INCLUDED_BASLER_PYLON_CENUMPARAMETER_H
#define INCLUDED_BASLER_PYLON_CENUMPARAMETER_H

#pragma once

#include <pylon/PylonBase.h>
#include <GenApi/IEnumeration.h>
#include <pylon/Parameter.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
{
    interface IEnumerationEx : virtual public GenApi::IEnumeration, virtual public IValueEx
    {
        using GenApi::IEnumeration::operator=;

        virtual String_t GetValueOrDefault( const String_t& defaultValue ) = 0;


        virtual bool TrySetValue( const String_t& value ) = 0;


        virtual void SetValue( const char** nullTerminatedList ) = 0;


        virtual bool TrySetValue( const char** nullTerminatedList ) = 0;


        virtual bool CanSetValue( const String_t& value ) = 0;


        virtual void SetValue( const String_t& value ) = 0;


        virtual String_t GetValue() = 0;


        virtual void GetSettableValues( GenApi::StringList_t& values ) = 0;


        virtual void GetAllValues( GenApi::StringList_t& values ) = 0;


        virtual CParameter GetEntryByNameAsParameter( const GenICam::gcstring& value ) = 0;


        virtual CParameter GetCurrentEntryAsParameter() = 0;
    };


    class PYLONBASE_API CEnumParameter : virtual public IEnumerationEx, public CParameter
    {
    public:
        CEnumParameter();


        explicit CEnumParameter( GenApi::INode* pNode );


        explicit CEnumParameter( GenApi::IEnumeration* pEnumeration );


        CEnumParameter( GenApi::INodeMap* pNodeMap, const char* pName );


        CEnumParameter( GenApi::INodeMap& nodeMap, const char* pName );


        CEnumParameter( const CEnumParameter& rhs );


        virtual ~CEnumParameter();


        virtual bool Attach( GenApi::INodeMap* pNodeMap, const char* pName );


        virtual bool Attach( GenApi::INodeMap& nodeMap, const char* pName );


        virtual bool Attach( GenApi::INode* pNode );


        virtual bool Attach( GenApi::IEnumeration* pEnumeration );


        CEnumParameter& operator=( const CEnumParameter& rhs );


        virtual bool Equals( const CEnumParameter& rhs ) const;


        virtual bool Equals( const GenApi::INode* pNode ) const;


        virtual bool Equals( const GenApi::IEnumeration* pEnumeration ) const;


        virtual void Release();


        // Implements IValueEx
        virtual bool IsValid() const;


        // Implements GenApi::IEnumeration
        virtual void GetSymbolics( GenApi::StringList_t& symbolics );

        // Implements GenApi::IEnumeration
        virtual void GetEntries( GenApi::NodeList_t& entries );

        // Implements GenApi::IEnumeration
        virtual GenApi::IEnumeration& operator=( const GenICam::gcstring& valueStr );

        // Implements GenApi::IEnumeration
        virtual void SetIntValue( int64_t value, bool verify = true );

        // Implements GenApi::IEnumeration
        virtual GenICam::gcstring operator*();

        // Implements GenApi::IEnumeration
        virtual int64_t GetIntValue( bool verify = false, bool ignoreCache = false );

        // Implements GenApi::IEnumeration
        virtual GenApi::IEnumEntry* GetEntryByName( const GenICam::gcstring& symbolic );

        // Implements GenApi::IEnumeration
        virtual GenApi::IEnumEntry* GetEntry( const int64_t intValue );

        // Implements GenApi::IEnumeration
        virtual GenApi::IEnumEntry* GetCurrentEntry( bool verify = false, bool ignoreCache = false );


        // Implements IEnumerationEx
        virtual String_t GetValueOrDefault( const String_t& defaultValue );

        // Implements IEnumerationEx
        virtual bool TrySetValue( const String_t& value );

        // Implements IEnumerationEx
        virtual void SetValue( const char** nullTerminatedList );

        // Implements IEnumerationEx
        virtual bool TrySetValue( const char** nullTerminatedList );

        // Implements IEnumerationEx
        virtual bool CanSetValue( const String_t& value );

        // Implements IEnumerationEx
        virtual void SetValue( const String_t& value );

        // Implements IEnumerationEx
        virtual String_t GetValue();

        // Implements IEnumerationEx
        virtual void GetSettableValues( GenApi::StringList_t& values );

        // Implements IEnumerationEx
        virtual void GetAllValues( GenApi::StringList_t& values );

        // Implements IEnumerationEx
        virtual CParameter GetEntryByNameAsParameter( const GenICam::gcstring& value );

        // Implements IEnumerationEx
        virtual CParameter GetCurrentEntryAsParameter();


    public:
        // Start - For using C++ enums instead of strings as enumeration values (native parameter access)
        class TableItem_t
        {
        public:
            TableItem_t()
                : m_szName( "" )
                , m_sizeOfName( 0 )
            {
            }

            TableItem_t( const char* name, size_t size )
                : m_szName( name )
                , m_sizeOfName( size )
            {
            }

            inline const char* GetName() const
            {
                return m_szName;
            }

            inline size_t GetSizeOfName() const
            {
                return m_sizeOfName;
            }
        private:
            const char* m_szName;
            size_t m_sizeOfName;
        };
        class Table_t
        {
        public:
            Table_t()
                : m_items( 0 )
                , m_tableSize( 0 )
            {
            }

            Table_t( const TableItem_t* items, size_t tableSize )
                : m_items( items )
                , m_tableSize( tableSize )
            {
            }

            inline const TableItem_t* GetItems() const
            {
                return m_items;
            }

            inline size_t GetSizeOfTable() const
            {
                return m_tableSize;
            }
        private:
            const TableItem_t* m_items;
            size_t m_tableSize;
        };
    protected:
        void SetValue( const Table_t& table, size_t index, bool verify );
        size_t /*index*/ GetValue( const Table_t& table, bool verify, bool ignoreCache );
        GenApi::IEnumEntry* GetEntry( const Table_t& table, size_t index );
        bool CanSetValue( const Table_t& table, size_t index );
        // End - For using C++ enums instead of strings as enumeration values (native parameter access)

    protected:
        GenApi::IEnumeration* m_pFeature;
    };
}
#ifdef _MSC_VER
#   pragma warning( pop )
#endif

#ifdef _MSC_VER
#   pragma pack(pop)
#endif /* _MSC_VER */

#endif /* INCLUDED_BASLER_PYLON_CENUMPARAMETER_H */

Updated on 5 July 2022 at 15:30:01