refactor Tools dir for C++11

This commit is contained in:
Dennis Luxen 2014-05-08 18:33:38 +02:00
parent 3074a0146e
commit 1960c38468
4 changed files with 64 additions and 65 deletions

View File

@ -92,7 +92,7 @@ int main(int argc, char *argv[])
} }
std::vector<ImportEdge> edge_list; std::vector<ImportEdge> edge_list;
const NodeID node_based_node_count = readBinaryOSRMGraphFromStream(input_stream, const NodeID number_of_nodes = readBinaryOSRMGraphFromStream(input_stream,
edge_list, edge_list,
bollard_node_IDs_vector, bollard_node_IDs_vector,
traffic_light_node_IDs_vector, traffic_light_node_IDs_vector,
@ -113,7 +113,8 @@ int main(int argc, char *argv[])
*/ */
SimpleLogger().Write() << "Starting SCC graph traversal"; SimpleLogger().Write() << "Starting SCC graph traversal";
std::shared_ptr<TarjanSCC> tarjan = std::make_shared<TarjanSCC>(node_based_node_count, std::shared_ptr<TarjanSCC> tarjan =
std::make_shared<TarjanSCC>(number_of_nodes,
edge_list, edge_list,
bollard_node_IDs_vector, bollard_node_IDs_vector,
traffic_light_node_IDs_vector, traffic_light_node_IDs_vector,

View File

@ -31,7 +31,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
#include <boost/ref.hpp>
#include <cmath> #include <cmath>
#include <cstdio> #include <cstdio>
@ -110,7 +109,8 @@ int main(int argc, char *argv[])
fcntl(fileno(fd), F_RDAHEAD, 0); fcntl(fileno(fd), F_RDAHEAD, 0);
time1 = std::chrono::steady_clock::now(); time1 = std::chrono::steady_clock::now();
write(fileno(fd), (char *)random_array, number_of_elements * sizeof(unsigned)); write(fileno(fd), (char *)random_array, number_of_elements * sizeof(unsigned));
time2 = std::chrono::steady_clock::now();; time2 = std::chrono::steady_clock::now();
;
fclose(fd); fclose(fd);
#endif #endif
#ifdef __linux__ #ifdef __linux__
@ -142,11 +142,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
//
// Run Non-Cached I/O benchmarks // Run Non-Cached I/O benchmarks
//
if (!boost::filesystem::exists(test_path)) if (!boost::filesystem::exists(test_path))
{ {
throw OSRMException("data file does not exist"); throw OSRMException("data file does not exist");

View File

@ -45,43 +45,43 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Dude, real recursions on the OS stack? You must be brave... // Dude, real recursions on the OS stack? You must be brave...
void print_tree(boost::property_tree::ptree const &property_tree, const unsigned recursion_depth) void print_tree(boost::property_tree::ptree const &property_tree, const unsigned recursion_depth)
{ {
boost::property_tree::ptree::const_iterator end = property_tree.end(); auto end = property_tree.end();
for (boost::property_tree::ptree::const_iterator tree_iterator = property_tree.begin(); tree_iterator != end; ++tree_iterator) for (auto tree_iterator = property_tree.begin(); tree_iterator != end; ++tree_iterator)
{ {
for (unsigned current_recursion = 0; current_recursion < recursion_depth; ++current_recursion) for (unsigned current_recursion = 0; current_recursion < recursion_depth;
++current_recursion)
{ {
std::cout << " " << std::flush; std::cout << " " << std::flush;
} }
std::cout << tree_iterator->first << ": " << tree_iterator->second.get_value<std::string>() << std::endl; std::cout << tree_iterator->first << ": " << tree_iterator->second.get_value<std::string>()
<< std::endl;
print_tree(tree_iterator->second, recursion_depth + 1); print_tree(tree_iterator->second, recursion_depth + 1);
} }
} }
int main(int argc, const char *argv[])
int main (int argc, const char * argv[]) { {
LogPolicy::GetInstance().Unmute(); LogPolicy::GetInstance().Unmute();
try { try
{
std::string ip_address; std::string ip_address;
int ip_port, requested_thread_num; int ip_port, requested_thread_num;
bool use_shared_memory = false, trial = false; bool use_shared_memory = false, trial = false;
ServerPaths server_paths; ServerPaths server_paths;
if( !GenerateServerProgramOptions( if (!GenerateServerProgramOptions(argc,
argc,
argv, argv,
server_paths, server_paths,
ip_address, ip_address,
ip_port, ip_port,
requested_thread_num, requested_thread_num,
use_shared_memory, use_shared_memory,
trial trial))
) {
) {
return 0; return 0;
} }
SimpleLogger().Write() << SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION << ", "
"starting up engines, " << g_GIT_DESCRIPTION << ", " << << "compiled at " << __DATE__ << ", " __TIME__;
"compiled at " << __DATE__ << ", " __TIME__;
OSRM routing_machine(server_paths, use_shared_memory); OSRM routing_machine(server_paths, use_shared_memory);
@ -98,13 +98,13 @@ int main (int argc, const char * argv[]) {
route_parameters.language = ""; // unused atm route_parameters.language = ""; // unused atm
// route_parameters.hints.push_back(); // see wiki, saves I/O if done properly // route_parameters.hints.push_back(); // see wiki, saves I/O if done properly
FixedPointCoordinate start_coordinate(52.519930*COORDINATE_PRECISION,13.438640*COORDINATE_PRECISION); // start_coordinate
FixedPointCoordinate target_coordinate(52.513191*COORDINATE_PRECISION,13.415852*COORDINATE_PRECISION); route_parameters.coordinates.emplace_back(52.519930 * COORDINATE_PRECISION,
route_parameters.coordinates.push_back(start_coordinate); 13.438640 * COORDINATE_PRECISION);
route_parameters.coordinates.push_back(target_coordinate); // target_coordinate
route_parameters.coordinates.emplace_back(52.513191 * COORDINATE_PRECISION,
13.415852 * COORDINATE_PRECISION);
http::Reply osrm_reply; http::Reply osrm_reply;
routing_machine.RunQuery(route_parameters, osrm_reply); routing_machine.RunQuery(route_parameters, osrm_reply);
// attention: super-inefficient hack below: // attention: super-inefficient hack below:
@ -121,7 +121,9 @@ int main (int argc, const char * argv[]) {
boost::property_tree::read_json(my_stream, property_tree); boost::property_tree::read_json(my_stream, property_tree);
print_tree(property_tree, 0); print_tree(property_tree, 0);
} catch (std::exception & current_exception) { }
catch (std::exception &current_exception)
{
SimpleLogger().Write(logWARNING) << "caught exception: " << current_exception.what(); SimpleLogger().Write(logWARNING) << "caught exception: " << current_exception.what();
return -1; return -1;
} }

View File

@ -31,13 +31,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <iostream> #include <iostream>
int main() { int main()
{
LogPolicy::GetInstance().Unmute(); LogPolicy::GetInstance().Unmute();
try try
{ {
SimpleLogger().Write() << SimpleLogger().Write() << "starting up engines, " << g_GIT_DESCRIPTION << ", "
"starting up engines, " << g_GIT_DESCRIPTION << ", " << << "compiled at " << __DATE__ << ", " __TIME__;
"compiled at " << __DATE__ << ", " __TIME__;
SimpleLogger().Write() << "Releasing all locks"; SimpleLogger().Write() << "Releasing all locks";
SharedBarriers barrier; SharedBarriers barrier;
barrier.pending_update_mutex.unlock(); barrier.pending_update_mutex.unlock();