8.0 Adding program options

(Win version)

< 7.0 | 8.0 | 8.1 >

In this part, you will use the Boost Program Options library to add the ability to specify options on the command line so that information such as tree and data file names need not be hard coded.

In the previous step, we hard-coded the name of the tree file into the main function. This forces our users to always name their data file test.tre or go to some trouble (editing main.cpp and recompiling the program) in order to change the file names. Software run from the command line normally requires some input from the user, and such user input is normally accommodated by command line options (or switches if they are boolean true/false options). We will use the Boost program_options library to manage these options for our project. In this part you will also create a Strom class of which one instance will be created. This Strom object will have a run method that is called once program options are processed.

Step Title Description
Step 8.1 The Strom class

The Strom class encapsulates the program itself, providing “global” variables and access to command line options.

Step 8.2 Testing program options

Test the command line option capability by specifying the tree file to be processed on the command line.

< 7.0 | 8.0 | 8.1 >