197398464SJohn Scipione/* 297398464SJohn Scipione * Copyright 2001-2015 Haiku, Inc. All rights reserved. 397398464SJohn Scipione * Distributed under the terms of the MIT License. 497398464SJohn Scipione * 597398464SJohn Scipione * Authors: 697398464SJohn Scipione * John Scipione, jscipione@gmail.com 797398464SJohn Scipione * Ingo Weinhold, bonefish@users.sf.net 897398464SJohn Scipione * 997398464SJohn Scipione * Corresponds to: 1097398464SJohn Scipione * headers/os/app/Messenger.h hrev48689 1197398464SJohn Scipione * src/kits/app/Messenger.cpp hrev48689 1297398464SJohn Scipione */ 1397398464SJohn Scipione 1497398464SJohn Scipione 1597398464SJohn Scipione/*! 1697398464SJohn Scipione \file Messenger.h 1797398464SJohn Scipione \ingroup app 1897398464SJohn Scipione \ingroup libbe 19fd3c25a9SJohn Scipione \brief Provides the BMessenger class and some BMessenger operator 20fd3c25a9SJohn Scipione functions. 2197398464SJohn Scipione*/ 2297398464SJohn Scipione 2397398464SJohn Scipione 2497398464SJohn Scipione/*! 2597398464SJohn Scipione \class BMessenger 2697398464SJohn Scipione \ingroup app 2797398464SJohn Scipione \ingroup libbe 2897398464SJohn Scipione \brief A class to send messages to a target BLooper or BHandler. 2997398464SJohn Scipione 3097398464SJohn Scipione A BMessenger can send messages to local and remote targets. If the target 3197398464SJohn Scipione belongs to the same team as the BMessenger it is a local target, otherwise 3297398464SJohn Scipione if the target lives in a separate address space it is a remote target. 3397398464SJohn Scipione 3497398464SJohn Scipione The most significant (set of) method(s) in the class is SendMessage(), 3597398464SJohn Scipione which sends its message to the target. For a local target SendMessage() 3697398464SJohn Scipione is roughly equivalent in terms of efficiency to posting a message 372eb2dcfaSJohn Scipione directly to the messenger's target (i.e. BLooper::PostMessage()). 3897398464SJohn Scipione 39*151a4f7fSJohn Scipione If you supply a target BMessenger or BHandler to SendMessage() the method 40*151a4f7fSJohn Scipione will return immediately after delivery and the response will be handled 41*151a4f7fSJohn Scipione asynchronously, otherwise the method will return once the reply has been 42*151a4f7fSJohn Scipione delivered or after a set timeout. 43*151a4f7fSJohn Scipione 4497398464SJohn Scipione The global \a be_app_messenger pointer targets the main message 4597398464SJohn Scipione loop of \a be_app is automatically initialized for you when you create 4697398464SJohn Scipione a BApplication object, you can use it wherever a BMessenger is called for. 4797398464SJohn Scipione 4897398464SJohn Scipione \since BeOS R3 4997398464SJohn Scipione*/ 5097398464SJohn Scipione 5197398464SJohn Scipione 5297398464SJohn Scipione/*! 5397398464SJohn Scipione \fn BMessenger::BMessenger() 5497398464SJohn Scipione \brief Creates an uninitialized BMessenger. 5597398464SJohn Scipione 5697398464SJohn Scipione \since BeOS R3 5797398464SJohn Scipione*/ 5897398464SJohn Scipione 5997398464SJohn Scipione 6097398464SJohn Scipione/*! 6197398464SJohn Scipione \fn BMessenger::BMessenger(const char* signature, team_id team, 6297398464SJohn Scipione status_t* result) 6397398464SJohn Scipione \brief Creates a BMessenger and initializes it to target the already 6497398464SJohn Scipione running application identified by its signature and/or team ID. 6597398464SJohn Scipione 6697398464SJohn Scipione When only a \a signature is given, and multiple instances of the application 6797398464SJohn Scipione are running it is indeterminate which one is chosen as the target. In case 6897398464SJohn Scipione only a \a team ID is passed, the target application is identified uniquely. 6997398464SJohn Scipione If both are supplied, the application identified by the \a team ID must have 7097398464SJohn Scipione a matching signature, otherwise the initialization fails. 7197398464SJohn Scipione 7297398464SJohn Scipione \param signature The target application's signature. May be \c NULL. 7397398464SJohn Scipione \param team The target application's team ID. May be < 0. 7497398464SJohn Scipione \param result An optional pointer to a pre-allocated status_t into which 7597398464SJohn Scipione the result of the initialization is written. 7697398464SJohn Scipione 7797398464SJohn Scipione \since BeOS R3 7897398464SJohn Scipione*/ 7997398464SJohn Scipione 8097398464SJohn Scipione 8197398464SJohn Scipione/*! 8297398464SJohn Scipione \fn BMessenger::BMessenger(const BHandler* handler, const BLooper* looper, 8397398464SJohn Scipione status_t* _result) 8497398464SJohn Scipione \brief Creates a BMessenger and initializes it to target the local 8597398464SJohn Scipione BHandler and/or BLooper. 8697398464SJohn Scipione 8797398464SJohn Scipione When a \c NULL \a handler is supplied, the preferred handler in the 8897398464SJohn Scipione \a looper is targeted. If no \a looper is supplied the looper that \a handler 8997398464SJohn Scipione belongs to is used instead -- that means in particular, that the \a handler 9097398464SJohn Scipione must already belong to a looper. If both are supplied the \a handler must 9197398464SJohn Scipione belong to the \a looper. 9297398464SJohn Scipione 9397398464SJohn Scipione \param handler The target handler. May be \c NULL. 9497398464SJohn Scipione \param looper The target looper. May be \c NULL. 9597398464SJohn Scipione \param _result An optional pointer to a pre-allocated status_t into which 9697398464SJohn Scipione the result of the initialization is written. 9797398464SJohn Scipione 9897398464SJohn Scipione \since BeOS R3 9997398464SJohn Scipione*/ 10097398464SJohn Scipione 10197398464SJohn Scipione 10297398464SJohn Scipione/*! 10397398464SJohn Scipione \fn BMessenger::BMessenger(const BMessenger& other) 10497398464SJohn Scipione \brief Creates a BMessenger and initializes it to have the same target 10597398464SJohn Scipione as the supplied messenger. 10697398464SJohn Scipione 10797398464SJohn Scipione \since BeOS R3 10897398464SJohn Scipione*/ 10997398464SJohn Scipione 11097398464SJohn Scipione 11197398464SJohn Scipione/*! 11297398464SJohn Scipione \fn BMessenger::~BMessenger() 11397398464SJohn Scipione \brief Frees all resources associated with this object. 11497398464SJohn Scipione 11597398464SJohn Scipione \since BeOS R3 11697398464SJohn Scipione*/ 11797398464SJohn Scipione 11897398464SJohn Scipione 11997398464SJohn Scipione/*! 12097398464SJohn Scipione \name Target 12197398464SJohn Scipione*/ 12297398464SJohn Scipione 12397398464SJohn Scipione 12497398464SJohn Scipione//! @{ 12597398464SJohn Scipione 12697398464SJohn Scipione 12797398464SJohn Scipione/*! 12897398464SJohn Scipione \fn bool BMessenger::IsTargetLocal() const 12997398464SJohn Scipione \brief Returns whether the messenger and target belong to the same team. 13097398464SJohn Scipione 13197398464SJohn Scipione \return \c true if the messenger is properly initialized and its target 13297398464SJohn Scipione belong ot the same team, \c false if they reside in separate 13397398464SJohn Scipione address spaces. 13497398464SJohn Scipione 13597398464SJohn Scipione \since BeOS R3 13697398464SJohn Scipione*/ 13797398464SJohn Scipione 13897398464SJohn Scipione 13997398464SJohn Scipione 14097398464SJohn Scipione/*! 14197398464SJohn Scipione \fn BHandler* BMessenger::Target(BLooper** _looper) const 14297398464SJohn Scipione \brief Returns the handler and looper targeted by the messenger 14397398464SJohn Scipione (if the target is local). 14497398464SJohn Scipione 14597398464SJohn Scipione The handler is returned directly, the looper by reference. If both are 14697398464SJohn Scipione \c NULL, the object is either not properly initialized, the target 14797398464SJohn Scipione objects have been deleted or the target is remote. If only the returned 14897398464SJohn Scipione handler is \c NULL, either the looper's preferred handler is targeted or 14997398464SJohn Scipione the handler has been deleted. 15097398464SJohn Scipione 15197398464SJohn Scipione \param _looper A pointer to a pre-allocated BLooper pointer into which 15297398464SJohn Scipione the pointer to the targeted looper is written. 15397398464SJohn Scipione 15497398464SJohn Scipione \return The BHandler targeted by the messenger. 15597398464SJohn Scipione 15697398464SJohn Scipione \since BeOS R3 15797398464SJohn Scipione*/ 15897398464SJohn Scipione 15997398464SJohn Scipione 16097398464SJohn Scipione/*! 16197398464SJohn Scipione \fn bool BMessenger::LockTarget() const 16297398464SJohn Scipione \brief Locks the BLooper targeted by the messenger 16397398464SJohn Scipione (if the target is local). 16497398464SJohn Scipione 16597398464SJohn Scipione This method is a shorthand for retrieving the targeted looper via 16697398464SJohn Scipione Target() and calling BLooper::Lock() on the looper afterwards. 16797398464SJohn Scipione 16897398464SJohn Scipione \see BLooper::Lock() for details. 16997398464SJohn Scipione 17097398464SJohn Scipione \return \c true, if the looper was locked successfully, \c false, if 17197398464SJohn Scipione the messenger was not properly initialized, the target was remote, 17297398464SJohn Scipione or the targeted looper was invalid. 17397398464SJohn Scipione 17497398464SJohn Scipione \since BeOS R3 17597398464SJohn Scipione*/ 17697398464SJohn Scipione 17797398464SJohn Scipione 17897398464SJohn Scipione 17997398464SJohn Scipione/*! 18097398464SJohn Scipione \fn status_t BMessenger::LockTargetWithTimeout(bigtime_t timeout) const 18197398464SJohn Scipione \brief Locks the BLooper targeted by the messenger with a \a timeout 18297398464SJohn Scipione (if the target is local). 18397398464SJohn Scipione 18497398464SJohn Scipione This method is a shorthand for retrieving the targeted looper via 18597398464SJohn Scipione Target() and calling BLooper::LockWithTimeout() on the looper afterwards. 18697398464SJohn Scipione 18797398464SJohn Scipione \see BLooper::LockWithTimeout() for details. 18897398464SJohn Scipione 18997398464SJohn Scipione \return A status code, \c B_OK on success or an error code otherwise, 19097398464SJohn Scipione all other error codes returned by BLooper::LockWithTimeout(). 19197398464SJohn Scipione \retval B_OK if the looper could be locked successfully, 19297398464SJohn Scipione \retval B_BAD_VALUE if the messenger is not properly initialized, 19397398464SJohn Scipione the target is remote, or the targeted looper is invalid. 19497398464SJohn Scipione 19597398464SJohn Scipione \see BLooper::LockWithTimeout() for more error codes. 19697398464SJohn Scipione 19797398464SJohn Scipione \since BeOS R3 19897398464SJohn Scipione*/ 19997398464SJohn Scipione 20097398464SJohn Scipione 20197398464SJohn Scipione//! @} 20297398464SJohn Scipione 20397398464SJohn Scipione 20497398464SJohn Scipione/*! 20597398464SJohn Scipione \name SendMessage 20697398464SJohn Scipione*/ 20797398464SJohn Scipione 20897398464SJohn Scipione 20997398464SJohn Scipione//! @{ 21097398464SJohn Scipione 21197398464SJohn Scipione 21297398464SJohn Scipione/*! 21397398464SJohn Scipione \fn status_t BMessenger::SendMessage(uint32 command, BHandler* replyTo) const 214*151a4f7fSJohn Scipione \brief Delivers a BMessage with \a command \c what identifier to the 215*151a4f7fSJohn Scipione messenger's target. A response may be sent to the \a replyTo handler 216*151a4f7fSJohn Scipione asynchronously. 21797398464SJohn Scipione 21897398464SJohn Scipione If the target's message port is full, the method waits indefinitely, until 21997398464SJohn Scipione space becomes available in the port. After delivery the method returns 22097398464SJohn Scipione immediately. It does not wait until the target processes the message or 22197398464SJohn Scipione even sends a reply. 22297398464SJohn Scipione 22397398464SJohn Scipione \param command The what field of the message to deliver. 22497398464SJohn Scipione \param replyTo The handler to which a reply to the message shall be sent. 22597398464SJohn Scipione May be \c NULL. 22697398464SJohn Scipione 22797398464SJohn Scipione \return A status code, \c B_OK on success or an error code otherwise. 22897398464SJohn Scipione \retval B_OK Everything went fine. 22997398464SJohn Scipione \retval B_BAD_PORT_ID The messenger is not properly initialized or its 23097398464SJohn Scipione target doesn't exist anymore. 23197398464SJohn Scipione 23297398464SJohn Scipione \since BeOS R3 23397398464SJohn Scipione*/ 23497398464SJohn Scipione 23597398464SJohn Scipione 23697398464SJohn Scipione/*! 23797398464SJohn Scipione \fn status_t BMessenger::SendMessage(BMessage* message, BHandler* replyTo, 23897398464SJohn Scipione bigtime_t timeout) const 239*151a4f7fSJohn Scipione \brief Delivers a \a message to the messenger's target. A response message 240*151a4f7fSJohn Scipione may be sent back to the \a replyTo handler asynchronously. 24197398464SJohn Scipione 24297398464SJohn Scipione A copy of the supplied message is sent and the caller retains ownership 24397398464SJohn Scipione of \a message. 24497398464SJohn Scipione 24597398464SJohn Scipione If the target's message port is full, the method waits until space becomes 24697398464SJohn Scipione available in the port or the specified timeout occurs (whichever happens 24797398464SJohn Scipione first). After delivery the method returns immediately. It does not wait 24897398464SJohn Scipione until the target processes the message or even sends a reply. 24997398464SJohn Scipione 250*151a4f7fSJohn Scipione This method does not return by default until the message has been delivered. 251*151a4f7fSJohn Scipione You can set a delivery \a timeout in microseconds. 252*151a4f7fSJohn Scipione 25397398464SJohn Scipione \param message The message to be sent. 254*151a4f7fSJohn Scipione \param replyTo The handler for a response message to be sent. 25597398464SJohn Scipione May be \c NULL. 256*151a4f7fSJohn Scipione \param timeout The message delivery timeout in microseconds. (optional) 25797398464SJohn Scipione 25897398464SJohn Scipione \return A status code, \c B_OK on success or an error code otherwise. 25997398464SJohn Scipione \retval B_OK Everything went fine. 26097398464SJohn Scipione \retval B_BAD_PORT_ID The messenger was not properly initialized or its 26197398464SJohn Scipione target didn't exist. 26297398464SJohn Scipione \retval B_WOULD_BLOCK A delivery timeout of 0 was supplied and the target 26397398464SJohn Scipione port was full when trying to deliver the message. 26497398464SJohn Scipione \retval B_TIMED_OUT The timeout expired while trying to deliver the 26597398464SJohn Scipione message. 26697398464SJohn Scipione 26797398464SJohn Scipione \since BeOS R3 26897398464SJohn Scipione*/ 26997398464SJohn Scipione 27097398464SJohn Scipione 27197398464SJohn Scipione/*! 27297398464SJohn Scipione \fn status_t BMessenger::SendMessage(BMessage* message, BMessenger replyTo, 27397398464SJohn Scipione bigtime_t timeout) const 274*151a4f7fSJohn Scipione \brief Delivers a \a message to the messenger's target. A response message 275*151a4f7fSJohn Scipione may be sent back to the \a replyTo messenger's target asynchronously. 27697398464SJohn Scipione 27797398464SJohn Scipione A copy of the supplied message is sent and the caller retains ownership 27897398464SJohn Scipione of \a message. 27997398464SJohn Scipione 28097398464SJohn Scipione If the target's message port is full, the method waits until space becomes 28197398464SJohn Scipione available in the port or the specified timeout occurs (whichever happens 28297398464SJohn Scipione first). After delivery the method returns immediately. It does not wait 28397398464SJohn Scipione until the target processes the message or even sends a reply. 28497398464SJohn Scipione 285*151a4f7fSJohn Scipione This method does not return by default until the message has been delivered. 286*151a4f7fSJohn Scipione You can set a delivery \a timeout in microseconds. 287*151a4f7fSJohn Scipione 28897398464SJohn Scipione \param message The message to be sent. 289*151a4f7fSJohn Scipione \param replyTo A messenger specifying the target for a response message. 290*151a4f7fSJohn Scipione \param timeout The message delivery timeout in microseconds. (optional) 29197398464SJohn Scipione 29297398464SJohn Scipione \return A status code, \c B_OK on success or an error code otherwise. 29397398464SJohn Scipione \retval B_OK Everything went fine. 29497398464SJohn Scipione \retval B_BAD_PORT_ID The messenger was not properly initialized or its 29597398464SJohn Scipione target didn't exist. 29697398464SJohn Scipione \retval B_WOULD_BLOCK A delivery timeout of 0 was supplied and the target 29797398464SJohn Scipione port was full when trying to deliver the message. 29897398464SJohn Scipione \retval B_TIMED_OUT The timeout expired while trying to deliver the 29997398464SJohn Scipione message. 30097398464SJohn Scipione 30197398464SJohn Scipione \since BeOS R4 30297398464SJohn Scipione*/ 30397398464SJohn Scipione 30497398464SJohn Scipione 30597398464SJohn Scipione/*! 30697398464SJohn Scipione \fn status_t BMessenger::SendMessage(uint32 command, BMessage* reply) const 307*151a4f7fSJohn Scipione \brief Delivers a BMessage with \a command \c what identifier to the 308*151a4f7fSJohn Scipione messenger's target and waits for a \a reply BMessage synchronously. 30997398464SJohn Scipione 31097398464SJohn Scipione The method does wait for a reply. The reply message is copied into 31197398464SJohn Scipione \a reply. If the target doesn't send a reply, the \c what field of 31297398464SJohn Scipione \a reply is set to \c B_NO_REPLY. 31397398464SJohn Scipione 31497398464SJohn Scipione \param command The what field of the message to deliver. 315*151a4f7fSJohn Scipione \param reply A pointer to a pre-allocated BMessage object which the reply 316*151a4f7fSJohn Scipione message will be copied into. 31797398464SJohn Scipione 31897398464SJohn Scipione \return A status code, \c B_OK on success or an error code otherwise. 31997398464SJohn Scipione \retval B_OK Everything went fine. 32097398464SJohn Scipione \retval B_BAD_PORT_ID The messenger was not properly initialized or its 32197398464SJohn Scipione target didn't exist. 32297398464SJohn Scipione \retval B_NO_MORE_PORTS All reply ports were in use. 32397398464SJohn Scipione 32497398464SJohn Scipione \since BeOS R3 32597398464SJohn Scipione*/ 32697398464SJohn Scipione 32797398464SJohn Scipione 32897398464SJohn Scipione/*! 32997398464SJohn Scipione \fn status_t BMessenger::SendMessage(BMessage* message, BMessage* reply, 33097398464SJohn Scipione bigtime_t deliveryTimeout, bigtime_t replyTimeout) const 331*151a4f7fSJohn Scipione \brief Delivers a \a message to the messenger's target and waits for a 332*151a4f7fSJohn Scipione \a reply to come back synchronously. 33397398464SJohn Scipione 33497398464SJohn Scipione A copy of the supplied message is sent and the caller retains ownership 33597398464SJohn Scipione of \a message. 33697398464SJohn Scipione 33797398464SJohn Scipione The method does wait for a reply. The reply message is copied into 33897398464SJohn Scipione \a reply. If the target doesn't send a reply or if a reply timeout occurs, 33997398464SJohn Scipione the \c what field of \a reply is set to \c B_NO_REPLY. 34097398464SJohn Scipione 341*151a4f7fSJohn Scipione This method does not return by default until the message has been delivered 342*151a4f7fSJohn Scipione and the reply has come back. You can set a \a deliveryTimeout and a 343*151a4f7fSJohn Scipione \a replyTimeout in microseconds. 344*151a4f7fSJohn Scipione 34597398464SJohn Scipione \param message The message to be sent. 346*151a4f7fSJohn Scipione \param reply A pointer to a pre-allocated BMessage which the reply 347*151a4f7fSJohn Scipione message will be copied into. 348*151a4f7fSJohn Scipione \param deliveryTimeout The message delivery timeout in microseconds. 349*151a4f7fSJohn Scipione (optional) 350*151a4f7fSJohn Scipione \param replyTimeout The reply message timeout in microseconds. (optional) 35197398464SJohn Scipione 35297398464SJohn Scipione \return A status code, \c B_OK on success or an error code otherwise. 35397398464SJohn Scipione \retval B_OK Everything went fine. 35497398464SJohn Scipione \retval B_BAD_PORT_ID The messenger was not properly initialized or its 35597398464SJohn Scipione target didn't exist. 35697398464SJohn Scipione \retval B_WOULD_BLOCK A delivery timeout of 0 was supplied and the target 35797398464SJohn Scipione port was full when trying to deliver the message. 35897398464SJohn Scipione \retval B_TIMED_OUT The timeout expired while trying to deliver the 35997398464SJohn Scipione message. 36097398464SJohn Scipione \retval B_NO_MORE_PORTS All reply ports were in use. 36197398464SJohn Scipione 36297398464SJohn Scipione \since BeOS R3 36397398464SJohn Scipione*/ 36497398464SJohn Scipione 36597398464SJohn Scipione 36697398464SJohn Scipione//! @} 36797398464SJohn Scipione 36897398464SJohn Scipione 36997398464SJohn Scipione/*! 37097398464SJohn Scipione \name SetTo 37197398464SJohn Scipione*/ 37297398464SJohn Scipione 37397398464SJohn Scipione 37497398464SJohn Scipione//! @{ 37597398464SJohn Scipione 37697398464SJohn Scipione 37797398464SJohn Scipione/*! 37897398464SJohn Scipione \fn status_t BMessenger::SetTo(const char* signature, team_id team) 37997398464SJohn Scipione \brief Reinitializes a BMessenger to target the already running application 38097398464SJohn Scipione identified by the supplied signature and/or team ID. 38197398464SJohn Scipione 38297398464SJohn Scipione When only a signature is given, and multiple instances of the application 38397398464SJohn Scipione are running it is indeterminate which one is chosen as the target. In case 38497398464SJohn Scipione only a team ID is passed, the target application is identified uniquely. 38597398464SJohn Scipione If both are supplied, the application identified by the team ID must have 38697398464SJohn Scipione a matching signature, otherwise the initialization fails. 38797398464SJohn Scipione 38897398464SJohn Scipione \param signature The target application's signature. May be \c NULL. 38997398464SJohn Scipione \param team The target application's team ID. May be negative. 39097398464SJohn Scipione 39197398464SJohn Scipione \return A status code, \c B_OK if the reinitialization was successful or an 39297398464SJohn Scipione error code otherwise. 39397398464SJohn Scipione \retval B_OK The reinitialization was successful. 39497398464SJohn Scipione \retval B_BAD_VALUE No application with the given \a signature or \a team 39597398464SJohn Scipione ID was running. 39697398464SJohn Scipione \retval B_BAD_TYPE No \a team ID was given and the \a signature was \c NULL. 39797398464SJohn Scipione \retval B_MISMATCHED_VALUES The supplied \a signature and the signature of 39897398464SJohn Scipione the team didn't match. 39997398464SJohn Scipione 40097398464SJohn Scipione \since Haiku R1 40197398464SJohn Scipione*/ 40297398464SJohn Scipione 40397398464SJohn Scipione 40497398464SJohn Scipione/*! 40597398464SJohn Scipione \fn status_t BMessenger::SetTo(const BHandler* handler, 40697398464SJohn Scipione const BLooper* looper) 40797398464SJohn Scipione \brief Reinitializes a BMessenger to target the local BHandler and/or 40897398464SJohn Scipione BLooper. 40997398464SJohn Scipione 41097398464SJohn Scipione When a \c NULL handler is supplied, the preferred handler in the given 41197398464SJohn Scipione looper is targeted. If no looper is supplied the looper the given handler 41297398464SJohn Scipione belongs to is used -- that means in particular, that the handler must 41397398464SJohn Scipione already belong to a looper. If both are supplied the handler must actually 41497398464SJohn Scipione belong to looper. 41597398464SJohn Scipione 41697398464SJohn Scipione \param handler The target handler. May be \c NULL. 41797398464SJohn Scipione \param looper The target looper. May be \c NULL. 41897398464SJohn Scipione 41997398464SJohn Scipione \return A status code, \c B_OK if the reinitialization was successful or an 42097398464SJohn Scipione error code otherwise. 42197398464SJohn Scipione \retval B_OK The reinitialization was successful. 42297398464SJohn Scipione \retval B_BAD_VALUE Both \a handler and \a looper were \c NULL or invalid. 42397398464SJohn Scipione \retval B_MISMATCHED_VALUES The looper of the supplied \a handler and 42497398464SJohn Scipione \a looper didn't match. 42597398464SJohn Scipione 42697398464SJohn Scipione \since Haiku R1 42797398464SJohn Scipione*/ 42897398464SJohn Scipione 42997398464SJohn Scipione 43097398464SJohn Scipione//! @} 43197398464SJohn Scipione 43297398464SJohn Scipione 43397398464SJohn Scipione/*! 43497398464SJohn Scipione \name Operators 43597398464SJohn Scipione*/ 43697398464SJohn Scipione 43797398464SJohn Scipione 43897398464SJohn Scipione//! @{ 43997398464SJohn Scipione 44097398464SJohn Scipione 44197398464SJohn Scipione/*! 44297398464SJohn Scipione \fn BMessenger& BMessenger::operator=(const BMessenger& other) 44397398464SJohn Scipione \brief Assignment operator, makes this BMessenger a copy of \a other. 44497398464SJohn Scipione 44597398464SJohn Scipione \param other the messenger to be copied. 44697398464SJohn Scipione 44797398464SJohn Scipione \return A reference to this object. 44897398464SJohn Scipione 44997398464SJohn Scipione \since BeOS R3 45097398464SJohn Scipione*/ 45197398464SJohn Scipione 45297398464SJohn Scipione 45397398464SJohn Scipione/*! 45497398464SJohn Scipione \fn bool BMessenger::operator==(const BMessenger& other) const 45597398464SJohn Scipione \brief Comparison operator, returns whether this and \a other have the same 45697398464SJohn Scipione target. 45797398464SJohn Scipione 45897398464SJohn Scipione \param other The messenger to be compared to. 45997398464SJohn Scipione 46097398464SJohn Scipione \return \c true, if the messengers have the same target or if both aren't 46197398464SJohn Scipione properly initialized, \c false otherwise. 46297398464SJohn Scipione 46397398464SJohn Scipione \since BeOS R3 46497398464SJohn Scipione*/ 46597398464SJohn Scipione 46697398464SJohn Scipione 46797398464SJohn Scipione//! @} 46897398464SJohn Scipione 46997398464SJohn Scipione 47097398464SJohn Scipione/*! 47197398464SJohn Scipione \fn bool BMessenger::IsValid() const 47297398464SJohn Scipione \brief Returns whether the messenger's target looper still exists. 47397398464SJohn Scipione 47497398464SJohn Scipione \warning This method does not check whether the target handler 47597398464SJohn Scipione also still exists. 47697398464SJohn Scipione 47797398464SJohn Scipione \return \c true, if the messenger's target looper still exists, 47897398464SJohn Scipione \c false otherwise. 47997398464SJohn Scipione 48097398464SJohn Scipione \since BeOS R3 48197398464SJohn Scipione*/ 48297398464SJohn Scipione 48397398464SJohn Scipione 48497398464SJohn Scipione/*! 48597398464SJohn Scipione \fn team_id BMessenger::Team() const 48697398464SJohn Scipione \brief Returns the ID of the team that the messenger's target belongs to. 48797398464SJohn Scipione 48897398464SJohn Scipione \return The team of the messenger's target. 48997398464SJohn Scipione 49097398464SJohn Scipione \since BeOS R3 49197398464SJohn Scipione*/ 49297398464SJohn Scipione 49397398464SJohn Scipione 49497398464SJohn Scipione/*! 49597398464SJohn Scipione \fn uint32 BMessenger::HashValue() const 49697398464SJohn Scipione \brief Returns a hash value that uniquely identifies the messenger. 49797398464SJohn Scipione 49897398464SJohn Scipione \since Haiku R1 49997398464SJohn Scipione*/ 500fd3c25a9SJohn Scipione 501fd3c25a9SJohn Scipione 502fd3c25a9SJohn Scipione/*! 503fd3c25a9SJohn Scipione \fn bool operator<(const BMessenger& _a, const BMessenger& _b) 504fd3c25a9SJohn Scipione \brief Returns whether the first messenger is less than the second one. 505fd3c25a9SJohn Scipione 506fd3c25a9SJohn Scipione This method defines an order on BMessengers based on their member 507fd3c25a9SJohn Scipione variables \c fPort, \c fHandlerToken and \c fPreferredTarget. 508fd3c25a9SJohn Scipione 509fd3c25a9SJohn Scipione \param _a The first messenger. 510fd3c25a9SJohn Scipione \param _b The second messenger. 511fd3c25a9SJohn Scipione 512fd3c25a9SJohn Scipione \return \c true, if \a a was less than \a b, \c false otherwise. 513fd3c25a9SJohn Scipione*/ 514fd3c25a9SJohn Scipione 515fd3c25a9SJohn Scipione 5162eb2dcfaSJohn Scipione/*! 5172eb2dcfaSJohn Scipione \fn bool operator!=(const BMessenger& a, const BMessenger& b) 518fd3c25a9SJohn Scipione \brief Returns whether two BMessengers do NOT have the same target. 519fd3c25a9SJohn Scipione 520fd3c25a9SJohn Scipione \param a The first messenger. 521fd3c25a9SJohn Scipione \param b The second messenger. 522fd3c25a9SJohn Scipione 523fd3c25a9SJohn Scipione \return \c false, if \a a and \a b had the same targets or both were not 524fd3c25a9SJohn Scipione properly initialized, \c true otherwise. 525fd3c25a9SJohn Scipione*/ 526