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
+13 -10
View File
@@ -1,13 +1,13 @@
#include "util/typedefs.hpp"
#include "extractor/tarjan_scc.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/dynamic_graph.hpp"
#include "util/static_graph.hpp"
#include "util/exception.hpp"
#include "util/fingerprint.hpp"
#include "util/graph_loader.hpp"
#include "util/make_unique.hpp"
#include "util/exception.hpp"
#include "util/simple_logger.hpp"
#include "util/static_graph.hpp"
#include "util/typedefs.hpp"
#include <boost/filesystem.hpp>
@@ -65,8 +65,8 @@ std::size_t loadGraph(const char *path,
std::vector<NodeID> traffic_light_node_list;
std::vector<NodeID> barrier_node_list;
auto number_of_nodes = util::loadNodesFromFile(input_stream, barrier_node_list,
traffic_light_node_list, coordinate_list);
auto number_of_nodes = util::loadNodesFromFile(
input_stream, barrier_node_list, traffic_light_node_list, coordinate_list);
util::loadEdgesFromFile(input_stream, edge_list);
@@ -83,13 +83,17 @@ std::size_t loadGraph(const char *path,
if (input_edge.forward)
{
graph_edge_list.emplace_back(input_edge.source, input_edge.target,
(std::max)(input_edge.weight, 1), input_edge.name_id);
graph_edge_list.emplace_back(input_edge.source,
input_edge.target,
(std::max)(input_edge.weight, 1),
input_edge.name_id);
}
if (input_edge.backward)
{
graph_edge_list.emplace_back(input_edge.target, input_edge.source,
(std::max)(input_edge.weight, 1), input_edge.name_id);
graph_edge_list.emplace_back(input_edge.target,
input_edge.source,
(std::max)(input_edge.weight, 1),
input_edge.name_id);
}
}
@@ -136,7 +140,6 @@ int main(int argc, char *argv[]) try
osrm::tools::deleteFileIfExists("component.shx");
osrm::tools::deleteFileIfExists("component.shp");
OGRRegisterAll();
const char *psz_driver_name = "ESRI Shapefile";
+18 -13
View File
@@ -39,23 +39,27 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig
"core,k",
boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0),
"Percentage of the graph (in vertices) to contract [0..1]")(
"segment-speed-file", boost::program_options::value<std::vector<std::string>>(
&contractor_config.segment_speed_lookup_paths)
->composing(),
"segment-speed-file",
boost::program_options::value<std::vector<std::string>>(
&contractor_config.segment_speed_lookup_paths)
->composing(),
"Lookup files containing nodeA, nodeB, speed data to adjust edge weights")(
"turn-penalty-file", boost::program_options::value<std::vector<std::string>>(
&contractor_config.turn_penalty_lookup_paths)
->composing(),
"turn-penalty-file",
boost::program_options::value<std::vector<std::string>>(
&contractor_config.turn_penalty_lookup_paths)
->composing(),
"Lookup files containing from_, to_, via_nodes, and turn penalties to adjust turn weights")(
"level-cache,o", boost::program_options::value<bool>(&contractor_config.use_cached_priority)
->default_value(false),
"level-cache,o",
boost::program_options::value<bool>(&contractor_config.use_cached_priority)
->default_value(false),
"Use .level file to retain the contaction level for each node from the last run.");
// 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()("input,i", boost::program_options::value<boost::filesystem::path>(
&contractor_config.osrm_input_path),
"Input file in .osm, .osm.bz2 or .osm.pbf format");
hidden_options.add_options()(
"input,i",
boost::program_options::value<boost::filesystem::path>(&contractor_config.osrm_input_path),
"Input file in .osm, .osm.bz2 or .osm.pbf format");
// positional option
boost::program_options::positional_options_description positional_options;
@@ -65,9 +69,10 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig
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(
"Usage: " + boost::filesystem::path(executable).filename().string() + " <input.osrm> [options]");
"Usage: " + boost::filesystem::path(executable).filename().string() +
" <input.osrm> [options]");
visible_options.add(generic_options).add(config_options);
// parse command line options
+7 -5
View File
@@ -52,9 +52,10 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
// 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()("input,i", boost::program_options::value<boost::filesystem::path>(
&extractor_config.input_path),
"Input file in .osm, .osm.bz2 or .osm.pbf format");
hidden_options.add_options()(
"input,i",
boost::program_options::value<boost::filesystem::path>(&extractor_config.input_path),
"Input file in .osm, .osm.bz2 or .osm.pbf format");
// positional option
boost::program_options::positional_options_description positional_options;
@@ -64,9 +65,10 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
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() + " <input.osm/.osm.bz2/.osm.pbf> [options]");
boost::filesystem::path(executable).filename().string() +
" <input.osm/.osm.bz2/.osm.pbf> [options]");
visible_options.add(generic_options).add(config_options);
// parse command line options
+2 -2
View File
@@ -40,8 +40,8 @@ void runStatistics(std::vector<double> &timings_vector, Statistics &stats)
double primary_sum = std::accumulate(timings_vector.begin(), timings_vector.end(), 0.0);
stats.mean = primary_sum / timings_vector.size();
double primary_sq_sum = std::inner_product(timings_vector.begin(), timings_vector.end(),
timings_vector.begin(), 0.0);
double primary_sq_sum = std::inner_product(
timings_vector.begin(), timings_vector.end(), timings_vector.begin(), 0.0);
stats.dev = std::sqrt(primary_sq_sum / timings_vector.size() - (stats.mean * stats.mean));
}
}
+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);
+2 -3
View File
@@ -1,7 +1,7 @@
#include <cstdio>
#include "storage/shared_memory.hpp"
#include "storage/shared_datatype.hpp"
#include "storage/shared_memory.hpp"
#include "util/simple_logger.hpp"
namespace osrm
@@ -16,8 +16,7 @@ void deleteRegion(const SharedDataType region)
{
if (SharedMemory::RegionExists(region) && !SharedMemory::Remove(region))
{
const std::string name = [&]
{
const std::string name = [&] {
switch (region)
{
case CURRENT_REGIONS:
+7 -5
View File
@@ -10,7 +10,9 @@
using namespace osrm;
// generate boost::program_options object for the routing part
bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesystem::path& base_path)
bool generateDataStoreOptions(const int argc,
const char *argv[],
boost::filesystem::path &base_path)
{
// declare a group of options that will be allowed only on command line
boost::program_options::options_description generic_options("Options");
@@ -23,9 +25,9 @@ bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesys
// 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", boost::program_options::value<boost::filesystem::path>(&base_path),
"base path to .osrm file");
hidden_options.add_options()("base,b",
boost::program_options::value<boost::filesystem::path>(&base_path),
"base path to .osrm file");
// positional option
boost::program_options::positional_options_description positional_options;
@@ -35,7 +37,7 @@ bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesys
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() + " [<options>] <configuration>");
visible_options.add(generic_options).add(config_options);
+1 -1
View File
@@ -1,5 +1,5 @@
#include "util/simple_logger.hpp"
#include "storage/shared_barriers.hpp"
#include "util/simple_logger.hpp"
#include <iostream>