| Class Overview | 
BMessageFilter(message_delivery delivery,
               message_source source,
               uint32 command,
               filter_hook filter = NULL);
BMessageFilter(message_delivery delivery,
               message_source source,
               filter_hook filter = NULL);
BMessageFilter(uint32 command,
               filter_hook filter = NULL);
BMessageFilter(const BMessageFilter& object);
BMessageFilter(const BMessageFilter* object);
Creates and returns a new BMessageFilter. The first
three arguments define the types of messages that the object wants to see:
| Parameter | Description | 
|---|---|
  | Specifies how the message must arrive: drag-and-drop
(  | 
  | Specifes whether the sender of the message
must be local vis-a-vis this app (  | 
  | Is a command constant. If supplied, the
  | 
Messages that don't fit the definition won't be sent to the object's filter function.
The filter argument is a pointer to a filter_hook
function. This is the function that's invoked when a message needs to be
examined (see
filter_hook
for the protocol). You don't have to supply a
filter_hook
function; instead, you can implement
BMessageFilter's
Filter()
function in a subclass.
For more information, refer to the description of the member Filter()
function.
virtual filter_result Filter(BMessage* message,
                             BHandler** target);
Implemented by derived classes to examine an arriving message just before
it's dispatched. The first two arguments are the
message that's being considered, and the proposed
BHandler
target. You can alter the contents of the message,
and alter or even replace the handler. If you replace the handler, the new
handler must belong to the same looper as the original. The new handler is
given an opportunity to filter the message before it's dispatched.
The return value must be one of these two values:
| Constant | Description | 
|---|---|
  | The   | 
  | The message goes no further—it's immediately thrown away by the caller.  | 
The default version of this function returns B_DISPATCH_MESSAGE.
It's possible to call your Filter() function
yourself (i.e. outside the message-passing mechanism), but keep in mind
that it's the caller's responsibility to interpret the return value.
Rather than implement the  function, you can supply the
BMessageFilter with a
filter_hook
callback when you construct the object. If you do both, the
filter_hook
(and not Filter()) will be invoked when the object
is asked to examine a message.
uint32 Command() const;bool FiltersAnyCommand() const;
Command() returns the command constant (the BMessage
what value) that an arriving message must match for the
filter to apply. FiltersAnyCommand() returns
true if the filter applies to all messages, and
false if it's limited to a specific command.
Because all command constants are valid, including negative numbers and 0,
Command() returns a reliable result only if
FiltersAnyCommand() returns
false.
BLooper* Looper() const;
Returns the BLooper
whose messages this object filters, or NULL if the
BMessageFilter hasn't yet been assigned to a BHandler or BLooper. To attach a
BMessageFilter to a looper or handler, use BLooper::AddCommonFilter()
or BHandler::AddFilter().
message_delivery MessageDelivery() const;message_source MessageSource() const;
These functions return constants, set when the
BMessageFilter object was constructed, that describe
the categories of messages that can be filtered.
MessageDelivery() returns a constant that
specifies how the message must be delivered
(B_DROPPED_DELIVERY,
B_PROGRAMMED_DELIVERY, or
B_ANY_DELIVERY).
MessageSource() returns how the source of the
message is constrained (B_LOCAL_SOURCE,
B_REMOTE_SOURCE, or
B_ANY_SOURCE).
filter_result (*filter_hook)(BMessage* message,
                             BHandler** target,
                             BMessageFilter* messageFilter);typedef enum filter_result {B_SKIP_MESSAGE,B_DISPATCH_MESSAGE}
filter_hook defines the protocol for message-filtering
functions. The first two arguments are the message
that's being considered, and the proposed BHandler target. You can
alter the contents of the message, and alter or even replace the handler.
If you replace the handler, the new handler must belong to the same looper
as the original. The new handler is given an opportunity to filter the
message before it's dispatched.
messageFilter is a pointer to the object on whose
behalf this function is being called; you mustn't delete this object. More
than one BMessageFilter can use the same
filter_hook function.
The return value of type filter_result must be one of these two values:
| Constant | Description | 
|---|---|
  | The   | 
  | The message goes no further–it's immediately thrown away by the caller.  | 
It's possible to call your filter function yourself (i.e. outside the message-passing mechanism), but keep in mind that it's the caller's responsibility to interpret the return value.
You supply a BMessageFilter with a
filter_hook function when you constuct the object.
Alternatively, you can subclass BMessageFilter and
provide an implementation of Filter().
If you do both, the filter_hook (and not Filter())
will be invoked when the object is asked to examine a message.
typedef enum message_delivery {B_ANY_DELIVERY,B_DROPPED_DELIVERY,B_PROGRAMMED_DELIVERY}
This type enumerates the delivery criteria for filtering a message.
See also:
The BMessageFilter
constructor
typedef enum message_source {B_ANY_SOURCE,B_REMOTE_SOURCE,B_LOCAL_SOURCE}
This type enumerates the source criteria for filtering a message.
See also:
The BMessageFilter
constructor