vx_khr_xml.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * Copyright (c) 2012-2017 The Khronos Group Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _VX_KHR_XML_H_
  17. #define _VX_KHR_XML_H_
  18. /*! \file
  19. * \brief The OpenVX XML Schema Extension Header.
  20. *
  21. * \defgroup group_xml Extension: XML API
  22. * \brief The Khronos Extension for OpenVX XML Import and Export Support.
  23. */
  24. #define OPENVX_KHR_XML "vx_khr_xml"
  25. #include <VX/vx.h>
  26. /*! \brief The Object Type Enumeration for Imports.
  27. * \ingroup group_xml
  28. */
  29. enum vx_ext_import_type_e {
  30. VX_TYPE_IMPORT = 0x814,/*!< \brief A <tt>\ref vx_import</tt> */
  31. };
  32. /*! \brief The import type enumeration.
  33. * \ingroup group_xml
  34. * \see VX_IMPORT_ATTRIBUTE_TYPE
  35. */
  36. enum vx_ext_import_types_e {
  37. VX_IMPORT_TYPE_XML = 0,/*!< \brief The XML import type */
  38. };
  39. /*! \brief The import attributes list
  40. * \ingroup group_xml
  41. * \see vxQueryImport
  42. */
  43. enum vx_import_attribute_e {
  44. /*! \brief Returns the number of references in the import object. Use a <tt>\ref vx_uint32</tt> parameter.*/
  45. VX_IMPORT_ATTRIBUTE_COUNT = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_IMPORT) + 0x0,
  46. /*! \brief Returns the type of import. Use a <tt>\ref vx_ext_import_types_e </tt> parameter */
  47. VX_IMPORT_ATTRIBUTE_TYPE = VX_ATTRIBUTE_BASE(VX_ID_KHRONOS, VX_TYPE_IMPORT) + 0x1,
  48. };
  49. /*! \brief An abstract handle to an import object.
  50. * \ingroup group_xml
  51. * \extends vx_reference
  52. */
  53. typedef struct _vx_import *vx_import;
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57. /*! \brief Exports all objects in the context to an XML file which uses the OpenVX
  58. * XML Schema.
  59. * \param [in] context The context to export.
  60. * \param [in] xmlfile The file name to write the XML into.
  61. * \note The reference numbers contained in the xml file can appear in any order but
  62. * should be inclusive from index number 0 to [number of references - 1]. For example,
  63. * if there are 20 references in the xml file, none of the reference indices should be >= 20.
  64. * \return A <tt>\ref vx_status_e</tt> enumeration.
  65. * \see https://www.khronos.org/registry/vx/schema/openvx-1-1.xsd
  66. * \ingroup group_xml
  67. */
  68. VX_API_ENTRY vx_status VX_API_CALL vxExportToXML(vx_context context, vx_char xmlfile[]);
  69. /*! \brief Imports all framework and data objects from an XML file into the given context.
  70. * \param [in] context The context to import into.
  71. * \param [in] xmlfile The XML file to read.
  72. * \note The reference indices in the import object corresponds with the reference numbers in the
  73. * XML file. It is assumed that the program has some means to know which references to use from
  74. * imported list (either by name: <tt>\ref vxGetImportReferenceByName</tt>, or by index from looking at the XML
  75. * file (debug use case): <tt>\ref vxGetImportReferenceByIndex</tt>). Alternativly, the program can use
  76. * <tt>\ref vxGetImportReferenceByIndex</tt> in a loop and query each one to understand what was imported. After
  77. * all references of interest have been retrieved, this import obects should be released using
  78. * <tt>\ref vxReleaseImport</tt>.
  79. * \return \ref vx_import object containing references to the imported objects in the context
  80. * \see https://www.khronos.org/registry/vx/schema/openvx-1-1.xsd
  81. * \ingroup group_xml
  82. */
  83. VX_API_ENTRY vx_import VX_API_CALL vxImportFromXML(vx_context context, vx_char xmlfile[]);
  84. /*! \brief Used to retrieve a reference by name from the import when the name is known beforehand. If
  85. * multiple references have the same name, then *any* one of them may be returned.
  86. * \param [in] import The reference to the import object.
  87. * \param [in] name The reference string name.
  88. * \return <tt>\ref vx_reference</tt>
  89. * \retval 0 Invalid import object or name does not match a reference in the import object.
  90. * \retval * The reference matching the requested name.
  91. * \note Use <tt>\ref vxReleaseReference</tt> to release the reference before releasing the context.
  92. * \pre <tt>\ref vxImportFromXML</tt>
  93. * \ingroup group_xml
  94. */
  95. VX_API_ENTRY vx_reference VX_API_CALL vxGetImportReferenceByName(vx_import import, const vx_char *name);
  96. /*! \brief Used to retrieve a reference by the index from the import.
  97. * \param [in] import The reference to the import object.
  98. * \param [in] index The index of the reference in the import object to return.
  99. * \return <tt>\ref vx_reference</tt>
  100. * \retval 0 Invalid import object or index.
  101. * \retval * The reference at the requested index number.
  102. * \note Use <tt>\ref vxQueryImport</tt> with <tt>\ref VX_IMPORT_ATTRIBUTE_COUNT</tt> to retrieve
  103. * the upper limit of references in the import.
  104. * \note Use <tt>\ref vxReleaseReference</tt> to release the reference before releasing the context.
  105. * \pre <tt>\ref vxImportFromXML</tt>
  106. * \ingroup group_xml
  107. */
  108. VX_API_ENTRY vx_reference VX_API_CALL vxGetImportReferenceByIndex(vx_import import, vx_uint32 index);
  109. /*! \brief Used to query the import about its properties.
  110. * \param [in] import The reference to the import object.
  111. * \param [in] attribute The <tt>\ref vx_import_attribute_e</tt> value to query for.
  112. * \param [out] ptr The location at which the resulting value will be stored.
  113. * \param [in] size The size of the container to which ptr points.
  114. * \return A <tt>\ref vx_status_e</tt> enumeration.
  115. * \pre <tt>\ref vxImportFromXML</tt>
  116. * \ingroup group_xml
  117. */
  118. VX_API_ENTRY vx_status VX_API_CALL vxQueryImport(vx_import import, vx_enum attribute, void *ptr, vx_size size);
  119. /*! \brief Releases a reference to an import object.
  120. * Also internally releases its references to its imported objects. These
  121. * imported objects may not be garbage collected until their total reference
  122. * counts are zero.
  123. * \param [in] import The pointer to the import object to release.
  124. * \return A <tt>\ref vx_status_e</tt> enumeration.
  125. * \retval VX_SUCCESS No errors.
  126. * \retval VX_ERROR_INVALID_REFERENCE If import is not a <tt>\ref vx_import</tt>.
  127. * \note After returning from this function the reference will be zeroed.
  128. * \pre <tt>\ref vxImportFromXML</tt>
  129. * \ingroup group_xml
  130. */
  131. VX_API_ENTRY vx_status VX_API_CALL vxReleaseImport(vx_import *import);
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif