/GoalUndo

Primary LanguageC++The UnlicenseUnlicense

GoalUndo

Purpose

This is a class for managing a history of goals (and their sub-operations) for an advanced "undo" feature. It is meant for use as an exercise in learning how to test C++ classes using GoogleTest.

Overview

Public Methods Parameters Description
undoGoal none When there are existing goals, it removes the most recently added one, along with any associated operations
undoOperation none When there is an existing goal with more than one operation, remove the most recently added operation. When there is only one operation in the most recently added goal, it removes both the operation and the goal (i.e. goals cannot exist without any operations in it).
undoOperation string undoOp Overloaded undoOperation that searches the most recent goal (LIFO order) for an operation that matches the argument and removes (only) the first match found. If there are no matches, nothing is removed.
getGoal none Returns the name of the most recently added goal, or an empty string if there are no goals.
getOperations none Returns the names of all of the operations in the most recently added goal, with a space between each operation.
addOperation string newGoal, string newOp Adds a new operation (newOp) within a new goal (newGoal). Both have to be non-empty strings. If either argument is an empty string, nothing is added.
addOperation string newOp Adds a new operation (newOp) within the most recently added goal. If the argument is an empty string, nothing is added. If no goals exist, it creates a new goal with the same name as the new operation