xref: /haiku/headers/os/app/Invoker.h (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
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 class BHandler;
16 class BLooper;
17 class BMessage;
18 
19 
20 class BInvoker {
21 	public:
22 							BInvoker();
23 							BInvoker(BMessage* message, const BHandler* handler,
24 								 const BLooper* looper = NULL);
25 							BInvoker(BMessage* message, BMessenger target);
26 		virtual				~BInvoker();
27 
28 		virtual	status_t	SetMessage(BMessage *message);
29 		BMessage*			Message() const;
30 		uint32				Command() const;
31 
32 		virtual status_t	SetTarget(const BHandler *handler,
33 								const BLooper *looper = NULL);
34 		virtual status_t	SetTarget(BMessenger messenger);
35 		bool				IsTargetLocal() const;
36 		BHandler*			Target(BLooper** _looper = NULL) const;
37 		BMessenger			Messenger() const;
38 
39 		virtual status_t	SetHandlerForReply(BHandler* handler);
40 		BHandler*			HandlerForReply() const;
41 
42 		virtual	status_t	Invoke(BMessage* message = NULL);
43 		status_t			InvokeNotify(BMessage* message,
44 								uint32 kind = B_CONTROL_INVOKED);
45 		status_t			SetTimeout(bigtime_t timeout);
46 		bigtime_t			Timeout() const;
47 
48 	protected:
49 		uint32				InvokeKind(bool* _notify = NULL);
50 		void				BeginInvokeNotify(uint32 kind = B_CONTROL_INVOKED);
51 		void				EndInvokeNotify();
52 
53 	private:
54 		virtual	void		_ReservedInvoker1();
55 		virtual	void		_ReservedInvoker2();
56 		virtual	void		_ReservedInvoker3();
57 
58 							BInvoker(const BInvoker&);
59 		BInvoker&			operator=(const BInvoker&);
60 
61 		BMessage*			fMessage;
62 		BMessenger			fMessenger;
63 		BHandler*			fReplyTo;
64 		bigtime_t			fTimeout;
65 		uint32				fNotifyKind;
66 		uint32				_reserved[1];
67 };
68 
69 #endif	// _INVOKER_H
70