IString.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 IString
  28. \ingroup GenApi_PublicInterface
  29. */
  30. #ifndef GENAPI_ISTRING_H
  31. #define GENAPI_ISTRING_H
  32. #include <Base/GCString.h>
  33. #include <GenApi/GenApiDll.h>
  34. #include <GenApi/Types.h>
  35. #include <GenApi/IValue.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. // IString interface
  44. //*************************************************************
  45. /**
  46. \brief Interface for string properties
  47. \ingroup GenApi_PublicInterface
  48. */
  49. interface GENAPI_DECL_ABSTRACT IString : virtual public IValue
  50. {
  51. //! Set node value
  52. /*!
  53. \param Value The value to set
  54. \param Verify Enables AccessMode and Range verification (default = true)
  55. */
  56. virtual void SetValue(const GENICAM_NAMESPACE::gcstring& Value, bool Verify = true) = 0;
  57. //! Set node value
  58. virtual IString& operator=(const GENICAM_NAMESPACE::gcstring& Value) = 0;
  59. //! Get node value
  60. /*!
  61. \param Verify Enables Range verification (default = false). The AccessMode is always checked
  62. \param IgnoreCache If true the value is read ignoring any caches (default = false)
  63. \return The value read
  64. */
  65. virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify = false, bool IgnoreCache = false) = 0;
  66. //! Get node value
  67. virtual GENICAM_NAMESPACE::gcstring operator()() = 0;
  68. //! Get node value
  69. virtual GENICAM_NAMESPACE::gcstring operator*() = 0;
  70. //! Retrieves the maximum length of the string in bytes
  71. virtual int64_t GetMaxLength() = 0;
  72. };
  73. //*************************************************************
  74. // CStringRef class
  75. //*************************************************************
  76. #ifndef DOXYGEN_IGNORE
  77. /**
  78. \internal
  79. \brief Reference to an IEnumEntry pointer
  80. \ingroup GenApi_PublicImpl
  81. */
  82. template <class T>
  83. class CStringRefT : public CValueRefT<T>
  84. {
  85. typedef CValueRefT<T> ref;
  86. public:
  87. /*--------------------------------------------------------*/
  88. // IString
  89. /*--------------------------------------------------------*/
  90. //! Set node value
  91. virtual void SetValue(const GENICAM_NAMESPACE::gcstring& Value, bool Verify = true)
  92. {
  93. if(ref::m_Ptr)
  94. return ref::m_Ptr->SetValue(Value, Verify);
  95. else
  96. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  97. }
  98. //! Set node value
  99. virtual IString& operator=(const GENICAM_NAMESPACE::gcstring& Value)
  100. {
  101. if(ref::m_Ptr)
  102. return ref::m_Ptr->operator=(Value);
  103. else
  104. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  105. }
  106. //! Get node value
  107. virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify = false, bool IgnoreCache = false)
  108. {
  109. if(ref::m_Ptr)
  110. return ref::m_Ptr->GetValue(Verify, IgnoreCache);
  111. else
  112. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  113. }
  114. //! Get node value
  115. virtual GENICAM_NAMESPACE::gcstring operator()()
  116. {
  117. if(ref::m_Ptr)
  118. return ref::m_Ptr->operator()();
  119. else
  120. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  121. }
  122. //! Get node value
  123. virtual GENICAM_NAMESPACE::gcstring operator*()
  124. {
  125. if(ref::m_Ptr)
  126. return ref::m_Ptr-> operator*();
  127. else
  128. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  129. }
  130. //! Get max length of string
  131. virtual int64_t GetMaxLength()
  132. {
  133. if(ref::m_Ptr)
  134. return ref::m_Ptr->GetMaxLength();
  135. else
  136. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  137. }
  138. };
  139. //! Reference to an IString pointer
  140. //! \ingroup GenApi_PublicImpl
  141. typedef CStringRefT<IString> CStringRef;
  142. #endif
  143. }
  144. #ifdef _MSC_VER
  145. # pragma warning ( pop )
  146. #endif
  147. #endif // ifndef GENAPI_ISTRING_H