38 virtual std::string
Name() = 0;
84 Memento(std::string name, std::string text)
161 return std::make_shared<Memento>(operationName,
_text);
172 if (memento !=
nullptr)
Represents a single memento (snapshot) of the text state before an operation is applied....
std::string Text()
The saved text in this memento. This is accessible only by the Memento_TextObject class since it is t...
Memento(std::string name, std::string text)
Constructor.
std::string _name
The name of this memento (really just the name of the operation that triggered the need for this meme...
std::string Name() override
The name of this memento. This is seen as the operation that triggered the need for the memento.
std::string _text
The snapshot of the text data as stored in the Memento_TextObject class instance.
Container for a string. Need to use a class that allows the text to be changed while the container (t...
Memento_TextObject(std::string text)
Constructs a text object with an initial string.
std::string Text()
Gets the text in this TextObject.
std::string ToString()
Converts the Memento_TextObject to a string (makes it easier to use the class in string formatting).
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 as...
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.
std::string _text
The text that can change in this Memento_TextObject class.
The namespace containing all Design Pattern Examples implemented in C++.
Represents a single memento, a single snapshot of the state of the Memento_TextObject class as repres...
std::shared_ptr< IMemento > shared_ptr_t
Alias to make working with a shared pointer easier to type.
virtual ~IMemento()
Virtual destructor.
virtual std::string Name()=0
The name of the memento (snapshot). Useful for displaying a list of mementos in an undo list....