ArrayParameter.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. //------------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2018-2021 Basler AG
  4. // http://www.baslerweb.com
  5. //------------------------------------------------------------------------------
  6. /*!
  7. \file
  8. \brief Contains the class CArrayParameter used to simplify access to %GenApi parameters.
  9. */
  10. #ifndef INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H
  11. #define INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H
  12. #pragma once
  13. #include <pylon/PylonBase.h>
  14. #include <GenApi/IRegister.h>
  15. #include <pylon/Parameter.h>
  16. #ifdef _MSC_VER
  17. # pragma pack(push, PYLON_PACKING)
  18. #endif /* _MSC_VER */
  19. #ifdef _MSC_VER
  20. # pragma warning( push )
  21. # pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class.
  22. # pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance
  23. #endif
  24. namespace Pylon
  25. {
  26. /*!
  27. \brief Extends the GenApi::IRegister interface with convenience methods.
  28. */
  29. interface IRegisterEx : virtual public GenApi::IRegister, virtual public IValueEx
  30. {
  31. using GenApi::IRegister::operator=;
  32. };
  33. /*!
  34. \brief CArrayParameter class used to simplify access to %GenApi parameters.
  35. */
  36. class PYLONBASE_API CArrayParameter : public IRegisterEx, public CParameter
  37. {
  38. public:
  39. /*!
  40. \brief Creates an empty CArrayParameter object.
  41. \error
  42. Does not throw C++ exceptions.
  43. */
  44. CArrayParameter();
  45. /*!
  46. \brief Creates a CArrayParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode().
  47. \param[in] pNode The node to attach.
  48. \post
  49. <ul>
  50. <li>If the passed node does not match the parameter type, the parameter will be empty, see IsValid().
  51. <li>If the passed node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality.
  52. <li>The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node.
  53. </ul>
  54. \error
  55. Does not throw C++ exceptions.
  56. */
  57. explicit CArrayParameter( GenApi::INode* pNode );
  58. /*!
  59. \brief Creates a CArrayParameter object and attaches it to a node of a matching type.
  60. \param[in] pRegister The node to attach.
  61. \post
  62. The parameter object must not be used to access the node's functionality if the source of the attached \c pRegister has been destroyed. In this case, call Release() or attach a new node.
  63. \error
  64. Does not throw C++ exceptions.
  65. */
  66. explicit CArrayParameter( GenApi::IRegister* pRegister );
  67. /*!
  68. \brief Creates a CArrayParameter object and attaches it to a node retrieved from the provided node map.
  69. \param[in] pNodeMap The node map. The source of the parameter.
  70. \param[in] pName The name of the parameter to attach.
  71. \post
  72. <ul>
  73. <li>If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid().
  74. <li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
  75. <li>If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality.
  76. <li>The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node.
  77. </ul>
  78. \error
  79. The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
  80. */
  81. CArrayParameter( GenApi::INodeMap* pNodeMap, const char* pName );
  82. /*!
  83. \brief Creates a CArrayParameter object and attaches it to a node retrieved from the provided node map.
  84. \param[in] nodeMap The node map. The source of the parameter.
  85. \param[in] pName The name of the parameter to attach.
  86. \post
  87. <ul>
  88. <li>If \c name is NULL, the parameter will be empty, see IsValid().
  89. <li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
  90. <li>If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality.
  91. <li>The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node.
  92. </ul>
  93. \error
  94. The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
  95. */
  96. CArrayParameter( GenApi::INodeMap& nodeMap, const char* pName );
  97. /*!
  98. \brief Copies a CArrayParameter object.
  99. \param[in] rhs The object to copy.
  100. \error
  101. Does not throw C++ exceptions.
  102. */
  103. CArrayParameter( const CArrayParameter& rhs );
  104. /*!
  105. \brief Destroys the CArrayParameter object.
  106. Does not access the attached node.
  107. \error
  108. Does not throw C++ exceptions.
  109. */
  110. virtual ~CArrayParameter();
  111. /*!
  112. \brief Attaches a node retrieved from the provided node map.
  113. \param[in] pNodeMap The node map. The source of the parameter.
  114. \param[in] pName The name of the parameter to attach.
  115. \return Returns true if the node has been attached.
  116. \post
  117. <ul>
  118. <li>If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid().
  119. <li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
  120. <li>If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality.
  121. <li>The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node.
  122. </ul>
  123. \error
  124. The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
  125. */
  126. virtual bool Attach( GenApi::INodeMap* pNodeMap, const char* pName );
  127. /*!
  128. \brief Attaches a node retrieved from the provided node map.
  129. \param[in] nodeMap The node map. The source of the parameter.
  130. \param[in] pName The name of the parameter to attach.
  131. \return Returns true if the node has been attached.
  132. \post
  133. <ul>
  134. <li>If \c name is NULL the parameter will be empty, see IsValid().
  135. <li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
  136. <li>If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality.
  137. <li>The parameter object must not be used to access the node's functionality if the provided node map has been destroyed. In this case, call Release() or attach a new node.
  138. </ul>
  139. \error
  140. The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
  141. */
  142. virtual bool Attach( GenApi::INodeMap& nodeMap, const char* pName );
  143. /*!
  144. \brief Attaches a node, typically retrieved for a nodemap calling GetNode().
  145. \param[in] pNode The node to assign.
  146. \return Returns true if the node has been attached.
  147. \post
  148. <ul>
  149. <li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
  150. <li>If the node does match the parameter type, it is attached and the parameter object can be used to access the node's functionality.
  151. <li>The parameter object must not be used to access the node's functionality if the source of the attached \c pNode has been destroyed. In this case, call Release() or attach a new node.
  152. </ul>
  153. \error
  154. Does not throw C++ exceptions.
  155. */
  156. virtual bool Attach( GenApi::INode* pNode );
  157. /*!
  158. \brief Assigns a node of the same type to the parameter object.
  159. \param[in] pRegister The node to assign.
  160. \return Returns true if the node has been attached.
  161. \error
  162. Does not throw C++ exceptions.
  163. */
  164. virtual bool Attach( GenApi::IRegister* pRegister );
  165. /*!
  166. \brief Assigns a CArrayParameter object.
  167. \param[in] rhs The object to assign.
  168. \error
  169. Does not throw C++ exceptions.
  170. */
  171. CArrayParameter& operator=( const CArrayParameter& rhs );
  172. /*!
  173. \brief Returns true if the same nodes are attached or both parameters are empty.
  174. \param[in] rhs The object to compare to.
  175. \return Returns true if the same nodes are attached or both parameters are empty.
  176. \error
  177. Does not throw C++ exceptions.
  178. */
  179. virtual bool Equals( const CArrayParameter& rhs ) const;
  180. /*!
  181. \brief Returns true if the attached node pointer is equal.
  182. \param[in] pNode The node to compare to.
  183. \return Returns true if the attached node pointer is equal.
  184. \error
  185. Does not throw C++ exceptions.
  186. */
  187. virtual bool Equals( const GenApi::INode* pNode ) const;
  188. /*!
  189. \brief Returns true if the attached node pointer is equal.
  190. \param[in] pRegister The node to compare to.
  191. \return Returns true if the attached node pointer is equal.
  192. \error
  193. Does not throw C++ exceptions.
  194. */
  195. virtual bool Equals( const GenApi::IRegister* pRegister ) const;
  196. /*!
  197. \brief Releases the attached node.
  198. \error
  199. Does not throw C++ exceptions.
  200. */
  201. virtual void Release();
  202. // Implements IValueEx
  203. virtual bool IsValid() const;
  204. // Implements GenApi::IRegister
  205. virtual void Set( const uint8_t* pBuffer, int64_t length, bool verify = true );
  206. // Implements GenApi::IRegister
  207. virtual void Get( uint8_t* pBuffer, int64_t length, bool verify = false, bool ignoreCache = false );
  208. // Implements GenApi::IRegister
  209. virtual int64_t GetLength();
  210. // Implements GenApi::IRegister
  211. virtual int64_t GetAddress();
  212. protected:
  213. GenApi::IRegister* m_pFeature;
  214. };
  215. }
  216. #ifdef _MSC_VER
  217. # pragma warning( pop )
  218. #endif
  219. #ifdef _MSC_VER
  220. # pragma pack(pop)
  221. #endif /* _MSC_VER */
  222. #endif /* INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H */