1 /* 2 * Copyright 2001-2005, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Frans van Nispen (xlr8@tref.nl) 7 */ 8 #ifndef _INVOKER_H 9 #define _INVOKER_H 10 11 12 #include <BeBuild.h> 13 #include <Messenger.h> 14 15 16 class BHandler; 17 class BLooper; 18 class BMessage; 19 20 21 class BInvoker { 22 public: 23 BInvoker(); 24 BInvoker(BMessage* message, 25 const BHandler* handler, 26 const BLooper* looper = NULL); 27 BInvoker(BMessage* message, BMessenger target); 28 virtual ~BInvoker(); 29 30 virtual status_t SetMessage(BMessage* message); 31 BMessage* Message() const; 32 uint32 Command() const; 33 34 virtual status_t SetTarget(const BHandler* handler, 35 const BLooper* looper = NULL); 36 virtual status_t SetTarget(BMessenger messenger); 37 bool IsTargetLocal() const; 38 BHandler* Target(BLooper** _looper = NULL) const; 39 BMessenger Messenger() const; 40 41 virtual status_t SetHandlerForReply(BHandler* handler); 42 BHandler* HandlerForReply() const; 43 44 virtual status_t Invoke(BMessage* message = NULL); 45 status_t InvokeNotify(BMessage* message, 46 uint32 kind = B_CONTROL_INVOKED); 47 status_t SetTimeout(bigtime_t timeout); 48 bigtime_t Timeout() const; 49 50 protected: 51 uint32 InvokeKind(bool* _notify = NULL); 52 void BeginInvokeNotify( 53 uint32 kind = B_CONTROL_INVOKED); 54 void EndInvokeNotify(); 55 56 private: 57 virtual void _ReservedInvoker1(); 58 virtual void _ReservedInvoker2(); 59 virtual void _ReservedInvoker3(); 60 61 BInvoker(const BInvoker&); 62 BInvoker& operator=(const BInvoker&); 63 64 BMessage* fMessage; 65 BMessenger fMessenger; 66 BHandler* fReplyTo; 67 bigtime_t fTimeout; 68 uint32 fNotifyKind; 69 uint32 _reserved[1]; 70 }; 71 72 73 #endif // _INVOKER_H 74