IValue.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 the interface IValue.
  28. \ingroup GenApi_PublicInterface
  29. */
  30. #ifndef GENAPI_IVALUE_H
  31. #define GENAPI_IVALUE_H
  32. #include <GenApi/GenApiDll.h>
  33. #include <GenApi/Types.h>
  34. #include <GenApi/IBase.h>
  35. #include <GenApi/INode.h>
  36. #include <Base/GCString.h>
  37. #include <Base/GCException.h>
  38. #pragma warning ( push )
  39. #pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY
  40. namespace GENAPI_NAMESPACE
  41. {
  42. interface INode;
  43. //*************************************************************
  44. // IValue interface
  45. //*************************************************************
  46. /**
  47. \brief Interface for value properties
  48. \ingroup GenApi_PublicInterface
  49. */
  50. interface GENAPI_DECL_ABSTRACT IValue : virtual public IBase
  51. {
  52. //! Get the INode interface of the node
  53. virtual INode* GetNode() { return dynamic_cast<INode*>(this); }
  54. //! Get content of the node as string
  55. /*!
  56. \param Verify Enables Range verification (default = false). The AccessMode is always checked
  57. \param IgnoreCache If true the value is read ignoring any caches (default = false)
  58. \return The value read
  59. */
  60. virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false) = 0;
  61. //! Set content of the node as string
  62. /*!
  63. \param ValueStr The value to set
  64. \param Verify Enables AccessMode and Range verification (default = true)
  65. */
  66. virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true) = 0;
  67. //! Checks if the value comes from cache or is requested from another node
  68. virtual bool IsValueCacheValid() const = 0;
  69. };
  70. //*************************************************************
  71. // CValueRef class
  72. //*************************************************************
  73. #ifndef DOXYGEN_IGNORE
  74. /**
  75. \internal
  76. \brief Reference to an IValue pointer
  77. \ingroup GenApi_PublicImpl
  78. */
  79. template <class T, class I=T>
  80. class CValueRefT : public CBaseRefT<T,I>
  81. {
  82. typedef CBaseRefT<T, I> ref;
  83. public:
  84. /*--------------------------------------------------------*/
  85. // IValue
  86. /*--------------------------------------------------------*/
  87. //! Get the INode interface of the node
  88. virtual INode* GetNode()
  89. {
  90. if(ref::m_Ptr)
  91. return ref::m_Ptr->GetNode();
  92. else
  93. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  94. }
  95. //! Get content of the node as string
  96. virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false)
  97. {
  98. if(ref::m_Ptr)
  99. return ref::m_Ptr->ToString(Verify, IgnoreCache);
  100. else
  101. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  102. }
  103. //! Set content of the node as string
  104. virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true)
  105. {
  106. if(ref::m_Ptr)
  107. return ref::m_Ptr->FromString(ValueStr, Verify);
  108. else
  109. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  110. }
  111. //! Checks if the value comes from cache or is requested from another node
  112. virtual bool IsValueCacheValid() const
  113. {
  114. if(ref::m_Ptr)
  115. return ref::m_Ptr->IsValueCacheValid();
  116. else
  117. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  118. }
  119. };
  120. //! Reference to an IValue pointer
  121. //! \ingroup GenApi_PublicImpl
  122. typedef CValueRefT<IValue> CValueRef;
  123. #endif
  124. }
  125. #pragma warning ( pop )
  126. #endif // ifndef GENAPI_IVALUE_H