123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- //-----------------------------------------------------------------------------
- // Basler pylon SDK
- // Copyright (c) 2007-2021 Basler AG
- // http://www.baslerweb.com
- // Author: AH
- //-----------------------------------------------------------------------------
- /*!
- \file
- \brief Low Level API: Pylon generic stream grabber interface declaration
- */
- #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"
- //! Macro to define a custom Node map proxy
- #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 ) \
- { \
- } \
- /*@}*/ \
- };
- namespace Pylon
- {
- //**************************************************************************************************
- //! Low Level API: The stream grabber class with parameter access methods
- /**
- This is the base class for pylon stream grabber providing access to configuration parameters.
- \see \ref configuringcameras
- \tparam TParams The specific parameter class (auto generated from the parameter xml file)
- \ingroup Pylon_LowLevelApi
- */
- //**************************************************************************************************
- template<class TParams>
- class CStreamGrabberProxyT : public CNodeMapProxyT<TParams>
- {
- public:
- //! \name Construction
- // \{
- //! Creates a CStreamGrabberProxyT object that is not attached to a pylon stream grabber. Use the Attach() method to attach the pylon stream grabber.
- CStreamGrabberProxyT();
- //! Creates a CStreamGrabberProxyT object and attaches it to a pylon stream grabber.
- CStreamGrabberProxyT( Pylon::IStreamGrabber* );
- //! Destructor
- virtual ~CStreamGrabberProxyT();
- //\}
- private:
- //! \name Assignment and copying is not supported
- // \{
- CStreamGrabberProxyT( const CStreamGrabberProxyT& );
- CStreamGrabberProxyT& operator=( const CStreamGrabberProxyT& );
- // \}
- public:
- //! \name Some smart pointer functionality
- // \{
- //! Attach a pylon stream grabber
- virtual void Attach( IStreamGrabber* );
- //! Checks if a pylon stream grabber is attached
- virtual bool IsAttached() const;
- //! Returns the pylon stream grabber interface pointer
- virtual IStreamGrabber* GetStreamGrabber() const;
- // \}
- public:
- //! \name Implementation of the IStreamGrabber interface
- //! See Pylon::IStreamGrabber for more details.
- // \{
- /** \brief \copybrief Pylon::IStreamGrabber::Open()
- \copydetails Pylon::IStreamGrabber::Open()
- */
- void Open()
- {
- CheckPtr();
- m_pStreamGrabber->Open();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::Close()
- \copydetails Pylon::IStreamGrabber::Close()
- */
- void Close()
- {
- CheckPtr();
- m_pStreamGrabber->Close();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::IsOpen()
- \copydetails Pylon::IStreamGrabber::IsOpen()
- */
- bool IsOpen() const
- {
- CheckPtr();
- return m_pStreamGrabber->IsOpen();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::RegisterBuffer()
- \copydetails Pylon::IStreamGrabber::RegisterBuffer()
- */
- StreamBufferHandle RegisterBuffer( void* pBuffer, size_t bufferSize )
- {
- CheckPtr();
- return m_pStreamGrabber->RegisterBuffer( pBuffer, bufferSize );
- }
- /** \brief \copybrief Pylon::IStreamGrabber::DeregisterBuffer()
- \copydetails Pylon::IStreamGrabber::DeregisterBuffer()
- */
- const void* DeregisterBuffer( StreamBufferHandle hStreamBuffer )
- {
- CheckPtr();
- return m_pStreamGrabber->DeregisterBuffer( hStreamBuffer );
- }
- /** \brief \copybrief Pylon::IStreamGrabber::PrepareGrab()
- \copydetails Pylon::IStreamGrabber::PrepareGrab()
- */
- void PrepareGrab()
- {
- CheckPtr();
- m_pStreamGrabber->PrepareGrab();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::IsStartAndStopStreamingMandatory()
- \copydetails Pylon::IStreamGrabber::IsStartAndStopStreamingMandatory()
- */
- bool IsStartAndStopStreamingMandatory()
- {
- CheckPtr();
- return m_pStreamGrabber->IsStartAndStopStreamingMandatory();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::StartStreamingIfMandatory()
- \copydetails Pylon::IStreamGrabber::StartStreamingIfMandatory()
- */
- void StartStreamingIfMandatory()
- {
- CheckPtr();
- m_pStreamGrabber->StartStreamingIfMandatory();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::StopStreamingIfMandatory()
- \copydetails Pylon::IStreamGrabber::StopStreamingIfMandatory()
- */
- void StopStreamingIfMandatory()
- {
- CheckPtr();
- m_pStreamGrabber->StopStreamingIfMandatory();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::FinishGrab()
- \copydetails Pylon::IStreamGrabber::FinishGrab()
- */
- void FinishGrab()
- {
- CheckPtr();
- m_pStreamGrabber->FinishGrab();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::QueueBuffer()
- \copydetails Pylon::IStreamGrabber::QueueBuffer()
- */
- void QueueBuffer( StreamBufferHandle hStreamBuffer, const void* pContext = NULL )
- {
- CheckPtr();
- m_pStreamGrabber->QueueBuffer( hStreamBuffer, pContext );
- }
- /** \brief \copybrief Pylon::IStreamGrabber::FlushBuffersToOutput()
- \copydetails Pylon::IStreamGrabber::FlushBuffersToOutput()
- */
- void FlushBuffersToOutput()
- {
- CheckPtr();
- m_pStreamGrabber->FlushBuffersToOutput();
- }
- // undocumented, deprecated
- void CancelGrab()
- {
- CheckPtr();
- m_pStreamGrabber->FlushBuffersToOutput();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::RetrieveResult()
- \copydetails Pylon::IStreamGrabber::RetrieveResult()
- */
- bool RetrieveResult( GrabResult& Result )
- {
- CheckPtr();
- return m_pStreamGrabber->RetrieveResult( Result );
- }
- /** \brief \copybrief Pylon::IStreamGrabber::GetWaitObject()
- \copydetails Pylon::IStreamGrabber::GetWaitObject()
- */
- WaitObject& GetWaitObject() const
- {
- CheckPtr();
- return m_pStreamGrabber->GetWaitObject();
- }
- /** \brief \copybrief Pylon::IStreamGrabber::GetNodeMap()
- \copydetails Pylon::IStreamGrabber::GetNodeMap()
- */
- 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
|