xref: /haiku/src/apps/cortex/support/observe.cpp (revision b55a57da7173b9af0432bd3e148d03f06161d036)
1 // observe.cpp
2 
3 #include "observe.h"
4 
5 #include <Debug.h>
6 #include <Message.h>
7 
8 //__USE_CORTEX_NAMESPACE
9 
10 // -------------------------------------------------------- //
11 // *** HELPERS ***
12 // -------------------------------------------------------- //
13 
14 // * Asynchronous
15 
16 status_t __CORTEX_NAMESPACE__ add_observer(
17 	const BMessenger&				observer,
18 	const BMessenger&				target) {
19 //	ASSERT(observer.IsValid());
20 //	ASSERT(target.IsValid());
21 
22 	BMessage m(M_ADD_OBSERVER);
23 	m.AddMessenger("observer", observer);
24 	return target.SendMessage(&m, observer);
25 }
26 
27 status_t __CORTEX_NAMESPACE__ remove_observer(
28 	const BMessenger&				observer,
29 	const BMessenger&				target) {
30 //	ASSERT(observer.IsValid());
31 //	ASSERT(target.IsValid());
32 
33 	BMessage m(M_REMOVE_OBSERVER);
34 	m.AddMessenger("observer", observer);
35 	return target.SendMessage(&m, observer);
36 }
37 
38 // * Synchronous
39 
40 status_t __CORTEX_NAMESPACE__ add_observer(
41 	const BMessenger&				observer,
42 	const BMessenger&				target,
43 	BMessage&								reply,
44 	bigtime_t								timeout) {
45 //	ASSERT(observer.IsValid());
46 //	ASSERT(target.IsValid());
47 
48 	BMessage m(M_ADD_OBSERVER);
49 	m.AddMessenger("observer", observer);
50 	return target.SendMessage(&m, &reply, timeout);
51 }
52 
53 status_t __CORTEX_NAMESPACE__ remove_observer(
54 	const BMessenger&				observer,
55 	const BMessenger&				target,
56 	BMessage&								reply,
57 	bigtime_t								timeout) {
58 //	ASSERT(observer.IsValid());
59 //	ASSERT(target.IsValid());
60 
61 	BMessage m(M_REMOVE_OBSERVER);
62 	m.AddMessenger("observer", observer);
63 	return target.SendMessage(&m, &reply, timeout);
64 }
65 
66 // END -- observe.cpp --
67