NodeMapProxy.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2007-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: AH
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Pylon generic node map interface declaration
  10. \ingroup PYLON_INTERNAL
  11. */
  12. #ifndef __PYLON_NODEMAPROXY__H__
  13. #define __PYLON_NODEMAPROXY__H__
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #include <pylon/Platform.h>
  18. #ifdef _MSC_VER
  19. # pragma pack(push, PYLON_PACKING)
  20. #endif /* _MSC_VER */
  21. #include <Base/GCException.h>
  22. #include <GenApi/INodeMap.h>
  23. #include <GenApi/INode.h>
  24. //! Macro to define a custom Node map proxy
  25. #define PYLON_DEFINE_NODEMAP(ClassName, BaseClass) \
  26. class ClassName : public BaseClass \
  27. { \
  28. public: \
  29. /** \name Construction */ \
  30. /*@{*/ \
  31. /** \brief \copybrief Pylon::CNodeMapProxyT::CNodeMapProxyT()
  32. \copydetails Pylon::CNodeMapProxyT::CNodeMapProxyT()
  33. */ \
  34. ClassName() \
  35. { \
  36. } \
  37. /** \brief \copybrief Pylon::CNodeMapProxyT::CNodeMapProxyT(GenApi::INodeMap*)
  38. \copydetails Pylon::CNodeMapProxyT::CNodeMapProxyT(GenApi::INodeMap*)
  39. */ \
  40. ClassName( GenApi::INodeMap* pNodeMap ) : BaseClass( pNodeMap ) \
  41. { \
  42. } \
  43. /*@}*/ \
  44. };
  45. namespace Pylon
  46. {
  47. //**************************************************************************************************
  48. //! Implementation Detail: This class wraps programming interfaces that are generated from %GenICam parameter description files to provide native parameter access.
  49. /**
  50. \see \ref configuringcameras
  51. \tparam TParams The specific parameter class (auto generated from the parameter xml file)
  52. \ingroup PYLON_INTERNAL
  53. */
  54. //**************************************************************************************************
  55. template<class TParams>
  56. class CNodeMapProxyT : public TParams
  57. {
  58. public:
  59. //! \name Construction
  60. // \{
  61. //! Creates a CNodeMapProxyT object that is not attached to a node map. Use the Attach() method to attach the pylon node map.
  62. CNodeMapProxyT();
  63. //! Creates a CNodeMapProxyT object and attaches it to a pylon node map.
  64. CNodeMapProxyT( GenApi::INodeMap* );
  65. //! Destructor
  66. virtual ~CNodeMapProxyT();
  67. //\}
  68. private:
  69. //! \name Assignment and copying is not supported
  70. // \{
  71. CNodeMapProxyT( const CNodeMapProxyT& );
  72. CNodeMapProxyT& operator=( const CNodeMapProxyT& );
  73. // \}
  74. public:
  75. //! \name Some smart pointer functionality
  76. // \{
  77. //! Attach a pylon node map
  78. virtual void Attach( GenApi::INodeMap*, bool replace = false );
  79. //! Checks if a pylon node map is attached
  80. virtual bool IsAttached() const;
  81. //! Returns the pylon node map interface pointer
  82. virtual GenApi::INodeMap* GetNodeMap() const;
  83. // \}
  84. public:
  85. //! \name Partial implementation of the INodeMap interface
  86. //! See GenApi::INodeMap for more details
  87. // \{
  88. /** \brief \copybrief GenApi::INodeMap::GetNodes()
  89. \copydetails GenApi::INodeMap::GetNodes()
  90. */
  91. void GetNodes( GenApi::NodeList_t& Nodes ) const
  92. {
  93. CheckNodeMapPtr();
  94. return m_pNodeMap->GetNodes( Nodes );
  95. }
  96. /** \brief \copybrief GenApi::INodeMap::GetNode()
  97. \copydetails GenApi::INodeMap::GetNode()
  98. */
  99. GenApi::INode* GetNode( const GenICam::gcstring& Name ) const
  100. {
  101. CheckNodeMapPtr();
  102. return m_pNodeMap->GetNode( Name );
  103. }
  104. /** \brief \copybrief GenApi::INodeMap::InvalidateNodes()
  105. \copydetails GenApi::INodeMap::InvalidateNodes()
  106. */
  107. void InvalidateNodes() const
  108. {
  109. CheckNodeMapPtr();
  110. m_pNodeMap->InvalidateNodes();
  111. }
  112. /** \brief \copybrief GenApi::INodeMap::Poll()
  113. \copydetails GenApi::INodeMap::Poll()
  114. */
  115. void Poll( int64_t ElapsedTime )
  116. {
  117. CheckNodeMapPtr();
  118. m_pNodeMap->Poll( ElapsedTime );
  119. }
  120. // \}
  121. protected:
  122. void CheckNodeMapPtr() const
  123. {
  124. if (NULL == m_pNodeMap)
  125. {
  126. throw LOGICAL_ERROR_EXCEPTION( "The object is not attached to a NodeMap" );
  127. }
  128. }
  129. GenApi::INodeMap* m_pNodeMap;
  130. };
  131. //**************************************************************************************************
  132. // CPylonDeviceProxyT implementation
  133. //**************************************************************************************************
  134. template<class TParams>
  135. inline CNodeMapProxyT<TParams>::CNodeMapProxyT()
  136. : m_pNodeMap( NULL )
  137. {
  138. }
  139. template<class TParams>
  140. inline CNodeMapProxyT<TParams>::CNodeMapProxyT( GenApi::INodeMap* pNodeMap )
  141. : m_pNodeMap( NULL )
  142. {
  143. Attach( pNodeMap );
  144. }
  145. template<class TParams>
  146. inline CNodeMapProxyT<TParams>::~CNodeMapProxyT( void )
  147. {
  148. }
  149. template<class TParams>
  150. inline void CNodeMapProxyT<TParams>::Attach( GenApi::INodeMap* pNodeMap, bool replace )
  151. {
  152. if (IsAttached() && !replace)
  153. {
  154. throw LOGICAL_ERROR_EXCEPTION( "Object is already attached to a node map" );
  155. }
  156. if (NULL == pNodeMap)
  157. {
  158. throw LOGICAL_ERROR_EXCEPTION( "Tried to attach a NULL pointer as node map" );
  159. }
  160. TParams::_Initialize( pNodeMap );
  161. m_pNodeMap = pNodeMap;
  162. }
  163. template<class TParams>
  164. inline bool CNodeMapProxyT<TParams>::IsAttached() const
  165. {
  166. return NULL != m_pNodeMap;
  167. }
  168. template<class TParams>
  169. inline GenApi::INodeMap* CNodeMapProxyT<TParams>::GetNodeMap() const
  170. {
  171. return m_pNodeMap;
  172. }
  173. }
  174. #ifdef _MSC_VER
  175. # pragma pack(pop)
  176. #endif /* _MSC_VER */
  177. #endif // __PYLON_NODEMAPROXY__H__