Bridge Header

namespace bridge_pattern

Namespace for the Bridge pattern.

class Abstraction
#include <bridge.hpp>

The Abstraction defines the high-level control logic and delegates low-level operations to the Implementor.

Subclassed by bridge_pattern::RefinedAbstraction

Public Functions

explicit Abstraction(Implementor *implementor)

Constructor to initialize the abstraction with an Implementor.

Parameters:

implementor – Pointer to the Implementor instance.

virtual ~Abstraction() = default

Virtual destructor to clean up resources.

virtual std::string operation() const

High-level operation implemented using the Implementor.

Returns:

A string representing the result of the operation.

Protected Attributes

Implementor *implementor

Pointer to the associated Implementor.

class ConcreteImplementorA : public bridge_pattern::Implementor
#include <bridge.hpp>

A concrete implementation of the Implementor interface.

Public Functions

virtual std::string operationImpl() const override

Implementation-specific operation for ConcreteImplementorA.

Returns:

A string representing the operation of ConcreteImplementorA.

class ConcreteImplementorB : public bridge_pattern::Implementor
#include <bridge.hpp>

Another concrete implementation of the Implementor interface.

Public Functions

virtual std::string operationImpl() const override

Implementation-specific operation for ConcreteImplementorB.

Returns:

A string representing the operation of ConcreteImplementorB.

class Implementor
#include <bridge.hpp>

The Implementor interface defines the interface for low-level operations.

Subclassed by bridge_pattern::ConcreteImplementorA, bridge_pattern::ConcreteImplementorB

Public Functions

virtual ~Implementor() = default
virtual std::string operationImpl() const = 0

Performs a low-level operation.

Returns:

A string representing the operation details.

class RefinedAbstraction : public bridge_pattern::Abstraction
#include <bridge.hpp>

The RefinedAbstraction adds additional functionality to the Abstraction.

Public Functions

explicit RefinedAbstraction(Implementor *implementor)

Constructor to initialize the refined abstraction with an Implementor.

Parameters:

implementor – Pointer to the Implementor instance.

virtual std::string operation() const override

Enhanced high-level operation implemented using the Implementor.

Returns:

A string representing the result of the refined operation.

Inner Classes

Inner Namespaces