IInteger.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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. #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. // IInteger interface
  44. //*************************************************************
  45. /**
  46. \brief Interface for integer properties
  47. \ingroup GenApi_PublicInterface
  48. */
  49. interface GENAPI_DECL_ABSTRACT IInteger : 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(int64_t Value, bool Verify = true) = 0;
  57. //! Set node value
  58. virtual IInteger& operator=(int64_t 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 int64_t GetValue(bool Verify = false, bool IgnoreCache = false ) = 0;
  66. //! Get node value
  67. virtual int64_t operator()() = 0;
  68. //! Get node value
  69. virtual int64_t operator*() = 0;
  70. //! Get minimum value allowed
  71. virtual int64_t GetMin() = 0;
  72. //! Get maximum value allowed
  73. virtual int64_t GetMax() = 0;
  74. //! Get increment mode
  75. virtual EIncMode GetIncMode() = 0;
  76. //! Get increment
  77. virtual int64_t GetInc() = 0;
  78. //! Get list of valid value
  79. virtual int64_autovector_t GetListOfValidValues(bool bounded = true) = 0;
  80. //! Get recommended representation
  81. virtual ERepresentation GetRepresentation() = 0;
  82. //! Get the physical unit name
  83. virtual GENICAM_NAMESPACE::gcstring GetUnit() = 0;
  84. //! Restrict minimum value
  85. virtual void ImposeMin(int64_t Value) = 0;
  86. //! Restrict maximum value
  87. virtual void ImposeMax(int64_t Value) = 0;
  88. };
  89. //*************************************************************
  90. // CIntegerRef class
  91. //*************************************************************
  92. #ifndef DOXYGEN_IGNORE
  93. interface IFloat;
  94. /**
  95. \internal
  96. \brief Reference to an IInteger pointer
  97. \ingroup GenApi_PublicImpl
  98. */
  99. template <class T, class I=T>
  100. class CIntegerRefT : public CValueRefT<T, I>
  101. {
  102. typedef CValueRefT<T, I> ref;
  103. public:
  104. /*--------------------------------------------------------*/
  105. // IInteger
  106. /*--------------------------------------------------------*/
  107. //! Set node value
  108. virtual void SetValue(int64_t Value, bool Verify = true)
  109. {
  110. if(ref::m_Ptr)
  111. return ref::m_Ptr->SetValue(Value, Verify);
  112. else
  113. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  114. }
  115. //! Set node value
  116. virtual IInteger& operator=(int64_t Value)
  117. {
  118. if(ref::m_Ptr)
  119. {
  120. ref::m_Ptr->SetValue(Value);
  121. return *this;
  122. }
  123. else
  124. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  125. }
  126. //! Get node value
  127. virtual int64_t GetValue( bool Verify = false, bool IgnoreCache = false )
  128. {
  129. if(ref::m_Ptr)
  130. return ref::m_Ptr->GetValue( Verify, IgnoreCache );
  131. else
  132. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  133. }
  134. //! Get node value
  135. virtual int64_t operator()()
  136. {
  137. if(ref::m_Ptr)
  138. return ref::m_Ptr->operator()();
  139. else
  140. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  141. }
  142. //! Get node value
  143. virtual int64_t operator*()
  144. {
  145. if(ref::m_Ptr)
  146. return ref::m_Ptr->operator*();
  147. else
  148. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  149. }
  150. //! Get minimum value allowed
  151. virtual int64_t GetMin()
  152. {
  153. if(ref::m_Ptr)
  154. return ref::m_Ptr->GetMin();
  155. else
  156. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  157. }
  158. //! Get maximum value allowed
  159. virtual int64_t GetMax()
  160. {
  161. if(ref::m_Ptr)
  162. return ref::m_Ptr->GetMax();
  163. else
  164. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  165. }
  166. //! Get increment
  167. virtual EIncMode GetIncMode()
  168. {
  169. if(ref::m_Ptr)
  170. return ref::m_Ptr->GetIncMode();
  171. else
  172. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  173. }
  174. //! Get increment
  175. virtual int64_t GetInc()
  176. {
  177. if(ref::m_Ptr)
  178. return ref::m_Ptr->GetInc();
  179. else
  180. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  181. }
  182. //! Implementation of IInteger::GetListOfValidValues
  183. virtual int64_autovector_t GetListOfValidValues(bool bounded = true)
  184. {
  185. if(ref::m_Ptr)
  186. return ref::m_Ptr->GetListOfValidValues( bounded );
  187. else
  188. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  189. }
  190. //! Get recommended representation
  191. virtual ERepresentation GetRepresentation()
  192. {
  193. if(ref::m_Ptr)
  194. return ref::m_Ptr->GetRepresentation();
  195. else
  196. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  197. }
  198. //! Get the physical unit name
  199. virtual GENICAM_NAMESPACE::gcstring GetUnit()
  200. {
  201. if(ref::m_Ptr)
  202. return ref::m_Ptr->GetUnit();
  203. else
  204. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  205. }
  206. //! gets the interface of an alias node.
  207. IFloat *GetFloatAlias()
  208. {
  209. if(ref::m_Ptr)
  210. return dynamic_cast<IFloat*>(ref::m_Ptr->GetNode()->GetCastAlias());
  211. else
  212. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  213. }
  214. //! Restrict minimum value
  215. virtual void ImposeMin(int64_t Value)
  216. {
  217. if(ref::m_Ptr)
  218. return ref::m_Ptr->ImposeMin(Value);
  219. else
  220. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  221. }
  222. //! Restrict maximum value
  223. virtual void ImposeMax(int64_t Value)
  224. {
  225. if(ref::m_Ptr)
  226. return ref::m_Ptr->ImposeMax(Value);
  227. else
  228. throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
  229. }
  230. };
  231. //! Reference to an IInteger pointer
  232. //! \ingroup GenApi_PublicImpl
  233. typedef CIntegerRefT<IInteger> CIntegerRef;
  234. #endif
  235. }
  236. #ifdef _MSC_VER
  237. # pragma warning ( pop )
  238. #endif
  239. #endif // ifndef GENAPI_IIINTEGER_H