Design Pattern Examples
Overview of object-oriented design patterns
TextElement Class Reference

Represents the core element that can be decorated. Note that this class implements the IRenderElement but otherwise has no knowledge of any of the decorators that might be applied. More...

#include <Decorator_Classes.h>

Inheritance diagram for TextElement:
Inheritance graph
Collaboration diagram for TextElement:
Collaboration graph

Public Member Functions

 TextElement (std::string element)
 Constructor.
 
std::string Render ()
 Render this element as a string.
 
- Public Member Functions inherited from IRenderElement
virtual ~IRenderElement ()
 
virtual std::string Render ()=0
 Render this element as a string.
 

Private Attributes

std::string _elementText
 The raw text at the center of all decorators.
 

Additional Inherited Members

- Public Types inherited from IRenderElement
using shared_ptr_t = std::shared_ptr< IRenderElement >
 An alias to simplify syntax for this shared pointer.
 

Detailed Description

Represents the core element that can be decorated. Note that this class implements the IRenderElement but otherwise has no knowledge of any of the decorators that might be applied.

This class wraps a string and does nothing other than return the string. This way, this class can be decorated because it implements the IRenderElement interface.

Definition at line 210 of file Decorator_Classes.h.

Constructor & Destructor Documentation

◆ TextElement()

TextElement ( std::string  element)
inline

Constructor.

Parameters
elementThe text to be rendered.

Definition at line 224 of file Decorator_Classes.h.

References TextElement::_elementText.

Member Function Documentation

◆ Render()

std::string Render ( )
inlinevirtual

Render this element as a string.

Returns
A string containing the rendering of the element.

Implements IRenderElement.

Definition at line 235 of file Decorator_Classes.h.

References TextElement::_elementText.

Member Data Documentation

◆ _elementText

std::string _elementText
private

The raw text at the center of all decorators.

Definition at line 216 of file Decorator_Classes.h.

Referenced by TextElement::Render(), and TextElement::TextElement().


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