Class Adapter Header

namespace class_adapter_pattern

Namespace for the Class Adapter pattern.

class Adaptee
#include <class_adapter.hpp>

The Adaptee class provides specific functionality.

The Adaptee has methods that perform useful operations but with an interface that is incompatible with the Target interface.

Subclassed by class_adapter_pattern::Adapter

Public Functions

inline std::string specificRequest() const

Performs a specific operation provided by the Adaptee.

This method showcases the Adaptee’s unique functionality.

Returns:

A string response indicating the Adaptee’s behavior.

class Adapter : public class_adapter_pattern::Target, private class_adapter_pattern::Adaptee
#include <class_adapter.hpp>

The Adapter class bridges the Target and Adaptee interfaces.

The Adapter allows the Adaptee’s functionality to be used where the Target’s interface is required by translating requests from the Target format to the Adaptee’s specific format.

Public Functions

inline virtual std::string request() const override

Translates the Target’s request into the Adaptee’s specificRequest.

This method allows the client to interact with the Adaptee’s functionality using the Target interface.

Returns:

A string response combining the Adapter’s translation and the Adaptee’s functionality.

class Target
#include <class_adapter.hpp>

Interface representing the Target.

The Target defines the domain-specific interface expected by the client. Classes implementing this interface can be used seamlessly by the client.

Subclassed by class_adapter_pattern::Adapter

Public Functions

virtual ~Target() = default
virtual std::string request() const = 0

Handles a generic request from the client.

This method provides the interface that the client interacts with.

Returns:

A string response from the Target.

Inner Classes

Inner Namespaces