Fix FreeBSD build.
[haiku.git] / headers / os / app / MessageFilter.h
blob1621a7a16abce858a31e89b486928cb6510f4b00
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 _MESSAGE_FILTER_H
9 #define _MESSAGE_FILTER_H
12 #include <Handler.h>
15 class BMessage;
18 // filter_hook Return Codes and Protocol
19 enum filter_result {
20 B_SKIP_MESSAGE,
21 B_DISPATCH_MESSAGE
25 typedef filter_result (*filter_hook)
26 (BMessage* message, BHandler** target, BMessageFilter* filter);
29 // BMessageFilter invocation criteria
30 enum message_delivery {
31 B_ANY_DELIVERY,
32 B_DROPPED_DELIVERY,
33 B_PROGRAMMED_DELIVERY
36 enum message_source {
37 B_ANY_SOURCE,
38 B_REMOTE_SOURCE,
39 B_LOCAL_SOURCE
43 class BMessageFilter {
44 public:
45 BMessageFilter(uint32 what,
46 filter_hook func = NULL);
47 BMessageFilter(message_delivery delivery,
48 message_source source, filter_hook func = NULL);
49 BMessageFilter(message_delivery delivery,
50 message_source source, uint32 what,
51 filter_hook func = NULL);
52 BMessageFilter(const BMessageFilter& filter);
53 BMessageFilter(const BMessageFilter* filter);
54 virtual ~BMessageFilter();
56 BMessageFilter& operator=(const BMessageFilter& from);
58 // Hook function; ignored if filter_hook is non-NULL
59 virtual filter_result Filter(BMessage* message, BHandler** _target);
61 message_delivery MessageDelivery() const;
62 message_source MessageSource() const;
63 uint32 Command() const;
64 bool FiltersAnyCommand() const;
65 BLooper* Looper() const;
67 private:
68 friend class BLooper;
69 friend class BHandler;
71 virtual void _ReservedMessageFilter1();
72 virtual void _ReservedMessageFilter2();
74 void SetLooper(BLooper* owner);
75 filter_hook FilterFunction() const;
77 bool fFiltersAny;
78 uint32 fWhat;
79 message_delivery fDelivery;
80 message_source fSource;
81 BLooper* fLooper;
82 filter_hook fFilterFunction;
84 uint32 _reserved[3];
88 #endif // _MESSAGE_FILTER_H