INode.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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 interface INode and types NodeList_t and CallbackHandleType:
  28. \ingroup GenApi_PublicInterface
  29. */
  30. #ifndef GENAPI_INODE_H
  31. #define GENAPI_INODE_H
  32. #include <Base/GCString.h>
  33. #include <GenApi/GenApiDll.h>
  34. #include <GenApi/Types.h>
  35. #include <GenApi/IBase.h>
  36. #include <GenApi/Container.h>
  37. #include <assert.h>
  38. #ifdef _MSC_VER
  39. # pragma warning ( push )
  40. # pragma warning ( disable : 4251 ) // XXX needs to have dll-interface to be used by clients of class YYY
  41. #endif
  42. namespace GENAPI_NAMESPACE
  43. {
  44. interface INode;
  45. interface INodeMap;
  46. //! a list of node references
  47. typedef node_vector NodeList_t;
  48. //! the callback handle for nodes
  49. typedef intptr_t CallbackHandleType;
  50. class CNodeCallback;
  51. //*************************************************************
  52. // INode interface
  53. //*************************************************************
  54. /**
  55. \brief Interface common to all nodes
  56. \ingroup GenApi_PublicInterface
  57. */
  58. interface GENAPI_DECL_ABSTRACT INode : virtual public IBase
  59. {
  60. //! Get node name
  61. virtual GENICAM_NAMESPACE::gcstring GetName(bool FullQualified=false) const = 0;
  62. //! Get name space
  63. virtual GENAPI_NAMESPACE::ENameSpace GetNameSpace() const = 0;
  64. //! Get the recommended visibility of the node
  65. virtual EVisibility GetVisibility() const = 0;
  66. //! Indicates that the node's value may have changed.
  67. /*! Fires the callback on this and all dependent nodes */
  68. virtual void InvalidateNode() = 0;
  69. //! Is the node value cachable
  70. virtual bool IsCachable() const = 0;
  71. //! True if the AccessMode can be cached
  72. virtual EYesNo IsAccessModeCacheable() const = 0;
  73. //! Get Caching Mode
  74. virtual ECachingMode GetCachingMode() const = 0;
  75. //! recommended polling time (for not cachable nodes)
  76. virtual int64_t GetPollingTime() const = 0;
  77. //! Get a short description of the node
  78. virtual GENICAM_NAMESPACE::gcstring GetToolTip() const = 0;
  79. //! Get a long description of the node
  80. virtual GENICAM_NAMESPACE::gcstring GetDescription() const = 0;
  81. //! Get a name string for display
  82. virtual GENICAM_NAMESPACE::gcstring GetDisplayName() const = 0;
  83. //! Get a name of the device
  84. virtual GENICAM_NAMESPACE::gcstring GetDeviceName() const = 0;
  85. /*!
  86. \brief Get all nodes this node directly depends on.
  87. \param[out] Children List of children nodes
  88. \param LinkType The link type
  89. */
  90. virtual void GetChildren(GENAPI_NAMESPACE::NodeList_t &Children, ELinkType LinkType=ctReadingChildren) const = 0;
  91. /*!
  92. \brief Gets all nodes this node is directly depending on
  93. \param[out] Parents List of parent nodes
  94. */
  95. virtual void GetParents(GENAPI_NAMESPACE::NodeList_t &Parents) const = 0;
  96. //! Register change callback
  97. /*! Takes ownership of the CNodeCallback object */
  98. virtual CallbackHandleType RegisterCallback( CNodeCallback *pCallback ) = 0;
  99. //! De register change callback
  100. /*! Destroys CNodeCallback object
  101. \return true if the callback handle was valid
  102. */
  103. virtual bool DeregisterCallback( CallbackHandleType hCallback ) = 0;
  104. //! Retrieves the central node map
  105. virtual INodeMap* GetNodeMap() const = 0;
  106. //! Get the EventId of the node
  107. virtual GENICAM_NAMESPACE::gcstring GetEventID() const = 0;
  108. //! True if the node is streamable
  109. virtual bool IsStreamable() const = 0;
  110. //! Returns a list of the names all properties set during initialization
  111. virtual void GetPropertyNames(GENICAM_NAMESPACE::gcstring_vector &PropertyNames) const = 0;
  112. //! Retrieves a property plus an additional attribute by name
  113. /*! If a property has multiple values/attribute they come with Tabs as delimiters */
  114. virtual bool GetProperty(const GENICAM_NAMESPACE::gcstring& PropertyName, GENICAM_NAMESPACE::gcstring& ValueStr, GENICAM_NAMESPACE::gcstring& AttributeStr) = 0;
  115. //! Imposes an access mode to the natural access mode of the node
  116. virtual void ImposeAccessMode(EAccessMode ImposedAccessMode) = 0;
  117. //! Imposes a visibility to the natural visibility of the node
  118. virtual void ImposeVisibility(EVisibility ImposedVisibility) = 0;
  119. //! Retrieves the a node which describes the same feature in a different way
  120. virtual INode* GetAlias() const = 0;
  121. //! Retrieves the a node which describes the same feature so that it can be casted
  122. virtual INode* GetCastAlias() const = 0;
  123. //! Gets a URL pointing to the documentation of that feature
  124. virtual GENICAM_NAMESPACE::gcstring GetDocuURL() const = 0;
  125. //! True if the node should not be used any more
  126. virtual bool IsDeprecated() const = 0;
  127. //! Get the type of the main interface of a node
  128. virtual EInterfaceType GetPrincipalInterfaceType() const = 0;
  129. //! True if the node can be reached via category nodes from a category node named "Root"
  130. virtual bool IsFeature() const = 0;
  131. };
  132. //! \addtogroup GenApi_PublicInterface
  133. //! \{
  134. //! Tests if readable
  135. inline bool IsReadable( EAccessMode AccessMode )
  136. {
  137. return RO == AccessMode || RW == AccessMode;
  138. }
  139. //! Checks if a node is readable
  140. inline bool IsReadable( const IBase* p)
  141. {
  142. return (p != NULL) && IsReadable( p->GetAccessMode() );
  143. }
  144. //! Checks if a node is readable
  145. inline bool IsReadable( const IBase& r)
  146. {
  147. return IsReadable( r.GetAccessMode() );
  148. }
  149. //! Tests if writable
  150. inline bool IsWritable( EAccessMode AccessMode )
  151. {
  152. return WO == AccessMode || RW == AccessMode;
  153. }
  154. //! Checks if a node is writable
  155. inline bool IsWritable( const IBase* p)
  156. {
  157. return (p != NULL) && IsWritable( p->GetAccessMode() );
  158. }
  159. //! Checks if a node is writable
  160. inline bool IsWritable( const IBase& r)
  161. {
  162. return IsWritable( r.GetAccessMode() );
  163. }
  164. //! Tests if implemented
  165. inline bool IsImplemented( EAccessMode AccessMode )
  166. {
  167. return AccessMode != NI;
  168. }
  169. //! Checks if a node is implemented
  170. inline bool IsImplemented( const IBase* p)
  171. {
  172. return (p != NULL) && IsImplemented(p->GetAccessMode() );
  173. }
  174. //! Checks if a node is implemented
  175. inline bool IsImplemented( const IBase& r)
  176. {
  177. return IsImplemented(&r);
  178. }
  179. //! Tests if available
  180. inline bool IsAvailable( EAccessMode AccessMode )
  181. {
  182. return ! ( AccessMode == NA || AccessMode == NI );
  183. }
  184. //! Checks if a node is available
  185. inline bool IsAvailable( const IBase* p)
  186. {
  187. return (p != NULL) && IsAvailable(p->GetAccessMode() );
  188. }
  189. //! Checks if a node is available
  190. inline bool IsAvailable( const IBase& r)
  191. {
  192. return IsAvailable(r.GetAccessMode() );
  193. }
  194. //! Computes which access mode the two guards allow together
  195. inline EAccessMode Combine(EAccessMode Peter, EAccessMode Paul)
  196. {
  197. assert( Peter != _UndefinedAccesMode );
  198. assert( Paul != _UndefinedAccesMode );
  199. if( Peter == NI || Paul == NI )
  200. return NI;
  201. else if( Peter == NA || Paul == NA )
  202. return NA;
  203. else if( (Peter == RO && Paul == WO) || (Peter == WO && Paul == RO) )
  204. return NA;
  205. else if( Peter == WO || Paul == WO )
  206. return WO;
  207. else if( Peter == RO || Paul == RO )
  208. return RO;
  209. else
  210. return RW;
  211. }
  212. //! Tests Visibility
  213. /*! CAVE : this relys on the EVisibility enum's coding */
  214. inline bool IsVisible( EVisibility Visibility, EVisibility MaxVisiblity )
  215. {
  216. return (Visibility <= MaxVisiblity);
  217. }
  218. //! Computes which visibility the two guards allow together
  219. inline EVisibility Combine(EVisibility Peter, EVisibility Paul)
  220. {
  221. assert( Peter != _UndefinedVisibility );
  222. assert( Paul != _UndefinedVisibility );
  223. if( Peter == Invisible || Paul == Invisible )
  224. return Invisible;
  225. else if( Peter == Guru || Paul == Guru )
  226. return Guru;
  227. else if( Peter == Expert || Paul == Expert )
  228. return Expert;
  229. else
  230. return Beginner;
  231. }
  232. //! Tests Cacheability
  233. inline bool IsCacheable( ECachingMode CachingMode )
  234. {
  235. return (CachingMode != NoCache);
  236. }
  237. //! Computes which CachingMode results from a combination
  238. inline ECachingMode Combine(ECachingMode Peter, ECachingMode Paul)
  239. {
  240. assert( Peter != _UndefinedCachingMode );
  241. assert( Paul != _UndefinedCachingMode );
  242. if( Peter == NoCache || Paul == NoCache )
  243. return NoCache;
  244. else if( Peter == WriteAround || Paul == WriteAround )
  245. return WriteAround;
  246. else
  247. return WriteThrough;
  248. }
  249. //! \}
  250. }
  251. #ifdef _MSC_VER
  252. # pragma warning ( pop )
  253. #endif
  254. #endif // ifndef GENAPI_INODE_H