headers/bsd: Add sys/queue.h.
[haiku.git] / src / kits / media / TimedEventQueue.cpp
blobcf270cea81777da336d3d68ca4225ebcf715f897
1 /***********************************************************************
2 * AUTHOR: Marcus Overhagen
3 * FILE: TimedEventQueue.cpp
4 * DESCR: used by BMediaEventLooper
5 ***********************************************************************/
7 #include <TimedEventQueue.h>
8 #include <string.h>
9 #include "TimedEventQueuePrivate.h"
10 #include "debug.h"
12 /*************************************************************
13 * struct media_timed_event
14 *************************************************************/
16 media_timed_event::media_timed_event()
18 CALLED();
19 memset(this, 0, sizeof(*this));
23 media_timed_event::media_timed_event(bigtime_t inTime,
24 int32 inType)
26 CALLED();
27 memset(this, 0, sizeof(*this));
28 event_time = inTime;
29 type = inType;
33 media_timed_event::media_timed_event(bigtime_t inTime,
34 int32 inType,
35 void *inPointer,
36 uint32 inCleanup)
38 CALLED();
39 memset(this, 0, sizeof(*this));
40 event_time = inTime;
41 type = inType;
42 pointer = inPointer;
43 cleanup = inCleanup;
47 media_timed_event::media_timed_event(bigtime_t inTime,
48 int32 inType,
49 void *inPointer,
50 uint32 inCleanup,
51 int32 inData,
52 int64 inBigdata,
53 char *inUserData,
54 size_t dataSize)
56 CALLED();
57 memset(this, 0, sizeof(*this));
58 event_time = inTime;
59 type = inType;
60 pointer = inPointer;
61 cleanup = inCleanup;
62 data = inData;
63 bigdata = inBigdata;
64 memcpy(user_data,inUserData,min_c(sizeof(media_timed_event::user_data),dataSize));
68 media_timed_event::media_timed_event(const media_timed_event &clone)
70 CALLED();
71 *this = clone;
75 void
76 media_timed_event::operator=(const media_timed_event &clone)
78 CALLED();
79 memcpy(this, &clone, sizeof(*this));
83 media_timed_event::~media_timed_event()
85 CALLED();
88 /*************************************************************
89 * global operators
90 *************************************************************/
92 bool operator==(const media_timed_event & a, const media_timed_event & b)
94 CALLED();
95 return (0 == memcmp(&a,&b,sizeof(media_timed_event)));
98 bool operator!=(const media_timed_event & a, const media_timed_event & b)
100 CALLED();
101 return (0 != memcmp(&a,&b,sizeof(media_timed_event)));
104 bool operator<(const media_timed_event & a, const media_timed_event & b)
106 CALLED();
107 return a.event_time < b.event_time;
110 bool operator>(const media_timed_event & a, const media_timed_event &b)
112 CALLED();
113 return a.event_time > b.event_time;
117 /*************************************************************
118 * public BTimedEventQueue
119 *************************************************************/
122 void *
123 BTimedEventQueue::operator new(size_t s)
125 CALLED();
126 return ::operator new(s);
130 void
131 BTimedEventQueue::operator delete(void *p, size_t s)
133 CALLED();
134 return ::operator delete(p);
138 BTimedEventQueue::BTimedEventQueue() :
139 fImp(new _event_queue_imp)
141 CALLED();
145 BTimedEventQueue::~BTimedEventQueue()
147 CALLED();
148 delete fImp;
152 status_t
153 BTimedEventQueue::AddEvent(const media_timed_event &event)
155 CALLED();
156 return fImp->AddEvent(event);
160 status_t
161 BTimedEventQueue::RemoveEvent(const media_timed_event *event)
163 CALLED();
164 return fImp->RemoveEvent(event);
168 status_t
169 BTimedEventQueue::RemoveFirstEvent(media_timed_event *outEvent)
171 CALLED();
172 return fImp->RemoveFirstEvent(outEvent);
176 bool
177 BTimedEventQueue::HasEvents() const
179 CALLED();
180 return fImp->HasEvents();
184 int32
185 BTimedEventQueue::EventCount() const
187 CALLED();
188 return fImp->EventCount();
192 const media_timed_event *
193 BTimedEventQueue::FirstEvent() const
195 CALLED();
196 return fImp->FirstEvent();
200 bigtime_t
201 BTimedEventQueue::FirstEventTime() const
203 CALLED();
204 return fImp->FirstEventTime();
208 const media_timed_event *
209 BTimedEventQueue::LastEvent() const
211 CALLED();
212 return fImp->LastEvent();
216 bigtime_t
217 BTimedEventQueue::LastEventTime() const
219 CALLED();
220 return fImp->LastEventTime();
224 const media_timed_event *
225 BTimedEventQueue::FindFirstMatch(bigtime_t eventTime,
226 time_direction direction,
227 bool inclusive,
228 int32 eventType)
230 CALLED();
231 return fImp->FindFirstMatch(eventTime, direction, inclusive, eventType);
235 status_t
236 BTimedEventQueue::DoForEach(for_each_hook hook,
237 void *context,
238 bigtime_t eventTime,
239 time_direction direction,
240 bool inclusive,
241 int32 eventType)
243 CALLED();
244 return fImp->DoForEach(hook, context, eventTime, direction, inclusive, eventType);
248 void
249 BTimedEventQueue::SetCleanupHook(cleanup_hook hook,
250 void *context)
252 CALLED();
253 fImp->SetCleanupHook(hook, context);
257 status_t
258 BTimedEventQueue::FlushEvents(bigtime_t eventTime,
259 time_direction direction,
260 bool inclusive,
261 int32 eventType)
263 CALLED();
264 return fImp->FlushEvents(eventTime, direction, inclusive, eventType);
267 /*************************************************************
268 * private BTimedEventQueue
269 *************************************************************/
272 // unimplemented
273 BTimedEventQueue::BTimedEventQueue(const BTimedEventQueue &other)
274 BTimedEventQueue &BTimedEventQueue::operator=(const BTimedEventQueue &other)
277 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_0(void *, ...) { return B_ERROR; }
278 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_1(void *, ...) { return B_ERROR; }
279 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_2(void *, ...) { return B_ERROR; }
280 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_3(void *, ...) { return B_ERROR; }
281 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_4(void *, ...) { return B_ERROR; }
282 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_5(void *, ...) { return B_ERROR; }
283 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_6(void *, ...) { return B_ERROR; }
284 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_7(void *, ...) { return B_ERROR; }
285 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_8(void *, ...) { return B_ERROR; }
286 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_9(void *, ...) { return B_ERROR; }
287 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_10(void *, ...) { return B_ERROR; }
288 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_11(void *, ...) { return B_ERROR; }
289 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_12(void *, ...) { return B_ERROR; }
290 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_13(void *, ...) { return B_ERROR; }
291 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_14(void *, ...) { return B_ERROR; }
292 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_15(void *, ...) { return B_ERROR; }
293 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_16(void *, ...) { return B_ERROR; }
294 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_17(void *, ...) { return B_ERROR; }
295 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_18(void *, ...) { return B_ERROR; }
296 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_19(void *, ...) { return B_ERROR; }
297 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_20(void *, ...) { return B_ERROR; }
298 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_21(void *, ...) { return B_ERROR; }
299 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_22(void *, ...) { return B_ERROR; }
300 status_t BTimedEventQueue::_Reserved_BTimedEventQueue_23(void *, ...) { return B_ERROR; }