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 <Memento.h>
Classes | |
class | Memento |
Represents a single memento (snapshot) of the text state before an operation is applied. The operation becomes the name of the memento for display purposes. More... | |
Public Member Functions | |
Memento_TextObject (std::string text) | |
Constructs a text object with an initial string. | |
std::string | Text () |
Gets the text in this TextObject. | |
void | SetText (const std::string &value) |
Sets the text in this TextObject. | |
IMemento::shared_ptr_t | GetMemento (std::string operationName) |
Returns an IMemento object containing a snapshot of the text stored in this class instance. | |
void | RestoreMemento (IMemento::shared_ptr_t memento) |
Sets the text in this class instance to the snapshot stored in the given IMemento object (which is assumed to be from this class). | |
std::string | ToString () |
Converts the Memento_TextObject to a string (makes it easier to use the class in string formatting). | |
Private Attributes | |
std::string | _text |
The text that can change in this Memento_TextObject class. | |
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).
|
inline |
Constructs a text object with an initial string.
text | The initial string for the text object. |
Definition at line 134 of file Memento.h.
References Memento_TextObject::_text.
|
inline |
Returns an IMemento object containing a snapshot of the text stored in this class instance.
Definition at line 159 of file Memento.h.
References Memento_TextObject::_text.
|
inline |
Sets the text in this class instance to the snapshot stored in the given IMemento object (which is assumed to be from this class).
memento | The IMemento object to restore to. |
Definition at line 170 of file Memento.h.
References Memento_TextObject::_text, and Memento_TextObject::Text().
|
inline |
Sets the text in this TextObject.
Definition at line 150 of file Memento.h.
References Memento_TextObject::_text.
|
inline |
Gets the text in this TextObject.
Definition at line 142 of file Memento.h.
References Memento_TextObject::_text.
Referenced by Memento_TextObject::RestoreMemento().
|
inline |
Converts the Memento_TextObject to a string (makes it easier to use the class in string formatting).
Definition at line 184 of file Memento.h.
References Memento_TextObject::_text.
Referenced by DesignPatternExamples_cpp::Memento_Exercise().
|
private |
The text that can change in this Memento_TextObject class.
Definition at line 122 of file Memento.h.
Referenced by Command_TextObject::__init__(), Memento_TextObject::__init__(), Memento_TextObject::GetMemento(), Memento_TextObject::Memento_TextObject(), Command_TextObject::Reset(), Memento_TextObject::RestoreMemento(), Memento_TextObject::SetText(), Memento_TextObject::Text(), Command_TextObject::Text(), Memento_TextObject.Memento::Text(), Memento_TextObject::ToString(), and Command_TextObject::ToString().