memento_pattern::Originator

class Originator

The Originator class creates and restores Memento objects.

Public Functions

inline void setState(const std::string &newState)

Sets the state of the Originator.

Parameters:

newState – The new state.

inline std::string getState() const

Retrieves the current state of the Originator.

Returns:

The current state as a string.

inline std::unique_ptr<Memento> createMemento() const

Creates a Memento containing the current state.

Returns:

A unique pointer to a Memento.

inline void restoreMemento(const Memento &memento)

Restores the state from a given Memento.

Parameters:

memento – The Memento to restore from.