Stride Reference Manual  1.0
LogMode.cpp
Go to the documentation of this file.
1 /*
2  * This is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU General Public License as published by
4  * the Free Software Foundation, either version 3 of the License, or
5  * any later version.
6  * The software is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  * You should have received a copy of the GNU General Public License
11  * along with the software. If not, see <http://www.gnu.org/licenses/>.
12  *
13  * Copyright 2015, Willem L, Kuylen E, Stijven S & Broeckhove J
14  */
15 
21 #include "LogMode.h"
22 
23 #include <boost/algorithm/string.hpp>
24 #include <map>
25 
26 namespace {
27 
28 using stride::LogMode;
29 using boost::to_upper;
30 using namespace std;
31 
32 map<LogMode, string> g_log_mode_name {
33  make_pair(LogMode::None, "None"),
34  make_pair(LogMode::Transmissions, "Transmissions"),
35  make_pair(LogMode::Contacts, "Contacts"),
36  make_pair(LogMode::Null, "Null")
37 };
38 
39 map<string, LogMode> g_name_log_mode {
40  make_pair("NONE", LogMode::None),
41  make_pair("TRANSMISSIONS", LogMode::Transmissions),
42  make_pair("CONTACTS", LogMode::Contacts),
43  make_pair("NULL", LogMode::Null)
44 };
45 
46 }
47 
48 namespace stride {
49 
50 string toString(LogMode l) {
51  return (g_log_mode_name.count(l) == 1) ? g_log_mode_name[l] : "Null";
52 }
53 
54 bool isLogMode(const string& s) {
55  std::string t {s};
56  to_upper(t);
57  return (g_name_log_mode.count(t) == 1);
58 }
59 
60 LogMode toLogMode(const string& s) {
61  std::string t {s};
62  to_upper(t);
63  return (g_name_log_mode.count(t) == 1) ? g_name_log_mode[t] : LogMode::Null;
64 }
65 
66 }
bool isLogMode(const string &s)
Check whether string is name of LogMode value.
Definition: LogMode.cpp:54
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
string toString(LogMode l)
Converts a LogMode value to corresponding name.
Definition: LogMode.cpp:50
STL namespace.
LogMode
Enum specifiying the level of logging required:
Definition: LogMode.h:32
Header for the LogMode class.
LogMode toLogMode(const string &s)
Converts a string with name to LogMode value.
Definition: LogMode.cpp:60