MRPT  1.9.9
mrpt::system::CObserver Class Referenceabstract

Detailed Description

Inherit from this class to get notified about events from any CObservable object after subscribing to it.

The main methods in this class are:

  • observeBegin(): To be called to start listening at a given object.
  • OnEvent(): Virtual functions to be implemented in your child class to receive all the notifications.

Note that if custom (child) mrptEvent classes are used, you can tell between them in runtime with "dynamic_cast<>()".

Note
The pairs CObservable / CObserver automatically notify each other the destruction of any of them, effectively ending the subscription of events.
See also
CObservable, mrptEvent

Definition at line 34 of file CObserver.h.

#include <mrpt/system/CObserver.h>

Inheritance diagram for mrpt::system::CObserver:
Inheritance graph

Public Member Functions

 CObserver ()
 
virtual ~CObserver ()
 
void observeBegin (CObservable &obj)
 Starts the subscription of this observer to the given object. More...
 
void observeEnd (CObservable &obj)
 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. More...
 

Protected Member Functions

virtual void OnEvent (const mrptEvent &e)=0
 This virtual function will be called upon receive of any event after starting listening at any CObservable object. More...
 

Private Member Functions

void internal_on_event (const mrptEvent &e)
 

Private Attributes

std::set< CObservable * > m_subscribed
 

Friends

class CObservable
 

Constructor & Destructor Documentation

◆ CObserver()

CObserver::CObserver ( )

Definition at line 18 of file CObserver.cpp.

◆ ~CObserver()

CObserver::~CObserver ( )
virtual

Definition at line 19 of file CObserver.cpp.

Member Function Documentation

◆ internal_on_event()

void CObserver::internal_on_event ( const mrptEvent e)
private

Definition at line 47 of file CObserver.cpp.

◆ observeBegin()

void CObserver::observeBegin ( CObservable obj)

Starts the subscription of this observer to the given object.

See also
observeEnd

Definition at line 26 of file CObserver.cpp.

Referenced by CGraphSlamHandler< GRAPH_T >::initVisualization().

◆ observeEnd()

void CObserver::observeEnd ( CObservable obj)

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.

See also
observeBegin

Definition at line 36 of file CObserver.cpp.

◆ OnEvent()

virtual void mrpt::system::CObserver::OnEvent ( const mrptEvent e)
protectedpure virtual

This virtual function will be called upon receive of any event after starting listening at any CObservable object.

Implemented in MyObserver, mrpt::slam::COccupancyGridMapFeatureExtractor, mrpt::graphslam::CWindowObserver, TMyExtraRenderingStuff, and MyObserver.

Friends And Related Function Documentation

◆ CObservable

friend class CObservable
friend

Definition at line 36 of file CObserver.h.

Member Data Documentation

◆ m_subscribed

std::set<CObservable*> mrpt::system::CObserver::m_subscribed
private

Definition at line 53 of file CObserver.h.




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020