IFloat.h 10 KB

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