Skip to content

pylon/StreamGrabberProxy.h#

Low Level API: Pylon generic stream grabber interface declaration.

Namespaces#

Name
Pylon
Contains definitions of pylon types.

Classes#

Name
class Pylon::CStreamGrabberProxyT
Low Level API: The stream grabber class with parameter access methods.

Defines#

Name
PYLON_DEFINE_STREAMGRABBER(ClassName, BaseClass)
Macro to define a custom Node map proxy.

Macros Documentation#

define PYLON_DEFINE_STREAMGRABBER#

#define PYLON_DEFINE_STREAMGRABBER(
    ClassName,
    BaseClass
)
class ClassName : public BaseClass \
    { \
    public: \
        /** \name Construction */ \
        /*@{*/ \
        /** \brief \copybrief Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT()
            \copydetails Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT()
        */ \
            ClassName() \
        { \
        } \
              /** \brief \copybrief Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT(Pylon::IStreamGrabber*)
              \copydetails Pylon::CStreamGrabberProxyT::CStreamGrabberProxyT(Pylon::IStreamGrabber*)
              */ \
            ClassName( IStreamGrabber* pStreamGrabber ) : BaseClass( pStreamGrabber ) \
        { \
        } \
            /*@}*/ \
    };

Macro to define a custom Node map proxy.

Source code#

//-----------------------------------------------------------------------------
//  Basler pylon SDK
//  Copyright (c) 2007-2022 Basler AG
//  http://www.baslerweb.com
//  Author:  AH
//-----------------------------------------------------------------------------
#ifndef __PYLON_STREAMGRABBERPROXY__H__
#define __PYLON_STREAMGRABBERPROXY__H__

#if _MSC_VER > 1000
#pragma once
#endif

#include <pylon/Platform.h>

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

#include <Base/GCException.h>
#include <pylon/StreamGrabber.h>
#include "NodeMapProxy.h"


#define PYLON_DEFINE_STREAMGRABBER(ClassName, BaseClass) \
    class ClassName : public BaseClass \
    { \
    public: \
 \
 \
 \
            ClassName() \
        { \
        } \
 \
            ClassName( IStreamGrabber* pStreamGrabber ) : BaseClass( pStreamGrabber ) \
        { \
        } \
 \
    };


    namespace Pylon
    {
        //**************************************************************************************************

        //**************************************************************************************************
        template<class TParams>
        class CStreamGrabberProxyT : public CNodeMapProxyT<TParams>
        {
        public:
            // \{

            CStreamGrabberProxyT();

            CStreamGrabberProxyT( Pylon::IStreamGrabber* );

            virtual ~CStreamGrabberProxyT();

            //\}


        private:
            // \{
            CStreamGrabberProxyT( const CStreamGrabberProxyT& );
            CStreamGrabberProxyT& operator=( const CStreamGrabberProxyT& );
            // \}


        public:
            // \{

            virtual void Attach( IStreamGrabber* );

            virtual bool IsAttached() const;

            virtual IStreamGrabber* GetStreamGrabber() const;

            // \}


        public:
            // \{

            void Open()
            {
                CheckPtr();
                m_pStreamGrabber->Open();
            }

            void Close()
            {
                CheckPtr();
                m_pStreamGrabber->Close();
            }

            bool IsOpen() const
            {
                CheckPtr();
                return m_pStreamGrabber->IsOpen();
            }

            StreamBufferHandle RegisterBuffer( void* pBuffer, size_t bufferSize )
            {
                CheckPtr();
                return m_pStreamGrabber->RegisterBuffer( pBuffer, bufferSize );
            }

            const void* DeregisterBuffer( StreamBufferHandle hStreamBuffer )
            {
                CheckPtr();
                return m_pStreamGrabber->DeregisterBuffer( hStreamBuffer );
            }

            void PrepareGrab()
            {
                CheckPtr();
                m_pStreamGrabber->PrepareGrab();
            }

            bool IsStartAndStopStreamingMandatory()
            {
                CheckPtr();
                return m_pStreamGrabber->IsStartAndStopStreamingMandatory();
            }

            void StartStreamingIfMandatory()
            {
                CheckPtr();
                m_pStreamGrabber->StartStreamingIfMandatory();
            }

            void StopStreamingIfMandatory()
            {
                CheckPtr();
                m_pStreamGrabber->StopStreamingIfMandatory();
            }

            void FinishGrab()
            {
                CheckPtr();
                m_pStreamGrabber->FinishGrab();
            }

            void QueueBuffer( StreamBufferHandle hStreamBuffer, const void* pContext = NULL )
            {
                CheckPtr();
                m_pStreamGrabber->QueueBuffer( hStreamBuffer, pContext );
            }

            void FlushBuffersToOutput()
            {
                CheckPtr();
                m_pStreamGrabber->FlushBuffersToOutput();
            }

            // undocumented, deprecated
            void CancelGrab()
            {
                CheckPtr();
                m_pStreamGrabber->FlushBuffersToOutput();
            }

            bool RetrieveResult( GrabResult& Result )
            {
                CheckPtr();
                return m_pStreamGrabber->RetrieveResult( Result );
            }

            WaitObject& GetWaitObject() const
            {
                CheckPtr();
                return m_pStreamGrabber->GetWaitObject();
            }

            GenApi::INodeMap* GetNodeMap()
            {
                CheckPtr();
                return m_pStreamGrabber->GetNodeMap();
            }

            // \}


        protected:
            void CheckPtr() const
            {
                if (NULL == m_pStreamGrabber)
                {
                    throw LOGICAL_ERROR_EXCEPTION( "The stream grabber class is not attached to a pylon stream grabber" );
                }
            }

            IStreamGrabber* m_pStreamGrabber;
        };


        //**************************************************************************************************
        // CStreamGrabberProxyT implementation
        //**************************************************************************************************

        template<class TParams>
        inline CStreamGrabberProxyT<TParams>::CStreamGrabberProxyT()
            : CNodeMapProxyT<TParams>(), m_pStreamGrabber( NULL )
        {
        }

        template<class TParams>
        inline CStreamGrabberProxyT<TParams>::CStreamGrabberProxyT( IStreamGrabber* pStreamGrabber )
            : CNodeMapProxyT<TParams>(), m_pStreamGrabber( NULL )
        {
            Attach( pStreamGrabber );
        }

        template<class TParams>
        inline CStreamGrabberProxyT<TParams>::~CStreamGrabberProxyT( void )
        {
        }

        template<class TParams>
        inline void CStreamGrabberProxyT<TParams>::Attach( IStreamGrabber* pStreamGrabber )
        {
            if (IsAttached())
            {
                throw LOGICAL_ERROR_EXCEPTION( "Object is already attached to a stream grabber" );
            }

            if (NULL == pStreamGrabber)
            {
                throw LOGICAL_ERROR_EXCEPTION( "Tried to attach a NULL pointer as stream grabber" );
            }

            CNodeMapProxyT<TParams>::Attach( pStreamGrabber->GetNodeMap() );
            m_pStreamGrabber = pStreamGrabber;
        }

        template<class TParams>
        inline bool CStreamGrabberProxyT<TParams>::IsAttached() const
        {
            return NULL != m_pStreamGrabber;
        }

        template<class TParams>
        inline IStreamGrabber* CStreamGrabberProxyT<TParams>::GetStreamGrabber() const
        {
            return m_pStreamGrabber;
        }

    } // namespace Pylon

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

#endif

Updated on 5 July 2022 at 15:30:01