1 /*
2 * Copyright 2001-2014 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Erik Jaesler (erik@cgsoftware.com)
7 */
8
9
10 #include <MessageFilter.h>
11
12
BMessageFilter(uint32 inWhat,filter_hook func)13 BMessageFilter::BMessageFilter(uint32 inWhat, filter_hook func)
14 :
15 fFiltersAny(false),
16 fWhat(inWhat),
17 fDelivery(B_ANY_DELIVERY),
18 fSource(B_ANY_SOURCE),
19 fLooper(NULL),
20 fFilterFunction(func)
21 {
22 }
23
24
BMessageFilter(message_delivery delivery,message_source source,filter_hook func)25 BMessageFilter::BMessageFilter(message_delivery delivery,
26 message_source source, filter_hook func)
27 :
28 fFiltersAny(true),
29 fWhat(0),
30 fDelivery(delivery),
31 fSource(source),
32 fLooper(NULL),
33 fFilterFunction(func)
34 {
35 }
36
37
BMessageFilter(message_delivery delivery,message_source source,uint32 inWhat,filter_hook func)38 BMessageFilter::BMessageFilter(message_delivery delivery,
39 message_source source, uint32 inWhat, filter_hook func)
40 :
41 fFiltersAny(false),
42 fWhat(inWhat),
43 fDelivery(delivery),
44 fSource(source),
45 fLooper(NULL),
46 fFilterFunction(func)
47 {
48 }
49
50
BMessageFilter(const BMessageFilter & filter)51 BMessageFilter::BMessageFilter(const BMessageFilter& filter)
52 {
53 *this = filter;
54 }
55
56
BMessageFilter(const BMessageFilter * filter)57 BMessageFilter::BMessageFilter(const BMessageFilter* filter)
58 {
59 *this = *filter;
60 }
61
62
~BMessageFilter()63 BMessageFilter::~BMessageFilter()
64 {
65 }
66
67
68 BMessageFilter &
operator =(const BMessageFilter & from)69 BMessageFilter::operator=(const BMessageFilter& from)
70 {
71 fFiltersAny = from.FiltersAnyCommand();
72 fWhat = from.Command();
73 fDelivery = from.MessageDelivery();
74 fSource = from.MessageSource();
75 fFilterFunction = from.FilterFunction();
76
77 SetLooper(from.Looper());
78
79 return *this;
80 }
81
82
83 filter_result
Filter(BMessage * message,BHandler ** target)84 BMessageFilter::Filter(BMessage* message, BHandler** target)
85 {
86 return B_DISPATCH_MESSAGE;
87 }
88
89
90 message_delivery
MessageDelivery() const91 BMessageFilter::MessageDelivery() const
92 {
93 return fDelivery;
94 }
95
96
97 message_source
MessageSource() const98 BMessageFilter::MessageSource() const
99 {
100 return fSource;
101 }
102
103
104 uint32
Command() const105 BMessageFilter::Command() const
106 {
107 return fWhat;
108 }
109
110
111 bool
FiltersAnyCommand() const112 BMessageFilter::FiltersAnyCommand() const
113 {
114 return fFiltersAny;
115 }
116
117
118 BLooper*
Looper() const119 BMessageFilter::Looper() const
120 {
121 return fLooper;
122 }
123
124
_ReservedMessageFilter1()125 void BMessageFilter::_ReservedMessageFilter1() {}
_ReservedMessageFilter2()126 void BMessageFilter::_ReservedMessageFilter2() {}
127
128
129 void
SetLooper(BLooper * owner)130 BMessageFilter::SetLooper(BLooper* owner)
131 {
132 fLooper = owner;
133 }
134
135
136 filter_hook
FilterFunction() const137 BMessageFilter::FilterFunction() const
138 {
139 return fFilterFunction;
140 }
141