Stride Reference Manual  1.0
ContactProfile.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 "ContactProfile.h"
22 
23 namespace stride {
24 
25 using namespace std;
26 using namespace boost::property_tree;
27 
28 ContactProfile::ContactProfile(ClusterType cluster_type, const ptree& pt_contacts) {
29  const string key = "matrices." + toString(cluster_type);
30  ContactProfile mean_nums;
31  unsigned int i = 0U;
32  for (const auto& participant: pt_contacts.get_child(key)) {
33  double total_contacts = 0;
34  for (const auto& contact: participant.second.get_child("contacts")) {
35  total_contacts += contact.second.get<double>("rate");
36  }
37  (*this)[i++] = total_contacts;
38  }
39 }
40 
41 }
42 
string toString(ClusterType c)
Converts a ClusterType value to corresponding name.
Definition: ClusterType.cpp:54
Time Dependent Person DataType.
Definition: NoBehaviour.h:17
ContactProfile()
Need to keep the default constructor available.
STL namespace.
ClusterType
Enumerates the cluster types.
Definition: ClusterType.h:28
Contact profile.