Add api_version
gloabal variable to profiles
Currently only `0` is supported (the default).
This commit is contained in:
parent
b9b52cb857
commit
0f3a463854
@ -30,6 +30,8 @@ struct LuaScriptingContext final
|
|||||||
bool has_node_function;
|
bool has_node_function;
|
||||||
bool has_way_function;
|
bool has_way_function;
|
||||||
bool has_segment_function;
|
bool has_segment_function;
|
||||||
|
|
||||||
|
int api_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,6 +44,9 @@ struct LuaScriptingContext final
|
|||||||
class Sol2ScriptingEnvironment final : public ScriptingEnvironment
|
class Sol2ScriptingEnvironment final : public ScriptingEnvironment
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const constexpr int SUPPORTED_MIN_API_VERSION = 0;
|
||||||
|
static const constexpr int SUPPORTED_MAX_API_VERSION = 0;
|
||||||
|
|
||||||
explicit Sol2ScriptingEnvironment(const std::string &file_name);
|
explicit Sol2ScriptingEnvironment(const std::string &file_name);
|
||||||
~Sol2ScriptingEnvironment() override = default;
|
~Sol2ScriptingEnvironment() override = default;
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
api_version = 0
|
||||||
|
|
||||||
-- Bicycle profile
|
-- Bicycle profile
|
||||||
|
|
||||||
local find_access_tag = require("lib/access").find_access_tag
|
local find_access_tag = require("lib/access").find_access_tag
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
api_version = 0
|
||||||
|
|
||||||
-- Car profile
|
-- Car profile
|
||||||
local find_access_tag = require("lib/access").find_access_tag
|
local find_access_tag = require("lib/access").find_access_tag
|
||||||
local get_destination = require("lib/destination").get_destination
|
local get_destination = require("lib/destination").get_destination
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
api_version = 0
|
||||||
-- Foot profile
|
-- Foot profile
|
||||||
|
|
||||||
local find_access_tag = require("lib/access").find_access_tag
|
local find_access_tag = require("lib/access").find_access_tag
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
api_version = 0
|
||||||
-- Rasterbot profile
|
-- Rasterbot profile
|
||||||
|
|
||||||
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
|
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
api_version = 0
|
||||||
-- Rasterbot profile
|
-- Rasterbot profile
|
||||||
|
|
||||||
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
|
-- Minimalist node_ and way_functions in order to test source_ and segment_functions
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
api_version = 0
|
||||||
-- Testbot profile
|
-- Testbot profile
|
||||||
|
|
||||||
-- Moves at fixed, well-known speeds, practical for testing speed and travel times:
|
-- Moves at fixed, well-known speeds, practical for testing speed and travel times:
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
api_version = 0
|
||||||
|
|
||||||
-- Testbot, with turn penalty
|
-- Testbot, with turn penalty
|
||||||
-- Used for testing turn penalties
|
-- Used for testing turn penalties
|
||||||
|
|
||||||
|
@ -306,6 +306,20 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
|
|||||||
context.has_node_function = node_function.valid();
|
context.has_node_function = node_function.valid();
|
||||||
context.has_way_function = way_function.valid();
|
context.has_way_function = way_function.valid();
|
||||||
context.has_segment_function = segment_function.valid();
|
context.has_segment_function = segment_function.valid();
|
||||||
|
auto maybe_version = context.state.get<sol::optional<int>>("api_version");
|
||||||
|
if (maybe_version)
|
||||||
|
{
|
||||||
|
context.api_version = *maybe_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.api_version < SUPPORTED_MIN_API_VERSION ||
|
||||||
|
context.api_version > SUPPORTED_MAX_API_VERSION )
|
||||||
|
{
|
||||||
|
throw util::exception("Invalid profile API version " + std::to_string(context.api_version) +
|
||||||
|
" only versions from " + std::to_string(SUPPORTED_MIN_API_VERSION) +
|
||||||
|
" to " + std::to_string(SUPPORTED_MAX_API_VERSION) +
|
||||||
|
" are supported." + SOURCE_REF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ProfileProperties &Sol2ScriptingEnvironment::GetProfileProperties()
|
const ProfileProperties &Sol2ScriptingEnvironment::GetProfileProperties()
|
||||||
|
Loading…
Reference in New Issue
Block a user