Main MRPT website > C++ reference for MRPT 1.5.6
CObserver.cpp
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 
13 #include <mrpt/utils/CObserver.h>
14 #include <mrpt/utils/CObservable.h>
15 
16 using namespace mrpt::utils;
17 using namespace std;
18 
20 {
21 }
22 
24 {
25  while (!m_subscribed.empty())
26  this->observeEnd(** m_subscribed.begin() );
27 }
28 
29 /** Starts the subscription of this observer to the given object. \sa observeEnd */
31 {
32  m_subscribed.insert(&obj);
33  obj.internal_observer_begin(this);
34 }
35 
36 /** Ends the subscription of this observer to the given object (note that there is no need to call this method, since the destruction of the first of observer/observed will put an end to the process
37 \sa observeBegin */
39 {
40  set<CObservable*>::iterator it = m_subscribed.find(&obj);
41  if (it!=m_subscribed.end())
42  {
43  (*it)->internal_observer_end(this);
44  m_subscribed.erase(it);
45  }
46 }
47 
48 // Redirect the notification to the user virtual method:
50 {
51  this->OnEvent(e);
52 }
The basic event type for the observer-observable pattern in MRPT.
Definition: mrptEvent.h:34
Scalar * iterator
Definition: eigen_plugins.h:23
void observeEnd(CObservable &obj)
Ends the subscription of this observer to the given object (note that there is no need to call this m...
Definition: CObserver.cpp:38
void internal_observer_begin(CObserver *)
Definition: CObservable.cpp:33
void internal_on_event(const mrptEvent &e)
Definition: CObserver.cpp:49
void observeBegin(CObservable &obj)
Starts the subscription of this observer to the given object.
Definition: CObserver.cpp:30
GLhandleARB obj
Definition: glew.h:3276
Inherit from this class for those objects capable of being observed by a CObserver class...
Definition: CObservable.h:33



Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018