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