2 * Copyright 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Erik Jaesler, erik@cgsoftware.com
8 #ifndef _MESSAGE_FILTER_H
9 #define _MESSAGE_FILTER_H
18 // filter_hook Return Codes and Protocol
25 typedef filter_result (*filter_hook
)
26 (BMessage
* message
, BHandler
** target
, BMessageFilter
* filter
);
29 // BMessageFilter invocation criteria
30 enum message_delivery
{
43 class BMessageFilter
{
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;
69 friend class BHandler
;
71 virtual void _ReservedMessageFilter1();
72 virtual void _ReservedMessageFilter2();
74 void SetLooper(BLooper
* owner
);
75 filter_hook
FilterFunction() const;
79 message_delivery fDelivery
;
80 message_source fSource
;
82 filter_hook fFilterFunction
;
88 #endif // _MESSAGE_FILTER_H