Skip to content

pylon/PylonVersionInfo.h#

Contains the VersionInfo class, which is a utility for comparing version numbers.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::VersionInfo
Holds a four-part version number consisting of major.minor.subminor.build.

Source code#

//-----------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2009-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  JS
//-----------------------------------------------------------------------------
#ifndef INCLUDED_PYLONVERSIONINFO_H_3453485
#define INCLUDED_PYLONVERSIONINFO_H_3453485

#include <pylon/Platform.h>

#ifdef _MSC_VER
#   pragma pack(push, PYLON_PACKING)
#endif /* _MSC_VER */

#include <pylon/PylonBase.h>

namespace Pylon
{

    class VersionInfo
    {
    public:
        explicit VersionInfo( bool checkBuild = false )
            : m_major( 0 )
            , m_minor( 0 )
            , m_subminor( 0 )
            , m_build( 0 )
            , m_checkBuild( checkBuild )
        {
            Pylon::GetPylonVersion( &m_major, &m_minor, &m_subminor, &m_build );
        }


        VersionInfo( unsigned int major,
                     unsigned int minor,
                     unsigned int subminor )
            : m_major( major )
            , m_minor( minor )
            , m_subminor( subminor )
            , m_build( 0 )
            , m_checkBuild( false )
        {
        }


        VersionInfo( unsigned int major,
                     unsigned int minor,
                     unsigned int subminor,
                     unsigned int build )
            : m_major( major )
            , m_minor( minor )
            , m_subminor( subminor )
            , m_build( build )
            , m_checkBuild( true )
        {
        }


        ~VersionInfo( void )
        {
        }

    public:
        static const char* getVersionString()
        {
            return Pylon::GetPylonVersionString();
        }


        unsigned int getMajor() const
        {
            return m_major;
        }


        unsigned int getMinor() const
        {
            return m_minor;
        }


        unsigned int getSubminor() const
        {
            return m_subminor;
        }


        unsigned int getBuild() const
        {
            return m_build;
        }

    public:
        bool operator > ( const VersionInfo& rhs ) const
        {
            bool res = (m_major > rhs.m_major)
                || (m_major == rhs.m_major && m_minor > rhs.m_minor)
                || (m_major == rhs.m_major && m_minor == rhs.m_minor && m_subminor > rhs.m_subminor)
                || (m_major == rhs.m_major && m_minor == rhs.m_minor && m_subminor == rhs.m_subminor && m_checkBuild && m_build > rhs.m_build);

            return res;
        }


        bool operator == ( const VersionInfo& rhs ) const
        {
            // use the reverse order to save some executiontime ;-)
            bool res( (m_checkBuild ? (m_build == rhs.m_build) : true)
                      && (m_subminor == rhs.m_subminor)
                      && (m_minor == rhs.m_minor)
                      && (m_major == rhs.m_major) );
            return res;
        }


        bool operator >= ( const VersionInfo& rhs ) const
        {
            bool res = (*this > rhs) || (*this == rhs);
            return res;
        }


        bool operator < ( const VersionInfo& rhs ) const
        {
            bool res = !(*this >= rhs);
            return res;
        }


        bool operator != ( const VersionInfo& rhs ) const
        {
            bool res = !(*this == rhs);
            return res;
        }


        bool operator <= ( const VersionInfo& rhs ) const
        {
            bool res = !(*this > rhs);
            return res;
        }

    protected:
        unsigned int    m_major;
        unsigned int    m_minor;
        unsigned int    m_subminor;
        unsigned int    m_build;
        bool            m_checkBuild;
    };
}

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

#endif /* INCLUDED_PYLONVERSIONINFO_H_3453485 */

Updated on 5 July 2022 at 15:30:01