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

Container for a string. Need to use a class that allows the text to be changed while the container (this class) remains constant. This way, operations can be applied to the text and the container's contents change but not the container (strings are immutable in C#; this dances around that problem). More...

#include <Command_Classes.h>

Collaboration diagram for Command_TextObject:
Collaboration graph

Public Types

using shared_ptr_t = std::shared_ptr< Command_TextObject >
 

Public Member Functions

 Command_TextObject (std::string text)
 Constructs a text object with an initial string.
 
std::string Text ()
 Gets the text in this TextObject.
 
void SetText (std::string value)
 Sets the text in this TextObject.
 
void Reset ()
 Resets the TextObject to the starting string.
 
std::string ToString ()
 Converts the TextObject to a string.
 

Private Attributes

std::string _startingText
 
std::string _text
 

Detailed Description

Container for a string. Need to use a class that allows the text to be changed while the container (this class) remains constant. This way, operations can be applied to the text and the container's contents change but not the container (strings are immutable in C#; this dances around that problem).

Definition at line 26 of file Command_Classes.h.

Member Typedef Documentation

◆ shared_ptr_t

using shared_ptr_t = std::shared_ptr<Command_TextObject>

Definition at line 29 of file Command_Classes.h.

Constructor & Destructor Documentation

◆ Command_TextObject()

Command_TextObject ( std::string  text)
inline

Constructs a text object with an initial string.

Parameters
textThe initial string for the text object.

Definition at line 43 of file Command_Classes.h.

References Command_TextObject::_startingText, and Command_TextObject::_text.

Member Function Documentation

◆ Reset()

void Reset ( )
inline

Resets the TextObject to the starting string.

Definition at line 61 of file Command_Classes.h.

References Command_TextObject::_startingText, and Command_TextObject::_text.

◆ SetText()

void SetText ( std::string  value)
inline

Sets the text in this TextObject.

Definition at line 56 of file Command_Classes.h.

References Command_TextObject::_text.

◆ Text()

std::string Text ( )
inline

Gets the text in this TextObject.

Definition at line 52 of file Command_Classes.h.

References Command_TextObject::_text.

◆ ToString()

std::string ToString ( )
inline

Converts the TextObject to a string.

Returns
Returns the text stored in the text object.

Definition at line 70 of file Command_Classes.h.

References Command_TextObject::_text.

Member Data Documentation

◆ _startingText

std::string _startingText
private

◆ _text


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