SmartSoft Component-Developer API
Public Member Functions | Protected Member Functions | List of all members
Smart::IShutdownObserver Class Referenceabstract

This class implements the Observer part of the Observer design pattern for implementing a uniform shutdown procedure for all component's resources. More...

#include <smartIShutdownObserver.h>

Inheritance diagram for Smart::IShutdownObserver:
Smart::ICommunicationPattern Smart::ITask Smart::IClientPattern Smart::IServerPattern Smart::IActiveQueryServerHandler< RequestType, AnswerType > Smart::IManagedTask Smart::IEventClientPattern< ActivationType, EventType > Smart::IPushClientPattern< DataType > Smart::IQueryClientPattern< RequestType, AnswerType > Smart::ISendClientPattern< DataType > Smart::IEventServerPattern< ActivationType, EventType, UpdateType > Smart::IPushServerPattern< DataType > Smart::IQueryServerPattern< RequestType, AnswerType > Smart::ISendServerPattern< DataType >

Public Member Functions

 IShutdownObserver (ShutdownSubject *subject=nullptr)
 The default constructor. More...
 
virtual ~IShutdownObserver ()
 The default destructor. More...
 
virtual void on_shutdown ()=0
 This is the main update method that will be automatically called from the given subject each time the subject undergoes a notable change. More...
 

Protected Member Functions

void attach_self_to (ShutdownSubject *subject)
 call this method from within the constructor of derived classes More...
 
void detach_self_from (ShutdownSubject *subject)
 this method is called within the destructor More...
 

Detailed Description

This class implements the Observer part of the Observer design pattern for implementing a uniform shutdown procedure for all component's resources.

An IComponent implements the counter-part IShutdownSubject interface that will trigger all attached IShutdownObserver instances just before the IComponent finally shuts down. Each communication pattern (clients and servers) attached to an IComponent should implement IShutdownObserver interface (i.e. the on_shutdown() method) thus providing individual cleanup strategies.

Constructor & Destructor Documentation

◆ IShutdownObserver()

Smart::IShutdownObserver::IShutdownObserver ( ShutdownSubject subject = nullptr)
inline

The default constructor.

This constructor will call subject->attach(this) to start observing the given subject.

Parameters
subjectthe subject (also called model) that this Observer is going to observe

◆ ~IShutdownObserver()

virtual Smart::IShutdownObserver::~IShutdownObserver ( )
inlinevirtual

The default destructor.

This destructor will call subject->detach(this) to stop observing the given subject.

Member Function Documentation

◆ attach_self_to()

void Smart::IShutdownObserver::attach_self_to ( ShutdownSubject subject)
inlineprotected

call this method from within the constructor of derived classes

The IShutdownObserver interface can be derived pure virtual which means that in these cases the default empty constructor will be called. For the pure virtual derivation, the constructor of the derived class should call this method manually to ensure proper registration of the IShutdownObserver.

Parameters
subjectthe subject (i.e. model) of the Observer design pattern

◆ detach_self_from()

void Smart::IShutdownObserver::detach_self_from ( ShutdownSubject subject)
inlineprotected

this method is called within the destructor

This method is called from within the destructor of this class if the internal subject pointer has been set-up before using the attach_self_to() method.

Parameters
subjectthe subject (i.e. model) of the Observer design pattern

◆ on_shutdown()

virtual void Smart::IShutdownObserver::on_shutdown ( )
pure virtual

This is the main update method that will be automatically called from the given subject each time the subject undergoes a notable change.

This method should be implemented in derived classes to provide an individual shutdown (i.e. cleanup) strategy/procedure.

Implemented in Smart::IClientPattern, Smart::IServerPattern, Smart::ITask, and Smart::IManagedTask.


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