Fix FreeBSD build.
[haiku.git] / headers / os / app / Handler.h
blob800bd822a3557620577d5e19e98e07a1386db21d
1 /*
2 * Copyright 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Erik Jaesler, erik@cgsoftware.com
7 */
8 #ifndef _HANDLER_H
9 #define _HANDLER_H
12 #include <Archivable.h>
15 class BLooper;
16 class BMessageFilter;
17 class BMessage;
18 class BMessenger;
19 class BList;
21 #define B_OBSERVE_WHAT_CHANGE "be:observe_change_what"
22 #define B_OBSERVE_ORIGINAL_WHAT "be:observe_orig_what"
23 const uint32 B_OBSERVER_OBSERVE_ALL = 0xffffffff;
25 namespace BPrivate {
26 class ObserverList;
29 class BHandler : public BArchivable {
30 public:
31 BHandler(const char* name = NULL);
32 virtual ~BHandler();
34 // Archiving
35 BHandler(BMessage* data);
36 static BArchivable* Instantiate(BMessage* data);
37 virtual status_t Archive(BMessage* data, bool deep = true) const;
39 // BHandler guts.
40 virtual void MessageReceived(BMessage* message);
41 BLooper* Looper() const;
42 void SetName(const char* name);
43 const char* Name() const;
44 virtual void SetNextHandler(BHandler* handler);
45 BHandler* NextHandler() const;
47 // Message filtering
48 virtual void AddFilter(BMessageFilter* filter);
49 virtual bool RemoveFilter(BMessageFilter* filter);
50 virtual void SetFilterList(BList* filters);
51 BList* FilterList();
53 bool LockLooper();
54 status_t LockLooperWithTimeout(bigtime_t timeout);
55 void UnlockLooper();
57 // Scripting
58 virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
59 BMessage* specifier, int32 what,
60 const char* property);
61 virtual status_t GetSupportedSuites(BMessage* data);
63 // Observer calls, inter-looper and inter-team
64 status_t StartWatching(BMessenger target, uint32 what);
65 status_t StartWatchingAll(BMessenger target);
66 status_t StopWatching(BMessenger target, uint32 what);
67 status_t StopWatchingAll(BMessenger target);
69 // Observer calls for observing targets in the local team
70 status_t StartWatching(BHandler* observer, uint32 what);
71 status_t StartWatchingAll(BHandler* observer);
72 status_t StopWatching(BHandler* observer, uint32 what);
73 status_t StopWatchingAll(BHandler* observer);
76 // Reserved
77 virtual status_t Perform(perform_code d, void* arg);
79 // Notifier calls
80 virtual void SendNotices(uint32 what,
81 const BMessage* notice = NULL);
82 bool IsWatched() const;
84 private:
85 typedef BArchivable _inherited;
86 friend inline int32 _get_object_token_(const BHandler* );
87 friend class BLooper;
88 friend class BMessageFilter;
90 virtual void _ReservedHandler2();
91 virtual void _ReservedHandler3();
92 virtual void _ReservedHandler4();
94 void _InitData(const char* name);
95 BPrivate::ObserverList* _ObserverList();
97 BHandler(const BHandler&);
98 BHandler& operator=(const BHandler&);
99 void SetLooper(BLooper* looper);
101 int32 fToken;
102 char* fName;
103 BLooper* fLooper;
104 BHandler* fNextHandler;
105 BList* fFilters;
106 BPrivate::ObserverList* fObserverList;
107 uint32 _reserved[3];
110 #endif // _HANDLER_H