2005-11-20 19:24:23 +03:00
|
|
|
/*
|
2007-07-06 14:35:17 +04:00
|
|
|
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
2005-11-20 19:24:23 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Ingo Weinhold (bonefish@users.sf.net)
|
|
|
|
*/
|
2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _MESSENGER_H
|
|
|
|
#define _MESSENGER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
#include <ByteOrder.h>
|
|
|
|
#include <Message.h>
|
|
|
|
|
|
|
|
class BHandler;
|
|
|
|
class BLooper;
|
|
|
|
|
2005-11-20 19:24:23 +03:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
class BMessenger {
|
|
|
|
public:
|
|
|
|
BMessenger();
|
|
|
|
BMessenger(const char *signature, team_id team = -1,
|
|
|
|
status_t *result = NULL);
|
|
|
|
BMessenger(const BHandler *handler, const BLooper *looper = NULL,
|
|
|
|
status_t *result = NULL);
|
|
|
|
BMessenger(const BMessenger &from);
|
|
|
|
~BMessenger();
|
|
|
|
|
|
|
|
// Target
|
|
|
|
|
|
|
|
bool IsTargetLocal() const;
|
|
|
|
BHandler *Target(BLooper **looper) const;
|
|
|
|
bool LockTarget() const;
|
|
|
|
status_t LockTargetWithTimeout(bigtime_t timeout) const;
|
|
|
|
|
|
|
|
// Message sending
|
|
|
|
|
|
|
|
status_t SendMessage(uint32 command, BHandler *replyTo = NULL) const;
|
|
|
|
status_t SendMessage(BMessage *message, BHandler *replyTo = NULL,
|
|
|
|
bigtime_t timeout = B_INFINITE_TIMEOUT) const;
|
|
|
|
status_t SendMessage(BMessage *message, BMessenger replyTo,
|
|
|
|
bigtime_t timeout = B_INFINITE_TIMEOUT) const;
|
|
|
|
status_t SendMessage(uint32 command, BMessage *reply) const;
|
|
|
|
status_t SendMessage(BMessage *message, BMessage *reply,
|
|
|
|
bigtime_t deliveryTimeout = B_INFINITE_TIMEOUT,
|
|
|
|
bigtime_t replyTimeout = B_INFINITE_TIMEOUT) const;
|
|
|
|
|
|
|
|
// Operators and misc
|
|
|
|
|
|
|
|
BMessenger &operator=(const BMessenger &from);
|
|
|
|
bool operator==(const BMessenger &other) const;
|
|
|
|
|
|
|
|
bool IsValid() const;
|
|
|
|
team_id Team() const;
|
|
|
|
|
|
|
|
//----- Private or reserved -----------------------------------------
|
2003-08-26 03:33:02 +04:00
|
|
|
|
|
|
|
class Private;
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
private:
|
2003-08-26 03:33:02 +04:00
|
|
|
friend class Private;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2005-11-20 19:24:23 +03:00
|
|
|
void _SetTo(team_id team, port_id port, int32 token);
|
|
|
|
void _InitData(const char *signature, team_id team, status_t *result);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
port_id fPort;
|
|
|
|
int32 fHandlerToken;
|
|
|
|
team_id fTeam;
|
2005-11-20 19:24:23 +03:00
|
|
|
|
|
|
|
int32 _reserved[3];
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2007-07-06 14:35:17 +04:00
|
|
|
bool operator<(const BMessenger &a, const BMessenger &b);
|
|
|
|
bool operator!=(const BMessenger &a, const BMessenger &b);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#endif // _MESSENGER_H
|