273 lines
10 KiB
C++
273 lines
10 KiB
C++
//------------------------------------------------------------------------------
|
|
// Basler pylon SDK
|
|
// Copyright (c) 2018-2023 Basler AG
|
|
// http://www.baslerweb.com
|
|
//------------------------------------------------------------------------------
|
|
/*!
|
|
\file
|
|
\brief Contains the class CArrayParameter used to simplify access to %GenApi parameters.
|
|
*/
|
|
|
|
#ifndef INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H
|
|
#define INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H
|
|
|
|
#pragma once
|
|
|
|
#include <pylon/PylonBase.h>
|
|
#include <GenApi/IRegister.h>
|
|
#include <pylon/Parameter.h>
|
|
|
|
#ifdef _MSC_VER
|
|
# pragma pack(push, PYLON_PACKING)
|
|
#endif /* _MSC_VER */
|
|
|
|
#ifdef _MSC_VER
|
|
# pragma warning( push )
|
|
# pragma warning( disable : 4275 ) // Class needs to have a dll interface to be used by clients of the class.
|
|
# pragma warning( disable : 4250 ) // warning C4250: 'Pylon::CXYZParameter': inherits 'Pylon::CParameter::Pylon::CParameter::ZYX' via dominance
|
|
#endif
|
|
|
|
namespace Pylon
|
|
{
|
|
/*!
|
|
\brief Extends the GenApi::IRegister interface with convenience methods.
|
|
*/
|
|
interface IRegisterEx : virtual public GenApi::IRegister, virtual public IValueEx
|
|
{
|
|
using GenApi::IRegister::operator=;
|
|
|
|
};
|
|
|
|
|
|
/*!
|
|
\brief CArrayParameter class used to simplify access to %GenApi parameters.
|
|
*/
|
|
class PYLONBASE_API CArrayParameter : public IRegisterEx, public CParameter
|
|
{
|
|
public:
|
|
/*!
|
|
\brief Creates an empty CArrayParameter object.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
CArrayParameter();
|
|
|
|
|
|
/*!
|
|
\brief Creates a CArrayParameter object and attaches it to a node, typically retrieved for a nodemap calling GetNode().
|
|
\param[in] pNode The node to attach.
|
|
\post
|
|
<ul>
|
|
<li>If the passed node does not match the parameter type, the parameter will be empty, see IsValid().
|
|
<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.
|
|
<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.
|
|
</ul>
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
explicit CArrayParameter( GenApi::INode* pNode );
|
|
|
|
|
|
/*!
|
|
\brief Creates a CArrayParameter object and attaches it to a node of a matching type.
|
|
\param[in] pRegister The node to attach.
|
|
\post
|
|
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.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
explicit CArrayParameter( GenApi::IRegister* pRegister );
|
|
|
|
|
|
/*!
|
|
\brief Creates a CArrayParameter object and attaches it to a node retrieved from the provided node map.
|
|
\param[in] pNodeMap The node map. The source of the parameter.
|
|
\param[in] pName The name of the parameter to attach.
|
|
\post
|
|
<ul>
|
|
<li>If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid().
|
|
<li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
|
|
<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.
|
|
<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.
|
|
</ul>
|
|
\error
|
|
The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
|
|
*/
|
|
CArrayParameter( GenApi::INodeMap* pNodeMap, const char* pName );
|
|
|
|
|
|
/*!
|
|
\brief Creates a CArrayParameter object and attaches it to a node retrieved from the provided node map.
|
|
\param[in] nodeMap The node map. The source of the parameter.
|
|
\param[in] pName The name of the parameter to attach.
|
|
\post
|
|
<ul>
|
|
<li>If \c name is NULL, the parameter will be empty, see IsValid().
|
|
<li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
|
|
<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.
|
|
<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.
|
|
</ul>
|
|
\error
|
|
The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
|
|
*/
|
|
CArrayParameter( GenApi::INodeMap& nodeMap, const char* pName );
|
|
|
|
|
|
/*!
|
|
\brief Copies a CArrayParameter object.
|
|
\param[in] rhs The object to copy.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
CArrayParameter( const CArrayParameter& rhs );
|
|
|
|
|
|
/*!
|
|
\brief Destroys the CArrayParameter object.
|
|
Does not access the attached node.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
virtual ~CArrayParameter();
|
|
|
|
|
|
/*!
|
|
\brief Attaches a node retrieved from the provided node map.
|
|
\param[in] pNodeMap The node map. The source of the parameter.
|
|
\param[in] pName The name of the parameter to attach.
|
|
\return Returns true if the node has been attached.
|
|
\post
|
|
<ul>
|
|
<li>If \c pNodeMap or \c name is NULL, the parameter will be empty, see IsValid().
|
|
<li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
|
|
<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.
|
|
<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.
|
|
</ul>
|
|
\error
|
|
The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
|
|
*/
|
|
virtual bool Attach( GenApi::INodeMap* pNodeMap, const char* pName );
|
|
|
|
|
|
/*!
|
|
\brief Attaches a node retrieved from the provided node map.
|
|
\param[in] nodeMap The node map. The source of the parameter.
|
|
\param[in] pName The name of the parameter to attach.
|
|
\return Returns true if the node has been attached.
|
|
\post
|
|
<ul>
|
|
<li>If \c name is NULL the parameter will be empty, see IsValid().
|
|
<li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
|
|
<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.
|
|
<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.
|
|
</ul>
|
|
\error
|
|
The call to GenApi::INodeMap::GetNode can throw C++ exceptions.
|
|
*/
|
|
virtual bool Attach( GenApi::INodeMap& nodeMap, const char* pName );
|
|
|
|
|
|
/*!
|
|
\brief Attaches a node, typically retrieved for a nodemap calling GetNode().
|
|
\param[in] pNode The node to assign.
|
|
\return Returns true if the node has been attached.
|
|
\post
|
|
<ul>
|
|
<li>If the node does not match the parameter type, the parameter will be empty, see IsValid().
|
|
<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.
|
|
<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.
|
|
</ul>
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
virtual bool Attach( GenApi::INode* pNode );
|
|
|
|
|
|
/*!
|
|
\brief Assigns a node of the same type to the parameter object.
|
|
\param[in] pRegister The node to assign.
|
|
\return Returns true if the node has been attached.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
virtual bool Attach( GenApi::IRegister* pRegister );
|
|
|
|
|
|
/*!
|
|
\brief Assigns a CArrayParameter object.
|
|
\param[in] rhs The object to assign.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
CArrayParameter& operator=( const CArrayParameter& rhs );
|
|
|
|
|
|
/*!
|
|
\brief Returns true if the same nodes are attached or both parameters are empty.
|
|
\param[in] rhs The object to compare to.
|
|
\return Returns true if the same nodes are attached or both parameters are empty.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
virtual bool Equals( const CArrayParameter& rhs ) const;
|
|
|
|
|
|
/*!
|
|
\brief Returns true if the attached node pointer is equal.
|
|
\param[in] pNode The node to compare to.
|
|
\return Returns true if the attached node pointer is equal.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
virtual bool Equals( const GenApi::INode* pNode ) const;
|
|
|
|
|
|
/*!
|
|
\brief Returns true if the attached node pointer is equal.
|
|
\param[in] pRegister The node to compare to.
|
|
\return Returns true if the attached node pointer is equal.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
virtual bool Equals( const GenApi::IRegister* pRegister ) const;
|
|
|
|
|
|
/*!
|
|
\brief Releases the attached node.
|
|
\error
|
|
Does not throw C++ exceptions.
|
|
*/
|
|
virtual void Release();
|
|
|
|
|
|
// Implements IValueEx
|
|
virtual bool IsValid() const;
|
|
|
|
|
|
// Implements GenApi::IRegister
|
|
virtual void Set( const uint8_t* pBuffer, int64_t length, bool verify = true );
|
|
|
|
// Implements GenApi::IRegister
|
|
virtual void Get( uint8_t* pBuffer, int64_t length, bool verify = false, bool ignoreCache = false );
|
|
|
|
// Implements GenApi::IRegister
|
|
virtual int64_t GetLength();
|
|
|
|
// Implements GenApi::IRegister
|
|
virtual int64_t GetAddress();
|
|
|
|
|
|
|
|
protected:
|
|
GenApi::IRegister* m_pFeature;
|
|
};
|
|
}
|
|
#ifdef _MSC_VER
|
|
# pragma warning( pop )
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
# pragma pack(pop)
|
|
#endif /* _MSC_VER */
|
|
|
|
#endif /* INCLUDED_BASLER_PYLON_CARRAYPARAMETER_H */ |