ReFRACtor
FullPhysics::Observer< T > Class Template Reference

Simple Mixin to be and Observer of another object of class T. More...

#include <observer.h>

+ Inheritance diagram for FullPhysics::Observer< T >:
+ Collaboration diagram for FullPhysics::Observer< T >:

Public Member Functions

 Observer ()
 
virtual ~Observer ()
 
virtual void notify_add (T &Observed_object)
 Called when an object is added to an Observable. More...
 
virtual void notify_add ()
 
virtual void notify_remove (T &Observed_object)
 Called when an object is removed from an Observable. More...
 
virtual void notify_remove ()
 
virtual void notify_update (const T &Observed_object)
 Called when the Observed object is updated. More...
 

Friends

class Observable< T >
 

Detailed Description

template<class T>
class FullPhysics::Observer< T >

Simple Mixin to be and Observer of another object of class T.

We get notified when the other object is updated.

A note on lifetime of objects. When an Observer is destroyed, nothing special needs to be done. The Observable is automatically notified that the Object no longer exists, and shouldn't receive notify_update messages anymore. Likewise, nothing special happens when the Observable is destroyed, this Observe simple receives no more messages from that Observable since it never changes after it is dead.

The relationship between Observer and Observable is m to n, a Observer can be attached to any number of Observables, and likewise an Observable can have any number of Observers attached.

Definition at line 29 of file observer.h.

Constructor & Destructor Documentation

◆ Observer()

template<class T>
FullPhysics::Observer< T >::Observer ( )
inline

Definition at line 31 of file observer.h.

◆ ~Observer()

template<class T>
virtual FullPhysics::Observer< T >::~Observer ( )
inlinevirtual

Definition at line 34 of file observer.h.

Member Function Documentation

◆ notify_add() [1/2]

template<class T>
virtual void FullPhysics::Observer< T >::notify_add ( T &  Observed_object)
inlinevirtual

Called when an object is added to an Observable.

Default is to do nothing.

Reimplemented in FullPhysics::AtmosphereOco, and FullPhysics::SubStateVectorObserver.

Definition at line 47 of file observer.h.

◆ notify_add() [2/2]

template<class T>
virtual void FullPhysics::Observer< T >::notify_add ( )
inlinevirtual

Definition at line 48 of file observer.h.

◆ notify_remove() [1/2]

template<class T>
virtual void FullPhysics::Observer< T >::notify_remove ( T &  Observed_object)
inlinevirtual

Called when an object is removed from an Observable.

Default is to do nothing.

Reimplemented in FullPhysics::AtmosphereOco, and FullPhysics::SubStateVectorObserver.

Definition at line 55 of file observer.h.

◆ notify_remove() [2/2]

template<class T>
virtual void FullPhysics::Observer< T >::notify_remove ( )
inlinevirtual

Definition at line 56 of file observer.h.

◆ notify_update()

Friends And Related Function Documentation

◆ Observable< T >

template<class T>
friend class Observable< T >
friend

Definition at line 62 of file observer.h.


The documentation for this class was generated from the following file:

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:13