Main MRPT website > C++ reference for MRPT 1.5.7
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 }
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
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
STL namespace.
GLsizei GLsizei GLuint * obj
Definition: glext.h:3902
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
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.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019