IPort.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //-----------------------------------------------------------------------------
  2. // (c) 2006 by Basler Vision Technologies
  3. // Section: Vision Components
  4. // Project: GenApi
  5. // Author: Margret Albrecht
  6. // $Header$
  7. //
  8. // License: This file is published under the license of the EMVA GenICam Standard Group.
  9. // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
  10. // If for some reason you are missing this file please contact the EMVA or visit the website
  11. // (http://www.genicam.org) for a full copy.
  12. //
  13. // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
  14. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  15. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
  17. // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. // POSSIBILITY OF SUCH DAMAGE.
  24. //-----------------------------------------------------------------------------
  25. /*!
  26. \file
  27. \brief Definition of interface IPort
  28. \ingroup GenApi_PublicInterface
  29. */
  30. #ifndef GENAPI_IPORT_H
  31. #define GENAPI_IPORT_H
  32. #include <Base/GCException.h>
  33. #include <GenApi/GenApiDll.h>
  34. #include <GenApi/Types.h>
  35. #include <GenApi/IBase.h>
  36. #ifdef _MSC_VER
  37. # pragma warning ( push )
  38. # pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY
  39. #endif
  40. namespace GENAPI_NAMESPACE
  41. {
  42. //*************************************************************
  43. // IPort interface
  44. //*************************************************************
  45. /**
  46. \brief Interface for ports
  47. \ingroup GenApi_PublicInterface
  48. */
  49. interface GENAPI_DECL_ABSTRACT IPort : virtual public IBase
  50. {
  51. //! Reads a chunk of bytes from the port
  52. virtual void Read(void *pBuffer, int64_t Address, int64_t Length) = 0;
  53. //! Writes a chunk of bytes to the port
  54. virtual void Write(const void *pBuffer, int64_t Address, int64_t Length) = 0;
  55. };
  56. //*************************************************************
  57. // CPortRef class
  58. //*************************************************************
  59. #ifndef DOXYGEN_IGNORE
  60. /**
  61. \internal
  62. \brief Reference to an IPort pointer
  63. \ingroup GenApi_PublicImpl
  64. */
  65. template <class T>
  66. class CPortRefT : public CBaseRefT<T>
  67. {
  68. typedef CBaseRefT<T> ref;
  69. public:
  70. /*--------------------------------------------------------*/
  71. // IPort
  72. /*--------------------------------------------------------*/
  73. //! Reads a chunk of bytes from the port
  74. virtual void Read(void *pBuffer, int64_t Address, int64_t Length)
  75. {
  76. if(ref::m_Ptr)
  77. return ref::m_Ptr->Read(pBuffer, Address, Length);
  78. else
  79. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  80. }
  81. //! Writes a chunk of bytes to the port
  82. virtual void Write(const void *pBuffer, int64_t Address, int64_t Length)
  83. {
  84. if(ref::m_Ptr)
  85. return ref::m_Ptr->Write(pBuffer, Address, Length);
  86. else
  87. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  88. }
  89. };
  90. //! Reference to an IEnumEntry pointer
  91. //! \ingroup GenApi_PublicImpl
  92. typedef CPortRefT<IPort> CPortRef;
  93. #endif
  94. }
  95. #ifdef _MSC_VER
  96. # pragma warning ( pop )
  97. #endif
  98. #endif // ifndef GENAPI_IPORT_H