1/*
2 * Copyright (c) 1999-2000, Eric Moon.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * 1. Redistributions of source code must retain the above copyright
10 *    notice, this list of conditions, and the following disclaimer.
11 *
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions, and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * 3. The name of the author may not be used to endorse or promote products
17 *    derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31
32// observe.cpp
33
34#include "observe.h"
35
36#include <Debug.h>
37#include <Message.h>
38
39//__USE_CORTEX_NAMESPACE
40
41// -------------------------------------------------------- //
42// *** HELPERS ***
43// -------------------------------------------------------- //
44
45// * Asynchronous
46
47status_t __CORTEX_NAMESPACE__ add_observer(
48	const BMessenger&				observer,
49	const BMessenger&				target) {
50//	ASSERT(observer.IsValid());
51//	ASSERT(target.IsValid());
52
53	BMessage m(M_ADD_OBSERVER);
54	m.AddMessenger("observer", observer);
55	return target.SendMessage(&m, observer);
56}
57
58status_t __CORTEX_NAMESPACE__ remove_observer(
59	const BMessenger&				observer,
60	const BMessenger&				target) {
61//	ASSERT(observer.IsValid());
62//	ASSERT(target.IsValid());
63
64	BMessage m(M_REMOVE_OBSERVER);
65	m.AddMessenger("observer", observer);
66	return target.SendMessage(&m, observer);
67}
68
69// * Synchronous
70
71status_t __CORTEX_NAMESPACE__ add_observer(
72	const BMessenger&				observer,
73	const BMessenger&				target,
74	BMessage&								reply,
75	bigtime_t								timeout) {
76//	ASSERT(observer.IsValid());
77//	ASSERT(target.IsValid());
78
79	BMessage m(M_ADD_OBSERVER);
80	m.AddMessenger("observer", observer);
81	return target.SendMessage(&m, &reply, timeout);
82}
83
84status_t __CORTEX_NAMESPACE__ remove_observer(
85	const BMessenger&				observer,
86	const BMessenger&				target,
87	BMessage&								reply,
88	bigtime_t								timeout) {
89//	ASSERT(observer.IsValid());
90//	ASSERT(target.IsValid());
91
92	BMessage m(M_REMOVE_OBSERVER);
93	m.AddMessenger("observer", observer);
94	return target.SendMessage(&m, &reply, timeout);
95}
96
97// END -- observe.cpp --
98