EventProvider.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of NVIDIA CORPORATION nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  20. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  22. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  23. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  24. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  26. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. /**
  29. * @file
  30. * <b>Libargus API: Event Provider API</b>
  31. *
  32. * @b Description: Defines the EventProvider interface.
  33. */
  34. #ifndef _ARGUS_EVENT_PROVIDER_H
  35. #define _ARGUS_EVENT_PROVIDER_H
  36. namespace Argus
  37. {
  38. /**
  39. * @class IEventProvider
  40. *
  41. * Interface for an object which generates Events (such as CaptureSession).
  42. *
  43. * Any generated Events are initially stored by the provider itself, and they
  44. * are not copied out to public EventQueues until waitForEvents() is called.
  45. * If at any time there is an event type offered by a provider that is not
  46. * accepted by an active EventQueue created by that provider, all events of
  47. * that type will be discarded.
  48. *
  49. * @ingroup ArgusCaptureSession
  50. */
  51. DEFINE_UUID(InterfaceID, IID_EVENT_PROVIDER, 523ed330,25dc,11e5,867f,08,00,20,0c,9a,66);
  52. class IEventProvider : public Interface
  53. {
  54. public:
  55. static const InterfaceID& id() { return IID_EVENT_PROVIDER; }
  56. /**
  57. * Returns a list of event types that this provider can generate.
  58. * @param[out] types A vector that will be populated by the available event types.
  59. *
  60. * @returns success/status of the call.
  61. */
  62. virtual Status getAvailableEventTypes(std::vector<EventType>* types) const = 0;
  63. /**
  64. * Creates an event queue for events of the given type(s)
  65. * @param[in] eventTypes The list of event types for the queue.
  66. * @param[out] status An optional pointer to return success/status.
  67. *
  68. * @returns the new EventQueue object, or NULL on failure.
  69. */
  70. virtual EventQueue* createEventQueue(const std::vector<EventType>& eventTypes,
  71. Status* status = NULL) = 0;
  72. /**
  73. * Waits for and transfers any pending events from the provider to the
  74. * provided queues.
  75. *
  76. * Ownership of all events transfered to a queue will be passed from the
  77. * provider to the queue, and these event object pointers will remain
  78. * valid until the queue is destroyed or until the next call to this
  79. * function with that queue. In other words, any events in a queue will be
  80. * destroyed when the queue is provided to another call of this function,
  81. * regardless of whether or not it receives any new events, or when the
  82. * queue is destroyed.
  83. *
  84. * If more than one given queue accepts events of the same type, only the
  85. * first of these queues will receive events of that type.
  86. *
  87. * Any events that are not copied to queues by this function are left in
  88. * the provider until they are queried using a queue receiving events of
  89. * that type.
  90. *
  91. * If there are no pending events of the requested types at the time this
  92. * function is called, it will block until one is available or a timeout
  93. * occurs.
  94. *
  95. * @param[in] queues The list of queues to transfer events to.
  96. * @param[in] timeout The maximum time (in nanoseconds) to wait for new events.
  97. *
  98. * @returns success/status of the call.
  99. */
  100. virtual Status waitForEvents(const std::vector<EventQueue*>& queues,
  101. uint64_t timeout = TIMEOUT_INFINITE) = 0;
  102. /**
  103. * Variant of waitForEvents() that waits for only one EventQueue.
  104. */
  105. virtual Status waitForEvents(EventQueue* queue,
  106. uint64_t timeout = TIMEOUT_INFINITE) = 0;
  107. protected:
  108. ~IEventProvider() {}
  109. };
  110. } // namespace Argus
  111. #endif // _ARGUS_EVENT_PROVIDER_H