Stride Reference Manual  - generated for commit 9643b11
ContactPool.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  */
15 
21 #pragma once
22 
23 #include "contact/ContactLogMode.h"
24 #include "contact/ContactType.h"
25 
26 #include <tuple>
27 #include <vector>
28 
29 namespace stride {
30 
31 class Person;
32 
39 {
40 public:
42  ContactPool(unsigned int poolId, ContactType::Id type);
43 
45  ~ContactPool() = default;
46 
48  void AddMember(Person* p);
49 
51  unsigned int GetId() const { return m_pool_id; }
52 
54  unsigned int GetInfectedCount() const;
55 
57  const std::vector<Person*>& GetPool() const { return m_members; }
58 
60  ContactType::Id GetType() const { return m_pool_type; }
61 
62 public:
63  // To iterate over the members.
64  using iterator = std::vector<stride::Person*>::iterator;
65 
67  iterator begin() { return m_members.begin(); }
68 
70  iterator end() { return m_members.end(); }
71 
73  size_t size() const { return m_members.size(); }
74 
76  Person* const& operator[](size_t index) const { return m_members[index]; }
77 
78 private:
80  std::tuple<bool, unsigned int> SortMembers();
81 
83  template <ContactLogMode::Id LL, bool TIC, bool TO>
84  friend class Infector;
85 
86 private:
87  unsigned int m_index_immune;
88  unsigned int m_pool_id;
90  std::vector<Person*> m_members;
91 };
92 
93 } // namespace stride
std::vector< Person * > m_members
Pointers to contactpool members (raw pointers intentional).
Definition: ContactPool.h:90
Id
Enumerates the ContactPool types.
Definition: ContactType.h:34
A group of Persons that potentially have contacts with one another.
Definition: ContactPool.h:38
std::vector< stride::Person * >::iterator iterator
Definition: ContactPool.h:64
ContactType::Id GetType() const
Get the type of ContactPool, used for logging and tests.
Definition: ContactPool.h:60
Person *const & operator[](size_t index) const
Gets a Person by index, doesn&#39;t performs a range check.
Definition: ContactPool.h:76
unsigned int GetId() const
Get the pool id.
Definition: ContactPool.h:51
void AddMember(Person *p)
Add the given Person.
Definition: ContactPool.cpp:37
unsigned int GetInfectedCount() const
Get Infected count.
Definition: ContactPool.cpp:43
iterator end()
Iterator to end of persons.
Definition: ContactPool.h:70
iterator begin()
Iterator to first person.
Definition: ContactPool.h:67
ContactType::Id m_pool_type
The type of the ContactPool (for logging and testing purposes).
Definition: ContactPool.h:89
unsigned int m_index_immune
Index of the first immune member in the ContactPool.
Definition: ContactPool.h:87
const std::vector< Person * > & GetPool() const
Get the entire pool of members.
Definition: ContactPool.h:57
size_t size() const
Gets current size of Location storage.
Definition: ContactPool.h:73
Definition of ContactPool Id Type.
unsigned int m_pool_id
The ID of the ContactPool (for logging purposes).
Definition: ContactPool.h:88
std::tuple< bool, unsigned int > SortMembers()
Sort w.r.t. health status: order: exposed/infected/recovered, susceptible, immune.
Definition: ContactPool.cpp:55
Header for the ContactLogMode class.
Actual contacts and transmission in contactpool (primary template).
Definition: Infector.h:69
~ContactPool()=default
Default will do.
ContactPool(unsigned int poolId, ContactType::Id type)
Initializing constructor.
Definition: ContactPool.cpp:32
Store and handle person data.
Definition: Person.h:34
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28