change library interface to expose json container as structure to exchange data
This commit is contained in:
+3
-3
@@ -35,9 +35,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
class OSRM_impl;
|
||||
struct RouteParameters;
|
||||
|
||||
namespace http
|
||||
namespace JSON
|
||||
{
|
||||
class Reply;
|
||||
struct Object;
|
||||
}
|
||||
|
||||
class OSRM
|
||||
@@ -48,7 +48,7 @@ class OSRM
|
||||
public:
|
||||
explicit OSRM(ServerPaths paths, const bool use_shared_memory = false);
|
||||
~OSRM();
|
||||
void RunQuery(RouteParameters &route_parameters, http::Reply &reply);
|
||||
int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result);
|
||||
};
|
||||
|
||||
#endif // OSRM_H
|
||||
|
||||
@@ -44,8 +44,6 @@ namespace boost { namespace interprocess { class named_mutex; } }
|
||||
#include "../Server/DataStructures/InternalDataFacade.h"
|
||||
#include "../Server/DataStructures/SharedBarriers.h"
|
||||
#include "../Server/DataStructures/SharedDataFacade.h"
|
||||
//TODO: remove
|
||||
#include "../Server/Http/Reply.h"
|
||||
#include "../Util/make_unique.hpp"
|
||||
#include "../Util/ProgramOptions.h"
|
||||
#include "../Util/simple_logger.hpp"
|
||||
@@ -104,13 +102,12 @@ void OSRM_impl::RegisterPlugin(BasePlugin *plugin)
|
||||
plugin_map.emplace(plugin->GetDescriptor(), plugin);
|
||||
}
|
||||
|
||||
void OSRM_impl::RunQuery(RouteParameters &route_parameters, http::Reply &reply)
|
||||
int OSRM_impl::RunQuery(RouteParameters &route_parameters, JSON::Object &json_result)
|
||||
{
|
||||
const PluginMap::const_iterator &iter = plugin_map.find(route_parameters.service);
|
||||
|
||||
if (plugin_map.end() != iter)
|
||||
{
|
||||
reply.status = http::Reply::ok;
|
||||
if (barrier)
|
||||
{
|
||||
// lock update pending
|
||||
@@ -131,7 +128,7 @@ void OSRM_impl::RunQuery(RouteParameters &route_parameters, http::Reply &reply)
|
||||
->CheckAndReloadFacade();
|
||||
}
|
||||
|
||||
iter->second->HandleRequest(route_parameters, reply);
|
||||
iter->second->HandleRequest(route_parameters, json_result);
|
||||
if (barrier)
|
||||
{
|
||||
// lock query
|
||||
@@ -148,10 +145,11 @@ void OSRM_impl::RunQuery(RouteParameters &route_parameters, http::Reply &reply)
|
||||
barrier->no_running_queries_condition.notify_all();
|
||||
}
|
||||
}
|
||||
return 200;
|
||||
}
|
||||
else
|
||||
{
|
||||
reply = http::Reply::StockReply(http::Reply::badRequest);
|
||||
return 400;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +162,7 @@ OSRM::OSRM(ServerPaths paths, const bool use_shared_memory)
|
||||
|
||||
OSRM::~OSRM() { OSRM_pimpl_.reset(); }
|
||||
|
||||
void OSRM::RunQuery(RouteParameters &route_parameters, http::Reply &reply)
|
||||
int OSRM::RunQuery(RouteParameters &route_parameters, JSON::Object &json_result)
|
||||
{
|
||||
OSRM_pimpl_->RunQuery(route_parameters, reply);
|
||||
return OSRM_pimpl_->RunQuery(route_parameters, json_result);
|
||||
}
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ class BasePlugin;
|
||||
namespace http { class Reply; }
|
||||
struct RouteParameters;
|
||||
|
||||
#include <osrm/json_container.hpp>
|
||||
#include <osrm/server_paths.hpp>
|
||||
|
||||
#include "../data_structures/query_edge.hpp"
|
||||
@@ -52,7 +53,7 @@ class OSRM_impl
|
||||
OSRM_impl(ServerPaths paths, const bool use_shared_memory);
|
||||
OSRM_impl(const OSRM_impl &) = delete;
|
||||
virtual ~OSRM_impl();
|
||||
void RunQuery(RouteParameters &route_parameters, http::Reply &reply);
|
||||
int RunQuery(RouteParameters &route_parameters, JSON::Object &json_result);
|
||||
|
||||
private:
|
||||
void RegisterPlugin(BasePlugin *plugin);
|
||||
|
||||
Reference in New Issue
Block a user