IFloat.h 10 KB

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