1 //////////////////////////////////////////////////////////// 2 // MultiInvoker.h 3 // -------------- 4 // Declares the MultiInvoker class. 5 // 6 // Copyright 1999, Be Incorporated. All Rights Reserved. 7 // This file may be used under the terms of the Be Sample 8 // Code License. 9 10 #ifndef _MultiInvoker_h 11 #define _MultiInvoker_h 12 13 #include <List.h> 14 15 //////////////////////////////////////////////////////////// 16 // Class: MultiInvoker 17 // ------------------- 18 // A BInvoker-like class that allows you to send messages 19 // to multiple targets. In addition, it will work with 20 // any BMessenger-derived class that you create. 21 22 class MultiInvoker 23 { 24 public: 25 MultiInvoker(); 26 MultiInvoker(const MultiInvoker& src); 27 virtual ~MultiInvoker(); 28 29 MultiInvoker& operator=(const MultiInvoker& src); 30 31 virtual void SetMessage(BMessage* message); 32 BMessage* Message() const; 33 uint32 Command() const; 34 35 virtual status_t AddTarget(const BHandler* h, const BLooper* loop=0); 36 37 // For this version of AddTarget, the MultiInvoker 38 // will assume ownership of the messenger. 39 virtual status_t AddTarget(BMessenger* messenger); 40 virtual void RemoveTarget(const BHandler* h); 41 virtual void RemoveTarget(int32 index); 42 int32 IndexOfTarget(const BHandler* h) const; 43 int32 CountTargets() const; 44 BHandler* TargetAt(int32 index, BLooper** looper=0) const; 45 BMessenger* MessengerAt(int32 index) const; 46 bool IsTargetLocal(int32 index) const; 47 48 void SetTimeout(bigtime_t timeout); 49 bigtime_t Timeout() const; 50 51 virtual void SetHandlerForReply(BHandler* h); 52 BHandler* HandlerForReply() const; 53 54 virtual status_t Invoke(BMessage* msg =0); 55 56 private: 57 void Clear(); 58 void Clone(const MultiInvoker& src); 59 60 BMessage* m_message; 61 BList m_messengers; 62 bigtime_t m_timeout; 63 BHandler* m_replyHandler; 64 }; 65 66 #endif /* _MultiInvoker_h */ 67