Event.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 API</b>
  31. *
  32. * @b Description: Defines the Event objects and interfaces.
  33. */
  34. #ifndef _ARGUS_EVENT_H
  35. #define _ARGUS_EVENT_H
  36. namespace Argus
  37. {
  38. /**
  39. * Container representing a single event.
  40. *
  41. * Every Event will have a single EventType and will expose one or more
  42. * interfaces, with the core IEvent interface being mandatory.
  43. *
  44. * @defgroup ArgusEvent Event
  45. * @ingroup ArgusObjects
  46. */
  47. class Event : public InterfaceProvider
  48. {
  49. protected:
  50. ~Event() {}
  51. };
  52. /**
  53. * A unique identifier for a particular type of Event.
  54. *
  55. * @ingroup ArgusEvent
  56. */
  57. class EventType : public NamedUUID
  58. {
  59. public:
  60. EventType(uint32_t time_low_
  61. , uint16_t time_mid_
  62. , uint16_t time_hi_and_version_
  63. , uint16_t clock_seq_
  64. , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
  65. , const char* name)
  66. : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_,
  67. c0, c1, c2, c3, c4, c5, name)
  68. {}
  69. EventType()
  70. : NamedUUID(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "EVENT_TYPE_UNSPECIFIED")
  71. {}
  72. };
  73. /*
  74. * Core Event types
  75. */
  76. /**
  77. * Event type used to report an error.
  78. *
  79. * @defgroup ArgusEventError Error Event
  80. * @ingroup ArgusEvent
  81. */
  82. DEFINE_UUID(EventType, EVENT_TYPE_ERROR, 2c80d8b0,2bfd,11e5,a2cb,08,00,20,0c,9a,66);
  83. /**
  84. * Event type used to report when a capture starts.
  85. *
  86. * @defgroup ArgusEventCaptureStarted CaptureStarted Event
  87. * @ingroup ArgusEvent
  88. */
  89. DEFINE_UUID(EventType, EVENT_TYPE_CAPTURE_STARTED, 2c80d8b1,2bfd,11e5,a2cb,08,00,20,0c,9a,66);
  90. /**
  91. * Event type used to report when all capture processing has completed.
  92. *
  93. * @defgroup ArgusEventCaptureComplete CaptureComplete Event
  94. * @ingroup ArgusEvent
  95. */
  96. DEFINE_UUID(EventType, EVENT_TYPE_CAPTURE_COMPLETE, 2c80d8b2,2bfd,11e5,a2cb,08,00,20,0c,9a,66);
  97. /**
  98. * @class IEvent
  99. *
  100. * Interface to the common Event properties.
  101. *
  102. * @ingroup ArgusEvent
  103. */
  104. DEFINE_UUID(InterfaceID, IID_EVENT, 98bcb49e,fd7d,11e4,a322,16,97,f9,25,ec,7b);
  105. class IEvent : public Interface
  106. {
  107. public:
  108. static const InterfaceID& id() { return IID_EVENT; }
  109. /**
  110. * Returns the event type.
  111. */
  112. virtual EventType getEventType() const = 0;
  113. /**
  114. * Returns the time of the event, in nanoseconds.
  115. */
  116. virtual uint64_t getTime() const = 0;
  117. /**
  118. * Returns the capture id for the event.
  119. */
  120. virtual uint32_t getCaptureId() const = 0;
  121. protected:
  122. ~IEvent() {}
  123. };
  124. /**
  125. * @class IEventError
  126. *
  127. * Interface exposed by Events having type EVENT_TYPE_ERROR.
  128. *
  129. * @ingroup ArgusEventError
  130. */
  131. DEFINE_UUID(InterfaceID, IID_EVENT_ERROR, 13e0fc70,1ab6,11e5,b939,08,00,20,0c,9a,66);
  132. class IEventError : public Interface
  133. {
  134. public:
  135. static const InterfaceID& id() { return IID_EVENT_ERROR; }
  136. /**
  137. * Returns the Status value describing the error.
  138. */
  139. virtual Status getStatus() const = 0;
  140. protected:
  141. ~IEventError() {}
  142. };
  143. /**
  144. * @class IEventCaptureComplete
  145. *
  146. * Interface exposed by Events having type EVENT_TYPE_CAPTURE_COMPLETE
  147. *
  148. * @ingroup ArgusEventCaptureComplete
  149. */
  150. DEFINE_UUID(InterfaceID, IID_EVENT_CAPTURE_COMPLETE, 8b2b40b5,f1e4,4c4d,ae1c,f3,93,f6,54,06,d5);
  151. class IEventCaptureComplete : public Interface
  152. {
  153. public:
  154. static const InterfaceID& id() { return IID_EVENT_CAPTURE_COMPLETE; }
  155. /**
  156. * Returns all dynamic metadata associated with this capture.
  157. * The lifetime of the returned pointer is equivalent to the lifetime of this event.
  158. * NULL may be returned if no metadata is available because the
  159. * capture failed or was aborted.
  160. */
  161. virtual const CaptureMetadata* getMetadata() const = 0;
  162. /**
  163. * Returns the error status of the metadata event.
  164. * If this value is not STATUS_OK, getMetadata() will return NULL.
  165. */
  166. virtual Status getStatus() const = 0;
  167. protected:
  168. ~IEventCaptureComplete() {}
  169. };
  170. } // namespace Argus
  171. #endif // _ARGUS_EVENT_H