From 27e489a4b40a139ace3c679215e44f109f006127 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 17 Jun 2017 07:50:31 +0200 Subject: Use enum for transmission mode --- src/ConfigParser.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'src/ConfigParser.cpp') diff --git a/src/ConfigParser.cpp b/src/ConfigParser.cpp index 3f977ad..8eed560 100644 --- a/src/ConfigParser.cpp +++ b/src/ConfigParser.cpp @@ -345,12 +345,21 @@ void parse_ptree( ptree pt_general = pt.get_child("general"); /* Dab mode logic */ - ensemble->mode = pt_general.get("dabmode", 2); - if ((ensemble->mode < 1) || (ensemble->mode > 4)) { - throw runtime_error("Mode must be between 1-4"); - } - if (ensemble->mode == 4) { - ensemble->mode = 0; + switch (pt_general.get("dabmode", 1)) { + case 1: + ensemble->transmission_mode = TransmissionMode_e::TM_I; + break; + case 2: + ensemble->transmission_mode = TransmissionMode_e::TM_II; + break; + case 3: + ensemble->transmission_mode = TransmissionMode_e::TM_III; + break; + case 4: + ensemble->transmission_mode = TransmissionMode_e::TM_IV; + break; + default: + throw runtime_error("Mode must be between 1-4"); } /******************** READ ENSEMBLE PARAMETERS *************/ -- cgit v1.2.3