Stride Reference Manual  - generated for commit 9643b11
GeoGridWriterFactory.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, Jan Broeckhove and Bistromatics group.
14  */
15 
16 #include "GeoGridWriterFactory.h"
17 
18 //#include "GeoGridJSONWriter.h"
19 #include "GeoGridProtoWriter.h"
20 #include "GeoGridWriter.h"
21 #include "util/Exception.h"
22 
23 #include <iostream>
24 
25 #ifdef BOOST_FOUND
26 #include <boost/filesystem.hpp>
27 #include <boost/filesystem/path.hpp>
28 namespace filesys = boost::filesystem;
29 #else
30 #include <filesystem>
31 namespace filesys = std::filesystem;
32 #endif
33 
34 namespace geopop {
35 
36 std::shared_ptr<GeoGridWriter> GeoGridWriterFactory::CreateGeoGridWriter(const std::string& filename)
37 {
38  filesys::path path(filename);
39 
40  /*if (path.extension().string() == ".json") {
41  return std::make_shared<GeoGridJSONWriter>();
42  } else */
43  if (path.extension().string() == ".proto") {
44  return std::make_shared<GeoGridProtoWriter>();
45  } else {
46  throw stride::util::Exception("GeoGridWriterFactory::CreateWriter> Unsupported file extension: " +
47  path.extension().string());
48  }
49 }
50 
51 } // namespace geopop
static std::shared_ptr< GeoGridWriter > CreateGeoGridWriter(const std::string &filename)
Create a GeoGridWriter based on the provided extension in the filename.
Basic exception class: needed to prevent clang-tidy warning "thrown exception type is not nothrow cop...
Definition: Exception.h:28
Namespace for the geographic and demograhic classes.
Definition: Coordinate.h:21