@@ -63,7 +63,7 @@ class RENDER_PIPELINE_DECL Messenger : public TypedObject
6363
6464 using AcceptorType = std::pair<EventFunction, bool >; // { function, persistent }
6565 using AcceptorMap = std::unordered_map<const DirectObject*, AcceptorType>;
66- using HooksType = std::unordered_map<EventName, AcceptorMap>;
66+ using CallbacksType = std::unordered_map<EventName, AcceptorMap>;
6767
6868public:
6969 static Messenger* get_global_instance ();
@@ -136,7 +136,7 @@ class RENDER_PIPELINE_DECL Messenger : public TypedObject
136136 void remove_hook (const EventName& event_name);
137137
138138 EventHandler* handler_;
139- HooksType hooks_ ;
139+ CallbacksType callbacks_ ;
140140
141141 static const AcceptorMap empty_acceptor_;
142142
@@ -155,15 +155,15 @@ class RENDER_PIPELINE_DECL Messenger : public TypedObject
155155inline size_t Messenger::get_num_listners () const
156156{
157157 size_t count = 0 ;
158- for (const auto & hook: hooks_ )
159- count += hook .second .size ();
158+ for (const auto & callback: callbacks_ )
159+ count += callback .second .size ();
160160 return count;
161161}
162162
163163inline size_t Messenger::get_num_listners (const EventName& event_name) const
164164{
165- const auto found = hooks_ .find (event_name);
166- if (found != hooks_ .end ())
165+ const auto found = callbacks_ .find (event_name);
166+ if (found != callbacks_ .end ())
167167 return found->second .size ();
168168 else
169169 return 0 ;
@@ -176,38 +176,38 @@ inline AsyncFuture* Messenger::get_future(const EventName& event_name) const
176176
177177inline void Messenger::ignore (const EventName& event_name, const DirectObject* object)
178178{
179- auto found = hooks_ .find (event_name);
180- if (found == hooks_ .end ())
179+ auto found = callbacks_ .find (event_name);
180+ if (found == callbacks_ .end ())
181181 return ;
182182
183- auto & hook = found->second ;
184- auto hook_found = hook .find (object);
185- if (hook_found != hook .end ())
186- hook .erase (hook_found );
183+ auto & acceptor_map = found->second ;
184+ auto acceptor_map_found = acceptor_map .find (object);
185+ if (acceptor_map_found != acceptor_map .end ())
186+ acceptor_map .erase (acceptor_map_found );
187187
188- if (hook .empty ())
188+ if (acceptor_map .empty ())
189189 remove_hook (event_name);
190190}
191191
192192inline void Messenger::ignore_all (const EventName& event_name)
193193{
194- auto found = hooks_ .find (event_name);
195- if (found == hooks_ .end ())
194+ auto found = callbacks_ .find (event_name);
195+ if (found == callbacks_ .end ())
196196 return ;
197197
198198 remove_hook (event_name);
199199}
200200
201201inline void Messenger::ignore_all (const DirectObject* object)
202202{
203- auto iter = hooks_ .begin ();
204- const auto iter_end = hooks_ .end ();
203+ auto iter = callbacks_ .begin ();
204+ const auto iter_end = callbacks_ .end ();
205205 while (iter != iter_end)
206206 {
207- auto & hook = iter->second ;
208- auto found = hook .find (object);
209- if (found != hook .end ())
210- hook .erase (found);
207+ auto & acceptor_map = iter->second ;
208+ auto found = acceptor_map .find (object);
209+ if (found != acceptor_map .end ())
210+ acceptor_map .erase (found);
211211
212212 // iterator becomes invalidated after erase.
213213 auto iter_tmp = iter;
@@ -220,19 +220,19 @@ inline void Messenger::ignore_all(const DirectObject* object)
220220inline auto Messenger::get_all_accepting (const DirectObject* object) const -> std::vector<EventName>
221221{
222222 std::vector<EventName> events;
223- for (const auto & kv : hooks_ )
223+ for (const auto & kv : callbacks_ )
224224 {
225- const auto & hook = kv.second ;
226- if (hook .find (object) != hook .end ())
225+ const auto & acceptor_map = kv.second ;
226+ if (acceptor_map .find (object) != acceptor_map .end ())
227227 events.push_back (kv.first );
228228 }
229229 return events;
230230}
231231
232232inline bool Messenger::is_accepting (const EventName& event_name, const DirectObject* object) const
233233{
234- auto found = hooks_ .find (event_name);
235- if (found != hooks_ .end ())
234+ auto found = callbacks_ .find (event_name);
235+ if (found != callbacks_ .end ())
236236 {
237237 if (found->second .find (object) != found->second .end ())
238238 return true ;
@@ -290,14 +290,14 @@ inline void Messenger::add_hook(const EventName& event_name)
290290inline void Messenger::remove_hook (const EventName& event_name)
291291{
292292 handler_->remove_hook (event_name, process_event, this );
293- hooks_ .erase (event_name);
293+ callbacks_ .erase (event_name);
294294}
295295
296296inline void Messenger::clear ()
297297{
298- for (auto && hook : hooks_ )
299- handler_->remove_hook (hook .first , process_event, this );
300- hooks_ .clear ();
298+ for (auto && kv : callbacks_ )
299+ handler_->remove_hook (kv .first , process_event, this );
300+ callbacks_ .clear ();
301301}
302302
303303inline bool Messenger::is_empty () const
@@ -308,8 +308,8 @@ inline bool Messenger::is_empty() const
308308inline auto Messenger::get_events () const -> std::vector<EventName>
309309{
310310 std::vector<EventName> events;
311- events.reserve (hooks_ .size ());
312- for (const auto & kv: hooks_ )
311+ events.reserve (callbacks_ .size ());
312+ for (const auto & kv: callbacks_ )
313313 events.push_back (kv.first );
314314 return events;
315315}
0 commit comments