Print Control
Print_Ctrl_Base, is a base class, that allows you to define a class with the functionality to control your program's runtime displayed messages, or trace.
This control is done by defining Boolean flags, that allow or forbid the display of various types of information, at various times during program execution. Here are two common usage examples: 1. While debugging your code, you wish to show messages during the initialization phase of your modules. But, once that's debugging is done, you disable those print outs - not removing their code. Thus, if you need to revisit that part, you can always re-enable print-out. 2. You wish to examine the behavior of your program when it's well into its execution. You can then enable print-out, starting close to the relevant region, e.g. from packet 2500 onward. |
|
The specific Boolean flags, and optional ranges during which these flags enable or disable displayed messages, are defined in a derived class. The test directory includes two such classes: Print_Ctrl_1 and Print_Ctrl_2.
The flags and ranges of each derived class could be controlled via command line options and/or a text file.
The base class includes a reference to a Cmdline_Parser instance, that can be used to find command line options.
Using functions from file_func helps in parsing a text file, locating print control options and ranges.
The base class defines two functions, that every derived class must implement:
set_print_everything() enables the display of every type of information, and all the time (i.e. ignoring any ranges).
set_print_nothing() does the opposite, disables any print-out from controlled code.
These functions are meant to be used as a quick and blunt tool to enable or disable every controlled print-out in a program.
The flags and ranges of each derived class could be controlled via command line options and/or a text file.
The base class includes a reference to a Cmdline_Parser instance, that can be used to find command line options.
Using functions from file_func helps in parsing a text file, locating print control options and ranges.
The base class defines two functions, that every derived class must implement:
set_print_everything() enables the display of every type of information, and all the time (i.e. ignoring any ranges).
set_print_nothing() does the opposite, disables any print-out from controlled code.
These functions are meant to be used as a quick and blunt tool to enable or disable every controlled print-out in a program.