Fix FreeBSD build.
[haiku.git] / headers / os / app / Messenger.h
blob7f5cbcaf0eaab2d2ec26ad1c67253aa6a7d659b5
1 /*
2 * Copyright 2001-2011 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Ingo Weinhold (bonefish@users.sf.net)
7 */
8 #ifndef _MESSENGER_H
9 #define _MESSENGER_H
12 #include <OS.h>
13 #include <ByteOrder.h>
14 #include <Message.h>
17 class BHandler;
18 class BLooper;
20 class BMessenger {
21 public:
22 BMessenger();
23 BMessenger(const char* signature,
24 team_id team = -1,
25 status_t* result = NULL);
26 BMessenger(const BHandler* handler,
27 const BLooper* looper = NULL,
28 status_t* result = NULL);
29 BMessenger(const BMessenger& other);
30 ~BMessenger();
32 // Target
34 bool IsTargetLocal() const;
35 BHandler* Target(BLooper **looper) const;
36 bool LockTarget() const;
37 status_t LockTargetWithTimeout(
38 bigtime_t timeout) const;
40 // Message sending
42 status_t SendMessage(uint32 command,
43 BHandler* replyTo = NULL) const;
44 status_t SendMessage(BMessage* message,
45 BHandler* replyTo = NULL,
46 bigtime_t timeout
47 = B_INFINITE_TIMEOUT) const;
48 status_t SendMessage(BMessage* message,
49 BMessenger replyTo,
50 bigtime_t timeout
51 = B_INFINITE_TIMEOUT) const;
52 status_t SendMessage(uint32 command,
53 BMessage* reply) const;
54 status_t SendMessage(BMessage* message,
55 BMessage* reply,
56 bigtime_t deliveryTimeout
57 = B_INFINITE_TIMEOUT,
58 bigtime_t replyTimeout
59 = B_INFINITE_TIMEOUT) const;
61 // Operators and misc
63 status_t SetTo(const char* signature,
64 team_id team = -1);
65 status_t SetTo(const BHandler* handler,
66 const BLooper* looper = NULL);
68 BMessenger& operator=(const BMessenger& other);
69 bool operator==(const BMessenger& other) const;
71 bool IsValid() const;
72 team_id Team() const;
74 uint32 HashValue() const;
76 //----- Private or reserved -----------------------------------------
78 class Private;
80 private:
81 friend class Private;
83 void _SetTo(team_id team, port_id port,
84 int32 token);
85 void _InitData(const char* signature,
86 team_id team, status_t* result);
87 void _InitData(const BHandler* handler,
88 const BLooper *looper,
89 status_t* result);
91 private:
92 port_id fPort;
93 int32 fHandlerToken;
94 team_id fTeam;
96 int32 _reserved[3];
99 bool operator<(const BMessenger& a, const BMessenger& b);
100 bool operator!=(const BMessenger& a, const BMessenger& b);
103 #endif // _MESSENGER_H