I have to implement a set_configuration API of signal processing device. This API should ensure that set of configuration provided by the user is legitimate (within expected range) before setting it. Moreover, configuration values are in discrete form.
I want to manipulate preprocessor directives in C to implement this conditional check; if/else takes lot of lines to implement.
One possible solution I think of is following;
typedef enum {VERY_LOW, LOW, HIGH, VERY_HIGH} config_first;
typedef enum {VERY_SHORT, SHORT, LONG, VERY_LONG} config_second;
typedef enum {SQUARE, CIRCLE, TRIANGLE, RECTANGLE} config_third;
typedef enum {GREEN, WHITE, YELLOW, BROWN, GREY} config_fourth;
typedef enum {WOOD, IRON, STEEL} config_fourth;
typedef enum {SWIM, FLY, RUN, WALK} config_fifth;
set_configuration(config_first first, config_second second, config_third third, config_fourth fourth, config_fifth fifth)
My question is, Is there any way I can combine all these configurations to one enumeration and make it as follows:
set_configuration(config_set config)
where config_set is a preprocessor directive.