Reference.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 template CReference
  28. \ingroup GenApi_PublicImpl
  29. */
  30. #ifndef GENAPI_REFERENCE_H
  31. #define GENAPI_REFERENCE_H
  32. #include <GenApi/Types.h>
  33. #include <GenApi/GenApiDll.h>
  34. namespace GENAPI_NAMESPACE
  35. {
  36. interface IBase;
  37. //*************************************************************
  38. // IReference interface
  39. //*************************************************************
  40. /**
  41. \brief Interface to construct a reference
  42. \ingroup GenApi_PublicImpl
  43. */
  44. interface GENAPI_DECL_ABSTRACT IReference
  45. {
  46. //! sets the implementation to a reference
  47. virtual void SetReference( GENAPI_NAMESPACE::IBase *pBase ) = 0;
  48. };
  49. //*************************************************************
  50. // IEnumReference interface
  51. //*************************************************************
  52. /**
  53. \brief Interface to construct an enum reference
  54. \ingroup GenApi_PublicImpl
  55. */
  56. interface GENAPI_DECL_ABSTRACT IEnumReference
  57. {
  58. //! sets the Enum value corresponding to a value
  59. virtual void SetEnumReference( int Index, GENICAM_NAMESPACE::gcstring Name) = 0;
  60. //! sets the number of enum vallues
  61. virtual void SetNumEnums( int NumEnums ) = 0;
  62. };
  63. //*************************************************************
  64. // CReference class
  65. //*************************************************************
  66. /**
  67. \brief Reference to an IBase derived pointer
  68. \ingroup GenApi_PublicImpl
  69. */
  70. template <class T, class I=T>
  71. class CReferenceT : public T, public IReference
  72. {
  73. public:
  74. // Constructor
  75. CReferenceT() :
  76. m_Ptr(NULL)
  77. {}
  78. /*--------------------------------------------------------*/
  79. // IReference
  80. /*--------------------------------------------------------*/
  81. //! sets the implementation to the reference
  82. virtual void SetReference( IBase *ptr )
  83. {
  84. m_Ptr = dynamic_cast<I*>( ptr );
  85. }
  86. protected:
  87. //! Pointer to the implementation the reference references to
  88. I *m_Ptr;
  89. };
  90. }
  91. #endif // ifndef GENAPI_REFERENCE_H