IValue.h 5.2 KB

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