Address PR comments
Renamed lua_function_exists and removes unused print function
This commit is contained in:
@@ -60,7 +60,7 @@ struct RouteParameters : public BaseParameters
|
||||
const bool alternatives_,
|
||||
const GeometriesType geometries_,
|
||||
const OverviewType overview_,
|
||||
boost::optional<bool> uturns_,
|
||||
const boost::optional<bool> uturns_,
|
||||
Args... args_)
|
||||
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternatives{alternatives_},
|
||||
geometries{geometries_}, overview{overview_}, uturns{uturns_}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace osrm
|
||||
namespace extractor
|
||||
{
|
||||
|
||||
class ProfileProperties;
|
||||
struct ProfileProperties;
|
||||
|
||||
class Extractor
|
||||
{
|
||||
|
||||
@@ -21,8 +21,6 @@ class GraphCompressor
|
||||
using EdgeData = util::NodeBasedDynamicGraph::EdgeData;
|
||||
|
||||
public:
|
||||
GraphCompressor();
|
||||
|
||||
void Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
const std::unordered_set<NodeID> &traffic_lights,
|
||||
RestrictionMap &restriction_map,
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef PROFILE_PROPERTIES_HPP
|
||||
#define PROFILE_PROPERTIES_HPP
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace extractor
|
||||
@@ -20,7 +22,7 @@ struct ProfileProperties
|
||||
|
||||
void SetUturnPenalty(const double u_turn_penalty_)
|
||||
{
|
||||
u_turn_penalty = static_cast<int>(u_turn_penalty_ * 10.);
|
||||
u_turn_penalty = boost::numeric_cast<int>(u_turn_penalty_ * 10.);
|
||||
}
|
||||
|
||||
double GetTrafficSignalPenalty() const
|
||||
@@ -30,7 +32,7 @@ struct ProfileProperties
|
||||
|
||||
void SetTrafficSignalPenalty(const double traffic_signal_penalty_)
|
||||
{
|
||||
traffic_signal_penalty = static_cast<int>(traffic_signal_penalty_ * 10.);
|
||||
traffic_signal_penalty = boost::numeric_cast<int>(traffic_signal_penalty_ * 10.);
|
||||
}
|
||||
|
||||
//! penalty to cross a traffic light in deci-seconds
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/raster_source.hpp"
|
||||
|
||||
#include "util/lua_util.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
@@ -28,12 +30,9 @@ class ScriptingEnvironment
|
||||
public:
|
||||
struct Context
|
||||
{
|
||||
Context();
|
||||
~Context();
|
||||
|
||||
ProfileProperties properties;
|
||||
SourceContainer sources;
|
||||
lua_State *state;
|
||||
util::LuaState state;
|
||||
};
|
||||
|
||||
explicit ScriptingEnvironment(const std::string &file_name);
|
||||
@@ -47,7 +46,7 @@ class ScriptingEnvironment
|
||||
void InitContext(Context &context);
|
||||
std::mutex init_mutex;
|
||||
std::string file_name;
|
||||
tbb::enumerable_thread_specific<std::shared_ptr<Context>> script_contexts;
|
||||
tbb::enumerable_thread_specific<std::unique_ptr<Context>> script_contexts;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,19 @@ namespace osrm
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename T> void LUA_print(T output) { std::cout << "[LUA] " << output << std::endl; }
|
||||
struct LuaState
|
||||
{
|
||||
LuaState() : handle{::luaL_newstate(), &::lua_close} { luaL_openlibs(*this); }
|
||||
|
||||
operator lua_State *() { return handle.get(); }
|
||||
operator lua_State const *() const { return handle.get(); }
|
||||
|
||||
using handle_type = std::unique_ptr<lua_State, decltype(&::lua_close)>;
|
||||
handle_type handle;
|
||||
};
|
||||
|
||||
// Check if the lua function <name> is defined
|
||||
inline bool lua_function_exists(lua_State *lua_state, const char *name)
|
||||
inline bool luaFunctionExists(lua_State *lua_state, const char *name)
|
||||
{
|
||||
luabind::object globals_table = luabind::globals(lua_state);
|
||||
luabind::object lua_function = globals_table[name];
|
||||
|
||||
Reference in New Issue
Block a user