Template Method Header

namespace template_method_pattern

Namespace for the Template Method pattern.

class AbstractClass
#include <template_method.hpp>

Abstract base class defining the template method and its steps.

Subclassed by template_method_pattern::ConcreteClass1, template_method_pattern::ConcreteClass2

Public Functions

virtual ~AbstractClass() = default

Virtual destructor for proper cleanup of derived classes.

inline void templateMethod() const

The template method defining the skeleton of the algorithm.

This method calls the steps, some of which are implemented by derived classes.

Protected Functions

inline void baseOperation1() const

A base operation implemented in the base class.

inline void baseOperation2() const

Another base operation implemented in the base class.

inline virtual void hook() const

A hook method that can be optionally overridden by subclasses.

virtual void requiredOperation1() const = 0

A pure virtual method to be implemented by subclasses.

virtual void requiredOperation2() const = 0

Another pure virtual method to be implemented by subclasses.

class ConcreteClass1 : public template_method_pattern::AbstractClass
#include <template_method.hpp>

Concrete implementation of the abstract class.

Protected Functions

inline virtual void requiredOperation1() const override

A pure virtual method to be implemented by subclasses.

inline virtual void requiredOperation2() const override

Another pure virtual method to be implemented by subclasses.

inline virtual void hook() const override

A hook method that can be optionally overridden by subclasses.

class ConcreteClass2 : public template_method_pattern::AbstractClass
#include <template_method.hpp>

Another concrete implementation of the abstract class.

Protected Functions

inline virtual void requiredOperation1() const override

A pure virtual method to be implemented by subclasses.

inline virtual void requiredOperation2() const override

Another pure virtual method to be implemented by subclasses.

Inner Classes

Inner Namespaces