reformat Prepare.h/cpp with clang-format

This commit is contained in:
Dennis Luxen 2014-07-10 15:24:30 +02:00
parent bda9de0775
commit 2a19ded9d5
2 changed files with 54 additions and 57 deletions

View File

@ -55,14 +55,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <thread> #include <thread>
#include <vector> #include <vector>
Prepare::Prepare() : Prepare::Prepare() : requested_num_threads(1) {}
requested_num_threads(1)
{
}
Prepare::~Prepare() Prepare::~Prepare() {}
{
}
int Prepare::Process(int argc, char *argv[]) int Prepare::Process(int argc, char *argv[])
{ {
@ -71,19 +66,18 @@ int Prepare::Process(int argc, char *argv[])
TIMER_START(expansion); TIMER_START(expansion);
if (!ParseArguments(argc, argv)) if (!ParseArguments(argc, argv))
{ return 0; {
return 0;
} }
if (!boost::filesystem::is_regular_file(input_path)) if (!boost::filesystem::is_regular_file(input_path))
{ {
SimpleLogger().Write(logWARNING) << "Input file " << input_path.string() SimpleLogger().Write(logWARNING) << "Input file " << input_path.string() << " not found!";
<< " not found!";
return 1; return 1;
} }
if (!boost::filesystem::is_regular_file(profile_path)) if (!boost::filesystem::is_regular_file(profile_path))
{ {
SimpleLogger().Write(logWARNING) << "Profile " << profile_path.string() SimpleLogger().Write(logWARNING) << "Profile " << profile_path.string() << " not found!";
<< " not found!";
return 1; return 1;
} }
@ -132,7 +126,9 @@ int Prepare::Process(int argc, char *argv[])
EdgeBasedGraphFactory::SpeedProfileProperties speed_profile; EdgeBasedGraphFactory::SpeedProfileProperties speed_profile;
if (!SetupScriptingEnvironment(lua_state, speed_profile)) if (!SetupScriptingEnvironment(lua_state, speed_profile))
{ return 1;} {
return 1;
}
#ifdef WIN32 #ifdef WIN32
#pragma message("Memory consumption on Windows can be higher due to different bit packing") #pragma message("Memory consumption on Windows can be higher due to different bit packing")
@ -164,8 +160,12 @@ int Prepare::Process(int argc, char *argv[])
DeallocatingVector<EdgeBasedEdge> edge_based_edge_list; DeallocatingVector<EdgeBasedEdge> edge_based_edge_list;
// init node_based_edge_list, edge_based_edge_list by edgeList // init node_based_edge_list, edge_based_edge_list by edgeList
BuildEdgeExpandedGraph(lua_state, number_of_node_based_nodes, number_of_edge_based_nodes, BuildEdgeExpandedGraph(lua_state,
node_based_edge_list, edge_based_edge_list, speed_profile); number_of_node_based_nodes,
number_of_edge_based_nodes,
node_based_edge_list,
edge_based_edge_list,
speed_profile);
lua_close(lua_state); lua_close(lua_state);
TIMER_STOP(expansion); TIMER_STOP(expansion);
@ -218,8 +218,7 @@ int Prepare::Process(int argc, char *argv[])
max_used_node_id = std::max(max_used_node_id, edge.source); max_used_node_id = std::max(max_used_node_id, edge.source);
max_used_node_id = std::max(max_used_node_id, edge.target); max_used_node_id = std::max(max_used_node_id, edge.target);
} }
SimpleLogger().Write(logDEBUG) << "input graph has " << number_of_edge_based_nodes SimpleLogger().Write(logDEBUG) << "input graph has " << number_of_edge_based_nodes << " nodes";
<< " nodes";
SimpleLogger().Write(logDEBUG) << "contracted graph has " << max_used_node_id << " nodes"; SimpleLogger().Write(logDEBUG) << "contracted graph has " << max_used_node_id << " nodes";
max_used_node_id += 1; max_used_node_id += 1;
@ -283,8 +282,8 @@ int Prepare::Process(int argc, char *argv[])
#ifndef NDEBUG #ifndef NDEBUG
if (current_edge.data.distance <= 0) if (current_edge.data.distance <= 0)
{ {
SimpleLogger().Write(logWARNING) SimpleLogger().Write(logWARNING) << "Edge: " << edge
<< "Edge: " << edge << ",source: " << contracted_edge_list[edge].source << ",source: " << contracted_edge_list[edge].source
<< ", target: " << contracted_edge_list[edge].target << ", target: " << contracted_edge_list[edge].target
<< ", dist: " << current_edge.data.distance; << ", dist: " << current_edge.data.distance;
@ -304,16 +303,13 @@ int Prepare::Process(int argc, char *argv[])
TIMER_STOP(preparing); TIMER_STOP(preparing);
SimpleLogger().Write() << "Preprocessing : " << TIMER_SEC(preparing) << " seconds"; SimpleLogger().Write() << "Preprocessing : " << TIMER_SEC(preparing) << " seconds";
SimpleLogger().Write() << "Expansion : " SimpleLogger().Write() << "Expansion : " << (number_of_node_based_nodes / TIMER_SEC(expansion))
<< (number_of_node_based_nodes / TIMER_SEC(expansion))
<< " nodes/sec and " << " nodes/sec and "
<< (number_of_edge_based_nodes / TIMER_SEC(expansion)) << (number_of_edge_based_nodes / TIMER_SEC(expansion)) << " edges/sec";
<< " edges/sec";
SimpleLogger().Write() << "Contraction: " SimpleLogger().Write() << "Contraction: "
<< (number_of_edge_based_nodes / TIMER_SEC(contraction)) << (number_of_edge_based_nodes / TIMER_SEC(contraction))
<< " nodes/sec and " << " nodes/sec and " << number_of_used_edges / TIMER_SEC(contraction)
<< number_of_used_edges / TIMER_SEC(contraction)
<< " edges/sec"; << " edges/sec";
node_array.clear(); node_array.clear();
@ -333,8 +329,7 @@ bool Prepare::ParseArguments(int argc, char *argv[])
{ {
// declare a group of options that will be allowed only on command line // declare a group of options that will be allowed only on command line
boost::program_options::options_description generic_options("Options"); boost::program_options::options_description generic_options("Options");
generic_options.add_options()("version,v", "Show version")("help,h", generic_options.add_options()("version,v", "Show version")("help,h", "Show this help message")(
"Show this help message")(
"config,c", "config,c",
boost::program_options::value<boost::filesystem::path>(&config_file_path) boost::program_options::value<boost::filesystem::path>(&config_file_path)
->default_value("contractor.ini"), ->default_value("contractor.ini"),
@ -351,7 +346,8 @@ bool Prepare::ParseArguments(int argc, char *argv[])
->default_value("profile.lua"), ->default_value("profile.lua"),
"Path to LUA routing profile")( "Path to LUA routing profile")(
"threads,t", "threads,t",
boost::program_options::value<unsigned int>(&requested_num_threads)->default_value(tbb::task_scheduler_init::default_num_threads()), boost::program_options::value<unsigned int>(&requested_num_threads)
->default_value(tbb::task_scheduler_init::default_num_threads()),
"Number of threads to use"); "Number of threads to use");
// hidden options, will be allowed both on command line and in config file, but will not be // hidden options, will be allowed both on command line and in config file, but will not be
@ -442,7 +438,9 @@ void Prepare::CheckRestrictionsFile(FingerPrint &fingerprint_orig)
\brief Setups scripting environment (lua-scripting) \brief Setups scripting environment (lua-scripting)
Also initializes speed profile. Also initializes speed profile.
*/ */
bool Prepare::SetupScriptingEnvironment(lua_State *lua_state, EdgeBasedGraphFactory::SpeedProfileProperties &speed_profile) bool
Prepare::SetupScriptingEnvironment(lua_State *lua_state,
EdgeBasedGraphFactory::SpeedProfileProperties &speed_profile)
{ {
// open utility libraries string library; // open utility libraries string library;
luaL_openlibs(lua_state); luaL_openlibs(lua_state);
@ -559,4 +557,3 @@ void Prepare::BuildRTree(std::vector<EdgeBasedNode> &node_based_edge_list)
rtree_leafs_path.c_str(), rtree_leafs_path.c_str(),
internal_to_external_node_map); internal_to_external_node_map);
} }

View File

@ -22,7 +22,6 @@ public:
typedef DynamicGraph<EdgeData>::InputEdge InputEdge; typedef DynamicGraph<EdgeData>::InputEdge InputEdge;
typedef StaticGraph<EdgeData>::InputEdge StaticEdge; typedef StaticGraph<EdgeData>::InputEdge StaticEdge;
explicit Prepare(); explicit Prepare();
Prepare(const Prepare &) = delete; Prepare(const Prepare &) = delete;
~Prepare(); ~Prepare();
@ -32,7 +31,8 @@ public:
protected: protected:
bool ParseArguments(int argc, char *argv[]); bool ParseArguments(int argc, char *argv[]);
void CheckRestrictionsFile(FingerPrint &fingerprint_orig); void CheckRestrictionsFile(FingerPrint &fingerprint_orig);
bool SetupScriptingEnvironment(lua_State *myLuaState, EdgeBasedGraphFactory::SpeedProfileProperties &speed_profile); bool SetupScriptingEnvironment(lua_State *myLuaState,
EdgeBasedGraphFactory::SpeedProfileProperties &speed_profile);
void BuildEdgeExpandedGraph(lua_State *myLuaState, void BuildEdgeExpandedGraph(lua_State *myLuaState,
NodeID nodeBasedNodeNumber, NodeID nodeBasedNodeNumber,
unsigned &nodeBasedEdgesNumber, unsigned &nodeBasedEdgesNumber,