Stride Reference Manual  - generated for commit 9643b11
ContactType.h
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  * Copyright 2018, Jan Broeckhove and Bistromatics group.
15  */
16 
22 #pragma once
23 
24 #include <cstdint>
25 #include <iostream>
26 #include <iterator>
27 #include <string>
28 #include <vector>
29 
30 namespace stride {
31 namespace ContactType {
32 
34 enum class Id : unsigned int
35 {
36  Household = static_cast<unsigned int>(0), // Needs to be zero.
37  K12School,
38  College,
39  Workplace,
42 };
43 
45 inline constexpr unsigned int NumOfTypes() { return 6U; }
46 
48 bool IsId(const std::string& s);
49 
51 Id ToId(const std::string& s);
52 
54 inline constexpr std::size_t ToSizeT(Id id) { return static_cast<std::size_t>(id); }
55 
57 std::string ToString(Id w);
58 
61 template <Id... ids>
62 struct IDPack
63 {
64  constexpr static std::initializer_list<Id> AsInitializerList = {ids...};
65 };
66 
68 using IdPack_t =
70 
72 constexpr IdPack_t IdPack;
73 
75 constexpr std::initializer_list<Id> IdList = IdPack_t::AsInitializerList;
76 
77 } // namespace ContactType
78 } // namespace stride
bool IsId(const string &s)
Check whether string is name of a ContactPoolType::Id.
Definition: ContactType.cpp:33
Id
Enumerates the ContactPool types.
Definition: ContactType.h:34
constexpr std::size_t ToSizeT(Id id)
Cast to size_t for indexing.
Definition: ContactType.h:54
constexpr std::initializer_list< Id > IdList
To allow iteration over the type ids.
Definition: ContactType.h:75
K12school with lower (inclusive) and upper (exclusive) age bracket.
Definition: AgeBrackets.h:43
Id ToId(const string &s)
Converts a string with name to Id.
Definition: ContactType.cpp:48
constexpr unsigned int NumOfTypes()
Number of ContactPool types.
Definition: ContactType.h:45
Keeps all available Ids in a template pack and exposes it as a std::initialize_list Useful when initi...
Definition: ContactType.h:62
College with lower (inclusive) and upper (exclusive) age bracket.
Definition: AgeBrackets.h:61
string ToString(Id c)
Converts a ContactPoolType::Id value to corresponding name.
Definition: ContactType.cpp:63
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28
constexpr IdPack_t IdPack
A constexpr global variable that gives access to the available Ids.
Definition: ContactType.h:72
College with lower (inclusive) and upper (exclusive) age bracket.
Definition: AgeBrackets.h:52
static constexpr std::initializer_list< Id > AsInitializerList
Exposed as std::initializer_list.
Definition: ContactType.h:64