INode.h 10 KB

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