DEPARTMENT OF COMPUTING

CS 3005: Programming in C++

Action Data, Menu Data

In previous assignments the functions declared in image_menu.h needed to have an input stream and an output stream to interact with the user. getString() is an example of this. Other functions also needed an Image object or a PPM object to work on. diagonalQuadPattern() and writeUserImage() are examples of these cases. As we add to the complexity of the software project, some of these functions will require additional parameters, and new functions will requires these parameters, and more.

Soon, our project create a program that allows the user to choose the actions it takes, by using a menu system. This menu will allow the user to read PPM images from files, edit them with several image operations, and save the resulting images back to PPM files.

In this assignment, you will build a pair of classes to support the menu system, and the various parameters needed by the action functions in the system. The ActionData class will contain the input and output streams, some PPM objects, other data necessary to control user interaction, and application status. The MenuData class will keep a collection of all actions the user can apply, the functions that implement the actions, and a help message for each action.

There will not be a new executable program at the end of this assignment. But, there will be one soon.

Assignment

In this assignment, you will add code to the work from the previous assignments. When you have completed the assignment the previous programs will all work the same as they did before. You will also have some unused functions that will make the next assignments easier.

Programming Requirements

The following files must be updated or created and stored in the src directory of your repository.

Create ActionData.h and ActionData.cpp

Declare the ActionData class in the header file, and implement its methods in the implementation file. Descriptions of the data members and methods follow.

Data Members:

Methods:

Create MenuData.h and MenuData.cpp

Declare the MenuData class in the header file, and implement its methods in the implementation file. Descriptions of the data members and methods follow. This class will be used to keep track of the command names that users can type, the function that will be called for each command name, and a text description of each command’s actions.

In the header file, define the ActionFunctionType using this typedef.

typedef void (*ActionFunctionType)(ActionData& action_data);

Data Members:

Methods:

Additions to the PPM Class

Update the PPM header file and implementation file to add the following method used to read images from files.

Update Makefile

Since ActionData.{h,cpp} and MenuData.{h,cpp} have been added, you’ll need to add rules to build ActionData.o, and MenuData.o. Since these are not currently used in any programs, they do not need to be added to any dependency lists, or linker commands, yet.

Build Requirements

Additional Documentation

Show Off Your Work

To receive credit for this assignment, you must

Additionally, the programs must build, run and give correct output.

Last Updated 09/11/2023