Stride Reference Manual  - generated for commit 9643b11
ContactLogMode.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 2017, Kuylen E, Willem L, Broeckhove J
14  */
15 
21 #include "ContactLogMode.h"
22 
23 #include <boost/algorithm/string.hpp>
24 #include <map>
25 
26 namespace stride {
27 namespace ContactLogMode {
28 
29 using namespace std;
30 using boost::to_upper;
31 
32 string ToString(Id l)
33 {
34  static map<Id, string> names{make_pair(Id::None, "None"), make_pair(Id::Transmissions, "Transmissions"),
35  make_pair(Id::All, "All"), make_pair(Id::Susceptibles, "Susceptibles")};
36  return names.at(l);
37 }
38 
39 Id ToMode(const string& s)
40 {
41  static map<string, Id> modes{make_pair("NONE", Id::None), make_pair("TRANSMISSIONS", Id::Transmissions),
42  make_pair("ALL", Id::All), make_pair("SUSCEPTIBLES", Id::Susceptibles)};
43  std::string t{s};
44  to_upper(t);
45  return modes.at(t);
46 }
47 
48 } // namespace ContactLogMode
49 } // namespace stride
Id ToMode(const string &s)
Converts a string with name to LogMode value.
string ToString(Id l)
Converts a LogMode value to corresponding name.
STL namespace.
Header for the ContactLogMode class.
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28