|
A few constructs are used by the base class, us_state_report_generator. These constructs are included in a separate header file described and shown below.
The first construct defined is an enumeration for the sort field, state_sort_field
. There is one enumerator for each state data field
which can be sorted on. When the derived classes call on the base class members to retrieve data, they specify the order of the data to retrieve by
passing a state_sort_field
enumerator. The data returned will be sorted by the specified field.
The second enumeration defined is sort_order
. This enumeration determines if the selected data field is sorted ascending or descending.
The next struct, region_up
defines a function object, which is used in the std::find operation to locate the first state in the specified region. The following struct, division_up
is a function
object which does the same for the state's division
.
The final struct, state_comp
, is a function object which is used with std::sort, to determine the sort field and sort order.
The header file, helper_constructs.h
is presented below for illustration.
Another helper file, state_data.h
is used to declare and define a class which contains statistical info for a single state. In state_data.h
,
the class state_info
is defined. Two helper functions, load_state_data()
and extract_data
are also defined.
Two important enumerations are also declared. The first, us_region
, enumerates the four regions of the US. The second, us_divisions
,
enumerates the divisions of the US. The header file is presented below for illustration.