PortImpl.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //-----------------------------------------------------------------------------
  2. // (c) 2006 by Basler Vision Technologies
  3. // Section: Vision Components
  4. // Project: GenApi
  5. // Author: Fritz Dierks
  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 CPortImpl
  28. \ingroup GenApi_PublicUtilities
  29. */
  30. #ifndef GENAPI_PORTIMPL_H
  31. #define GENAPI_PORTIMPL_H
  32. #include <Base/GCException.h>
  33. #include <GenApi/GenApiDll.h>
  34. #include <GenApi/Types.h>
  35. #include <GenApi/IPortConstruct.h>
  36. #include <GenApi/IPortRecorder.h>
  37. #include <GenApi/Pointer.h>
  38. #ifdef _MSC_VER
  39. # pragma warning( push )
  40. # pragma warning( disable : 4251 ) // enApi::CPortImpl::m_ptrPort' : class 'GenApi::CPointer<T>' needs to have dll-interface
  41. # pragma warning( disable : 4275 ) // DLL interface (this is a bug)
  42. # pragma warning( disable : 4068 ) // unknown pragma; refers to BullsEyeCoverage
  43. #endif
  44. namespace GENAPI_NAMESPACE
  45. {
  46. //*************************************************************
  47. // CPortImpl class
  48. //*************************************************************
  49. /**
  50. \brief Standard implementation for a port
  51. //! \ingroup GenApi_PublicUtilities
  52. */
  53. class CPortImpl : public IPortConstruct, public IPortReplay
  54. {
  55. public:
  56. //! Constructor
  57. CPortImpl()
  58. {
  59. }
  60. //! Destructor
  61. virtual ~CPortImpl()
  62. {
  63. }
  64. /*---------------------------------------------------------------*/
  65. // IBase ==> You need to override this method
  66. /*---------------------------------------------------------------*/
  67. //! Get the access mode of the node
  68. /*! Driver closed => NI, Driver open => RW, analysing a struct, RO */
  69. virtual EAccessMode GetAccessMode() const = 0;
  70. /*---------------------------------------------------------------*/
  71. // IPort ==> You need to override these methods
  72. /*---------------------------------------------------------------*/
  73. //! Reads a chunk of bytes from the port
  74. virtual void Read(void *pBuffer, int64_t Address, int64_t Length) = 0;
  75. //! Writes a chunk of bytes to the port
  76. virtual void Write(const void *pBuffer, int64_t Address, int64_t Length) = 0;
  77. /*---------------------------------------------------------------*/
  78. // IPortConstruct implementation (without IPort & IBase)
  79. /*---------------------------------------------------------------*/
  80. //! Sets pointer the real port implementation; this function may called only once
  81. virtual void SetPortImpl(IPort* pPort)
  82. {
  83. m_ptrPort = pPort;
  84. assert(m_ptrPort.IsValid());
  85. }
  86. //! Determines if the port adapter must perform an endianess swap
  87. virtual EYesNo GetSwapEndianess()
  88. {
  89. return No;
  90. }
  91. //---------------------------------------------------------------
  92. // IPortReplay implementation
  93. //---------------------------------------------------------------
  94. //! sends the commands to the camera.
  95. /*! the default implementation just walks the list and issues each command
  96. using the WriteRegister method. Depending on the capabilities of
  97. the transport layer the implementation can however use a special command
  98. which sends all register write commands as one package.
  99. */
  100. virtual void Replay( IPortWriteList *pPortRecorder, bool Invalidate = true )
  101. {
  102. if(pPortRecorder)
  103. pPortRecorder->Replay(this);
  104. if(Invalidate)
  105. InvalidateNode();
  106. }
  107. // Invalidate the node
  108. void InvalidateNode()
  109. {
  110. if(m_ptrPort.IsValid())
  111. m_ptrPort->InvalidateNode();
  112. }
  113. private:
  114. //! Pointer to the node holding a reference to this implementation
  115. CNodePtr m_ptrPort;
  116. };
  117. }
  118. #ifdef _MSC_VER
  119. # pragma warning(pop)
  120. #endif
  121. #endif // ifndef GENAPI_PORTIMPL_H