Stride Reference Manual  - generated for commit 9643b11
ImportPopBuilder.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 2018, 2019 Jan Broeckhove and Bistromatics group.
14  */
15 
21 #include "ImportPopBuilder.h"
22 
23 #include "geopop/GeoGrid.h"
26 #include "pop/Population.h"
27 #include "util/LogUtils.h"
28 
29 #include <boost/property_tree/ptree.hpp>
30 #include <spdlog/logger.h>
31 
32 namespace stride {
33 
34 using namespace std;
35 using namespace boost::property_tree;
36 using namespace geopop;
37 
38 shared_ptr<Population> ImportPopBuilder::Build(shared_ptr<Population> pop)
39 {
40  const auto importFile = m_config.get<string>("run.population_file");
41  m_stride_logger->info("Importing population from file {}.", importFile);
42 
43  GeoGridReaderFactory geoGridReaderFactory;
44  const auto& reader = geoGridReaderFactory.CreateReader(importFile, pop.get());
45  reader->Read();
46  pop->RefGeoGrid().Finalize();
47  return pop;
48 }
49 
50 } // namespace stride
A Factory for creating the correct implementation of a GeoGridReader based on the filename extension...
std::shared_ptr< GeoGridReader > CreateReader(const std::string &filename, stride::Population *pop) const
Create a GeoGridReader based on the provided extension in the filename.
Initialize populations.
STL namespace.
Logging (spdlog) utilities.
Namespace for the geographic and demograhic classes.
Definition: Coordinate.h:21
std::shared_ptr< Population > Build(std::shared_ptr< Population > pop) override
Creates a population by importing it.
Header file for the core Population class.
Namespace for the simulator and related classes.
Definition: Calendar.cpp:28