2 * Copyright 1999, Be Incorporated.
3 * Copyright (c) 1999-2000, Eric Moon.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions, and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions, and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the author may not be used to endorse or promote products
18 * derived from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
24 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
28 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 ////////////////////////////////////////////////////////////
36 // Declares the MultiInvoker class.
40 #ifndef _MultiInvoker_h
41 #define _MultiInvoker_h
45 ////////////////////////////////////////////////////////////
46 // Class: MultiInvoker
47 // -------------------
48 // A BInvoker-like class that allows you to send messages
49 // to multiple targets. In addition, it will work with
50 // any BMessenger-derived class that you create.
56 MultiInvoker(const MultiInvoker
& src
);
57 virtual ~MultiInvoker();
59 MultiInvoker
& operator=(const MultiInvoker
& src
);
61 virtual void SetMessage(BMessage
* message
);
62 BMessage
* Message() const;
63 uint32
Command() const;
65 virtual status_t
AddTarget(const BHandler
* h
, const BLooper
* loop
=0);
67 // For this version of AddTarget, the MultiInvoker
68 // will assume ownership of the messenger.
69 virtual status_t
AddTarget(BMessenger
* messenger
);
70 virtual void RemoveTarget(const BHandler
* h
);
71 virtual void RemoveTarget(int32 index
);
72 int32
IndexOfTarget(const BHandler
* h
) const;
73 int32
CountTargets() const;
74 BHandler
* TargetAt(int32 index
, BLooper
** looper
=0) const;
75 BMessenger
* MessengerAt(int32 index
) const;
76 bool IsTargetLocal(int32 index
) const;
78 void SetTimeout(bigtime_t timeout
);
79 bigtime_t
Timeout() const;
81 virtual void SetHandlerForReply(BHandler
* h
);
82 BHandler
* HandlerForReply() const;
84 virtual status_t
Invoke(BMessage
* msg
=0);
88 void Clone(const MultiInvoker
& src
);
93 BHandler
* m_replyHandler
;
96 #endif /* _MultiInvoker_h */