IInteger.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  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 IInteger.
  28. \ingroup GenApi_PublicInterface
  29. */
  30. #ifndef GENAPI_IIINTEGER_H
  31. #define GENAPI_IIINTEGER_H
  32. #include <Base/GCUtilities.h>
  33. #include <GenApi/GenApiDll.h>
  34. #include <GenApi/Types.h>
  35. #include <GenApi/IValue.h>
  36. #pragma warning ( push )
  37. #pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY
  38. namespace GENAPI_NAMESPACE
  39. {
  40. //*************************************************************
  41. // IInteger interface
  42. //*************************************************************
  43. /**
  44. \brief Interface for integer properties
  45. \ingroup GenApi_PublicInterface
  46. */
  47. interface GENAPI_DECL_ABSTRACT IInteger : virtual public IValue
  48. {
  49. //! Set node value
  50. /*!
  51. \param Value The value to set
  52. \param Verify Enables AccessMode and Range verification (default = true)
  53. */
  54. virtual void SetValue(int64_t Value, bool Verify = true) = 0;
  55. //! Set node value
  56. virtual IInteger& operator=(int64_t Value) = 0;
  57. //! Get node value
  58. /*!
  59. \param Verify Enables Range verification (default = false). The AccessMode is always checked
  60. \param IgnoreCache If true the value is read ignoring any caches (default = false)
  61. \return The value read
  62. */
  63. virtual int64_t GetValue(bool Verify = false, bool IgnoreCache = false ) = 0;
  64. //! Get node value
  65. virtual int64_t operator()() = 0;
  66. //! Get node value
  67. virtual int64_t operator*() = 0;
  68. //! Get minimum value allowed
  69. virtual int64_t GetMin() = 0;
  70. //! Get maximum value allowed
  71. virtual int64_t GetMax() = 0;
  72. //! Get increment mode
  73. virtual EIncMode GetIncMode() = 0;
  74. //! Get increment
  75. virtual int64_t GetInc() = 0;
  76. //! Get list of valid value
  77. virtual int64_autovector_t GetListOfValidValues(bool bounded = true) = 0;
  78. //! Get recommended representation
  79. virtual ERepresentation GetRepresentation() = 0;
  80. //! Get the physical unit name
  81. virtual GENICAM_NAMESPACE::gcstring GetUnit() = 0;
  82. //! Restrict minimum value
  83. virtual void ImposeMin(int64_t Value) = 0;
  84. //! Restrict maximum value
  85. virtual void ImposeMax(int64_t Value) = 0;
  86. };
  87. //*************************************************************
  88. // CIntegerRef class
  89. //*************************************************************
  90. #ifndef DOXYGEN_IGNORE
  91. interface IFloat;
  92. /**
  93. \internal
  94. \brief Reference to an IInteger pointer
  95. \ingroup GenApi_PublicImpl
  96. */
  97. template <class T, class I=T>
  98. class CIntegerRefT : public CValueRefT<T, I>
  99. {
  100. typedef CValueRefT<T, I> ref;
  101. public:
  102. /*--------------------------------------------------------*/
  103. // IInteger
  104. /*--------------------------------------------------------*/
  105. //! Set node value
  106. virtual void SetValue(int64_t Value, bool Verify = true)
  107. {
  108. if(ref::m_Ptr)
  109. return ref::m_Ptr->SetValue(Value, Verify);
  110. else
  111. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  112. }
  113. //! Set node value
  114. virtual IInteger& operator=(int64_t Value)
  115. {
  116. if(ref::m_Ptr)
  117. {
  118. ref::m_Ptr->SetValue(Value);
  119. return *this;
  120. }
  121. else
  122. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  123. }
  124. //! Get node value
  125. virtual int64_t GetValue( bool Verify = false, bool IgnoreCache = false )
  126. {
  127. if(ref::m_Ptr)
  128. return ref::m_Ptr->GetValue( Verify, IgnoreCache );
  129. else
  130. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  131. }
  132. //! Get node value
  133. virtual int64_t operator()()
  134. {
  135. if(ref::m_Ptr)
  136. return ref::m_Ptr->operator()();
  137. else
  138. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  139. }
  140. //! Get node value
  141. virtual int64_t operator*()
  142. {
  143. if(ref::m_Ptr)
  144. return ref::m_Ptr->operator*();
  145. else
  146. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  147. }
  148. //! Get minimum value allowed
  149. virtual int64_t GetMin()
  150. {
  151. if(ref::m_Ptr)
  152. return ref::m_Ptr->GetMin();
  153. else
  154. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  155. }
  156. //! Get maximum value allowed
  157. virtual int64_t GetMax()
  158. {
  159. if(ref::m_Ptr)
  160. return ref::m_Ptr->GetMax();
  161. else
  162. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  163. }
  164. //! Get increment
  165. virtual EIncMode GetIncMode()
  166. {
  167. if(ref::m_Ptr)
  168. return ref::m_Ptr->GetIncMode();
  169. else
  170. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  171. }
  172. //! Get increment
  173. virtual int64_t GetInc()
  174. {
  175. if(ref::m_Ptr)
  176. return ref::m_Ptr->GetInc();
  177. else
  178. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  179. }
  180. //! Implementation of IInteger::GetListOfValidValues
  181. virtual int64_autovector_t GetListOfValidValues(bool bounded = true)
  182. {
  183. if(ref::m_Ptr)
  184. return ref::m_Ptr->GetListOfValidValues( bounded );
  185. else
  186. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  187. }
  188. //! Get recommended representation
  189. virtual ERepresentation GetRepresentation()
  190. {
  191. if(ref::m_Ptr)
  192. return ref::m_Ptr->GetRepresentation();
  193. else
  194. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  195. }
  196. //! Get the physical unit name
  197. virtual GENICAM_NAMESPACE::gcstring GetUnit()
  198. {
  199. if(ref::m_Ptr)
  200. return ref::m_Ptr->GetUnit();
  201. else
  202. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  203. }
  204. //! gets the interface of an alias node.
  205. IFloat *GetFloatAlias()
  206. {
  207. if(ref::m_Ptr)
  208. return dynamic_cast<IFloat*>(ref::m_Ptr->GetNode()->GetCastAlias());
  209. else
  210. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  211. }
  212. //! Restrict minimum value
  213. virtual void ImposeMin(int64_t Value)
  214. {
  215. if(ref::m_Ptr)
  216. return ref::m_Ptr->ImposeMin(Value);
  217. else
  218. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  219. }
  220. //! Restrict maximum value
  221. virtual void ImposeMax(int64_t Value)
  222. {
  223. if(ref::m_Ptr)
  224. return ref::m_Ptr->ImposeMax(Value);
  225. else
  226. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  227. }
  228. };
  229. //! Reference to an IInteger pointer
  230. //! \ingroup GenApi_PublicImpl
  231. typedef CIntegerRefT<IInteger> CIntegerRef;
  232. #endif
  233. }
  234. #pragma warning ( pop )
  235. #endif // ifndef GENAPI_IIINTEGER_H