SmartSoft Component-Developer API
Public Member Functions | Protected Member Functions | Friends | List of all members
Smart::ShutdownSubject Class Reference

This class implements the Subject (also called Model) 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::ShutdownSubject:
Smart::IComponent

Public Member Functions

 ShutdownSubject ()
 Default constructor. More...
 
virtual ~ShutdownSubject ()
 Default destructor. More...
 

Protected Member Functions

virtual void attach (IShutdownObserver *observer)
 Attach an IShutdownObserver instance. More...
 
virtual void detach (IShutdownObserver *observer)
 Detach an IShutdownObserver instance. More...
 
virtual void notify_sutdown ()
 Notifies all attached IShutdownObserver instances about an upcoming shutdown. More...
 

Friends

class IShutdownObserver
 allows calling protected attach() and detach() methods More...
 

Detailed Description

This class implements the Subject (also called Model) part of the Observer design pattern for implementing a uniform shutdown procedure for all component's resources.

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

Constructor & Destructor Documentation

◆ ShutdownSubject()

Smart::ShutdownSubject::ShutdownSubject ( )
inline

Default constructor.

◆ ~ShutdownSubject()

virtual Smart::ShutdownSubject::~ShutdownSubject ( )
inlinevirtual

Default destructor.

Member Function Documentation

◆ attach()

virtual void Smart::ShutdownSubject::attach ( IShutdownObserver observer)
inlineprotectedvirtual

Attach an IShutdownObserver instance.

This method should be called from within the constructor of an IShutdownObserver instance. This is possible because the IShutdownObserver is defined as a friend class of IShutdownSubject.

◆ detach()

virtual void Smart::ShutdownSubject::detach ( IShutdownObserver observer)
inlineprotectedvirtual

Detach an IShutdownObserver instance.

This method should be called from within the destructor of an IShutdownObserver instance. This is possible because the IShutdownObserver is defined as a friend class of IShutdownSubject.

◆ notify_sutdown()

virtual void Smart::ShutdownSubject::notify_sutdown ( )
inlineprotectedvirtual

Notifies all attached IShutdownObserver instances about an upcoming shutdown.

An instance of IComponent should call this method just before the component itself cleans-up its own internal resources. In this way, all the attached entities (such as client- and server-ports, as well as tasks) can clean-up their individual internal resources before the component invalidates its own internal resources. This effectively prevents nullpointer exceptions.

Friends And Related Function Documentation

◆ IShutdownObserver

friend class IShutdownObserver
friend

allows calling protected attach() and detach() methods


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