Skip to content

Commit d8b0623

Browse files
committed
Move the middle factory function into its own cpp file
1 parent f453be4 commit d8b0623

File tree

4 files changed

+22
-11
lines changed

4 files changed

+22
-11
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ set(osm2pgsql_lib_SOURCES
88
geometry-processor.cpp
99
input.cpp
1010
logging.cpp
11+
middle.cpp
1112
middle-pgsql.cpp
1213
middle-ram.cpp
1314
node-persistent-cache.cpp

src/middle.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
#include "middle-pgsql.hpp"
3+
#include "middle-ram.hpp"
4+
#include "middle.hpp"
5+
#include "options.hpp"
6+
7+
std::shared_ptr<middle_t> create_middle(options_t const &options)
8+
{
9+
if (options.slim) {
10+
return std::make_shared<middle_pgsql_t>(&options);
11+
}
12+
13+
return std::make_shared<middle_ram_t>(&options);
14+
}
15+

src/middle.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include "osmtypes.hpp"
99
#include "thread-pool.hpp"
1010

11+
class options_t;
12+
1113
/**
1214
* Interface for returning information about raw OSM input data from a cache.
1315
*/
@@ -104,4 +106,7 @@ struct middle_t
104106

105107
inline middle_t::~middle_t() = default;
106108

109+
/// Factory function: Instantiate the middle based on the command line options.
110+
std::shared_ptr<middle_t> create_middle(options_t const &options);
111+
107112
#endif // OSM2PGSQL_MIDDLE_HPP

src/osm2pgsql.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
#include "format.hpp"
2828
#include "input.hpp"
2929
#include "logging.hpp"
30-
#include "middle-pgsql.hpp"
31-
#include "middle-ram.hpp"
30+
#include "middle.hpp"
3231
#include "options.hpp"
3332
#include "osmdata.hpp"
3433
#include "output.hpp"
@@ -39,15 +38,6 @@
3938
#include <exception>
4039
#include <memory>
4140

42-
static std::shared_ptr<middle_t> create_middle(options_t const &options)
43-
{
44-
if (options.slim) {
45-
return std::make_shared<middle_pgsql_t>(&options);
46-
}
47-
48-
return std::make_shared<middle_ram_t>(&options);
49-
}
50-
5141
int main(int argc, char *argv[])
5242
{
5343
try {

0 commit comments

Comments
 (0)