aboutsummaryrefslogtreecommitdiffstats
path: root/src/fig/FIGSchedulerType.cpp
blob: cb0c122eaeeb9cf5ebfc0f7fea21f99e5e1cc61e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
   Copyright (C) 2026
   Samuel Hunt, Maxxwave Ltd. sam@maxxwave.co.uk

   Copyright (C) 2026
   Matthias P. Braendli, matthias.braendli@mpb.li
   */
/*
   This file is part of ODR-DabMux.

   ODR-DabMux is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as
   published by the Free Software Foundation, either version 3 of the
   License, or (at your option) any later version.

   ODR-DabMux is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with ODR-DabMux.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "fig/FIGSchedulerType.h"
#include "Log.h"
#include <algorithm>
#include <cctype>

namespace FIC {

FIGSchedulerType parse_scheduler_type(const std::string& type_str)
{
    std::string lower = type_str;
    std::transform(lower.begin(), lower.end(), lower.begin(),
                   [](unsigned char c){ return std::tolower(c); });

    if (lower == "priority") {
        return FIGSchedulerType::Priority;
    }
    else if (lower == "classic-rate-tuning") {
        return FIGSchedulerType::ClassicRateTuning;
    }
    else if (lower == "classic" || lower == "default" || lower.empty()) {
        return FIGSchedulerType::Classic;
    }
    else {
        etiLog.level(warn) << "Unknown FIC scheduler type '" << type_str
                           << "', defaulting to classic";
        return FIGSchedulerType::Classic;
    }
}

std::string scheduler_type_to_string(FIGSchedulerType type)
{
    switch (type) {
        case FIGSchedulerType::Classic:
            return "classic";
        case FIGSchedulerType::ClassicRateTuning:
            return "classic-rate-tuning";
        case FIGSchedulerType::Priority:
            return "priority";
        default:
            return "unknown";
    }
}

} // namespace FIC