Format with clang-format 3.8

This commit is contained in:
Patrick Niklaus
2016-05-27 21:05:04 +02:00
parent 21c47514da
commit 6e16eab6ec
202 changed files with 2485 additions and 1863 deletions
+89 -63
View File
@@ -3,8 +3,8 @@
#include "util/simple_logger.hpp"
#include "util/version.hpp"
#include "osrm/osrm.hpp"
#include "osrm/engine_config.hpp"
#include "osrm/osrm.hpp"
#include "osrm/storage_config.hpp"
#include <boost/any.hpp>
@@ -23,8 +23,8 @@
#include <future>
#include <iostream>
#include <new>
#include <thread>
#include <string>
#include <thread>
#ifdef _WIN32
boost::function0<void> console_ctrl_function;
@@ -52,19 +52,18 @@ const static unsigned INIT_OK_DO_NOT_START_ENGINE = 1;
const static unsigned INIT_FAILED = -1;
// generate boost::program_options object for the routing part
inline unsigned
generateServerProgramOptions(const int argc,
const char *argv[],
boost::filesystem::path &base_path,
std::string &ip_address,
int &ip_port,
int &requested_num_threads,
bool &use_shared_memory,
bool &trial,
int &max_locations_trip,
int &max_locations_viaroute,
int &max_locations_distance_table,
int &max_locations_map_matching)
inline unsigned generateServerProgramOptions(const int argc,
const char *argv[],
boost::filesystem::path &base_path,
std::string &ip_address,
int &ip_port,
int &requested_num_threads,
bool &use_shared_memory,
bool &trial,
int &max_locations_trip,
int &max_locations_viaroute,
int &max_locations_distance_table,
int &max_locations_map_matching)
{
using boost::program_options::value;
using boost::filesystem::path;
@@ -77,29 +76,36 @@ generateServerProgramOptions(const int argc,
// declare a group of options that will be allowed on command line
boost::program_options::options_description config_options("Configuration");
config_options.add_options() //
("ip,i", value<std::string>(&ip_address)->default_value("0.0.0.0"),
config_options.add_options() //
("ip,i",
value<std::string>(&ip_address)->default_value("0.0.0.0"),
"IP address") //
("port,p", value<int>(&ip_port)->default_value(5000),
("port,p",
value<int>(&ip_port)->default_value(5000),
"TCP/IP port") //
("threads,t", value<int>(&requested_num_threads)->default_value(8),
("threads,t",
value<int>(&requested_num_threads)->default_value(8),
"Number of threads to use") //
("shared-memory,s",
value<bool>(&use_shared_memory)->implicit_value(true)->default_value(false),
"Load data from shared memory") //
("max-viaroute-size", value<int>(&max_locations_viaroute)->default_value(500),
("max-viaroute-size",
value<int>(&max_locations_viaroute)->default_value(500),
"Max. locations supported in viaroute query") //
("max-trip-size", value<int>(&max_locations_trip)->default_value(100),
("max-trip-size",
value<int>(&max_locations_trip)->default_value(100),
"Max. locations supported in trip query") //
("max-table-size", value<int>(&max_locations_distance_table)->default_value(100),
("max-table-size",
value<int>(&max_locations_distance_table)->default_value(100),
"Max. locations supported in distance table query") //
("max-matching-size", value<int>(&max_locations_map_matching)->default_value(100),
("max-matching-size",
value<int>(&max_locations_map_matching)->default_value(100),
"Max. locations supported in map matching query");
// hidden options, will be allowed on command line, but will not be shown to the user
boost::program_options::options_description hidden_options("Hidden options");
hidden_options.add_options()("base,b", value<boost::filesystem::path>(&base_path),
"base path to .osrm file");
hidden_options.add_options()(
"base,b", value<boost::filesystem::path>(&base_path), "base path to .osrm file");
// positional option
boost::program_options::positional_options_description positional_options;
@@ -109,7 +115,7 @@ generateServerProgramOptions(const int argc,
boost::program_options::options_description cmdline_options;
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
const auto* executable = argv[0];
const auto *executable = argv[0];
boost::program_options::options_description visible_options(
boost::filesystem::path(executable).filename().string() + " <base.osrm> [<options>]");
visible_options.add(generic_options).add(config_options);
@@ -146,7 +152,8 @@ generateServerProgramOptions(const int argc,
}
else if (use_shared_memory && option_variables.count("base"))
{
util::SimpleLogger().Write(logWARNING) << "Shared memory settings conflict with path settings.";
util::SimpleLogger().Write(logWARNING)
<< "Shared memory settings conflict with path settings.";
}
util::SimpleLogger().Write() << visible_options;
@@ -163,11 +170,18 @@ int main(int argc, const char *argv[]) try
EngineConfig config;
boost::filesystem::path base_path;
const unsigned init_result = generateServerProgramOptions(
argc, argv, base_path, ip_address, ip_port, requested_thread_num,
config.use_shared_memory, trial_run, config.max_locations_trip,
config.max_locations_viaroute, config.max_locations_distance_table,
config.max_locations_map_matching);
const unsigned init_result = generateServerProgramOptions(argc,
argv,
base_path,
ip_address,
ip_port,
requested_thread_num,
config.use_shared_memory,
trial_run,
config.max_locations_trip,
config.max_locations_viaroute,
config.max_locations_distance_table,
config.max_locations_map_matching);
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
{
return EXIT_SUCCESS;
@@ -180,7 +194,7 @@ int main(int argc, const char *argv[]) try
{
config.storage_config = storage::StorageConfig(base_path);
}
if(!config.IsValid())
if (!config.IsValid())
{
if (base_path.empty() != config.use_shared_memory)
{
@@ -188,53 +202,65 @@ int main(int argc, const char *argv[]) try
}
else
{
if(!boost::filesystem::is_regular_file(config.storage_config.ram_index_path))
if (!boost::filesystem::is_regular_file(config.storage_config.ram_index_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.ram_index_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.ram_index_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.file_index_path))
if (!boost::filesystem::is_regular_file(config.storage_config.file_index_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.file_index_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.file_index_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.hsgr_data_path))
if (!boost::filesystem::is_regular_file(config.storage_config.hsgr_data_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.hsgr_data_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.hsgr_data_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.nodes_data_path))
if (!boost::filesystem::is_regular_file(config.storage_config.nodes_data_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.nodes_data_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.nodes_data_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.edges_data_path))
if (!boost::filesystem::is_regular_file(config.storage_config.edges_data_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.edges_data_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.edges_data_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.core_data_path))
if (!boost::filesystem::is_regular_file(config.storage_config.core_data_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.core_data_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.core_data_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.geometries_path))
if (!boost::filesystem::is_regular_file(config.storage_config.geometries_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.geometries_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.geometries_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.timestamp_path))
if (!boost::filesystem::is_regular_file(config.storage_config.timestamp_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.timestamp_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.timestamp_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.datasource_names_path))
if (!boost::filesystem::is_regular_file(config.storage_config.datasource_names_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.datasource_names_path << " is not found";
util::SimpleLogger().Write(logWARNING)
<< config.storage_config.datasource_names_path << " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.datasource_indexes_path))
if (!boost::filesystem::is_regular_file(config.storage_config.datasource_indexes_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.datasource_indexes_path << " is not found";
util::SimpleLogger().Write(logWARNING)
<< config.storage_config.datasource_indexes_path << " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.names_data_path))
if (!boost::filesystem::is_regular_file(config.storage_config.names_data_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.names_data_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.names_data_path
<< " is not found";
}
if(!boost::filesystem::is_regular_file(config.storage_config.properties_path))
if (!boost::filesystem::is_regular_file(config.storage_config.properties_path))
{
util::SimpleLogger().Write(logWARNING) << config.storage_config.properties_path << " is not found";
util::SimpleLogger().Write(logWARNING) << config.storage_config.properties_path
<< " is not found";
}
}
return EXIT_FAILURE;
@@ -289,11 +315,10 @@ int main(int argc, const char *argv[]) try
}
else
{
std::packaged_task<int()> server_task([&]
{
routing_server->Run();
return 0;
});
std::packaged_task<int()> server_task([&] {
routing_server->Run();
return 0;
});
auto future = server_task.get_future();
std::thread server_thread(std::move(server_task));
@@ -306,7 +331,8 @@ int main(int argc, const char *argv[]) try
sigaddset(&wait_mask, SIGTERM);
pthread_sigmask(SIG_BLOCK, &wait_mask, nullptr);
util::SimpleLogger().Write() << "running and waiting for requests";
if(std::getenv("SIGNAL_PARENT_WHEN_READY")) {
if (std::getenv("SIGNAL_PARENT_WHEN_READY"))
{
kill(getppid(), SIGUSR1);
}
sigwait(&wait_mask, &sig);