diff --git a/Plugins/BasePlugin.h b/Plugins/BasePlugin.h index 77b133efb..d8956d022 100644 --- a/Plugins/BasePlugin.h +++ b/Plugins/BasePlugin.h @@ -33,8 +33,7 @@ public: BasePlugin() { } //Maybe someone can explain the pure virtual destructor thing to me (dennis) virtual ~BasePlugin() { } - virtual std::string GetDescriptor() const = 0; - virtual std::string GetVersionString() const = 0 ; + virtual const std::string & GetDescriptor() const = 0; virtual void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) = 0; inline bool checkCoord(const _Coordinate & c) { @@ -48,7 +47,6 @@ public: } return true; } - }; #endif /* BASEPLUGIN_H_ */ diff --git a/Plugins/HelloWorldPlugin.h b/Plugins/HelloWorldPlugin.h index 8e755ea8a..546789b1e 100644 --- a/Plugins/HelloWorldPlugin.h +++ b/Plugins/HelloWorldPlugin.h @@ -1,8 +1,21 @@ /* - * LocatePlugin.h - * - * Created on: 01.01.2011 - * Author: dennis + open source routing machine + Copyright (C) Dennis Luxen, 2010 + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU AFFERO General Public License as published by +the Free Software Foundation; either version 3 of the License, or +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +or see http://www.gnu.org/licenses/agpl.txt. */ #ifndef HELLOWORLDPLUGIN_H_ @@ -15,10 +28,9 @@ class HelloWorldPlugin : public BasePlugin { public: - HelloWorldPlugin() {} + HelloWorldPlugin() : descriptor_string("hello"){} virtual ~HelloWorldPlugin() { } - std::string GetDescriptor() const { return std::string("hello"); } - std::string GetVersionString() const { return std::string("0.1a"); } + const std::string & GetDescriptor() const { return descriptor_string; } void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) { reply.status = http::Reply::ok; @@ -45,6 +57,8 @@ public: reply.content.append(content.str()); reply.content.append(""); } +private: + std::string descriptor_string; }; #endif /* HELLOWORLDPLUGIN_H_ */ diff --git a/Plugins/LocatePlugin.h b/Plugins/LocatePlugin.h index 9fff478dd..e6f59159e 100644 --- a/Plugins/LocatePlugin.h +++ b/Plugins/LocatePlugin.h @@ -27,18 +27,15 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Server/DataStructures/QueryObjectsStorage.h" #include "../Util/StringUtil.h" -#include - /* * This Plugin locates the nearest node in the road network for a given coordinate. */ class LocatePlugin : public BasePlugin { public: - LocatePlugin(QueryObjectsStorage * objects) { + LocatePlugin(QueryObjectsStorage * objects) : descriptor_string("locate") { nodeHelpDesk = objects->nodeHelpDesk; } - std::string GetDescriptor() const { return std::string("locate"); } - std::string GetVersionString() const { return std::string("0.3 (DL)"); } + const std::string & GetDescriptor() const { return descriptor_string; } void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) { //check number of parameters if(!routeParameters.coordinates.size()) { @@ -102,6 +99,7 @@ public: private: NodeInformationHelpDesk * nodeHelpDesk; + std::string descriptor_string; }; #endif /* LOCATEPLUGIN_H_ */ diff --git a/Plugins/NearestPlugin.h b/Plugins/NearestPlugin.h index 9ea15d32b..a1ca3537e 100644 --- a/Plugins/NearestPlugin.h +++ b/Plugins/NearestPlugin.h @@ -28,21 +28,22 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Server/DataStructures/QueryObjectsStorage.h" #include "../Util/StringUtil.h" -#include - /* * This Plugin locates the nearest point on a street in the road network for a given coordinate. */ class NearestPlugin : public BasePlugin { public: - NearestPlugin(QueryObjectsStorage * objects) : names(objects->names) { + NearestPlugin(QueryObjectsStorage * objects ) + : + names(objects->names), + descriptor_string("nearest") + { nodeHelpDesk = objects->nodeHelpDesk; descriptorTable.insert(std::make_pair("" , 0)); //default descriptor descriptorTable.insert(std::make_pair("json", 1)); } - std::string GetDescriptor() const { return std::string("nearest"); } - std::string GetVersionString() const { return std::string("0.3 (DL)"); } + const std::string & GetDescriptor() const { return descriptor_string; } void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) { //check number of parameters if(!routeParameters.coordinates.size()) { @@ -112,6 +113,7 @@ private: NodeInformationHelpDesk * nodeHelpDesk; HashTable descriptorTable; std::vector & names; + std::string descriptor_string; }; #endif /* NearestPlugin_H_ */ diff --git a/Plugins/TimestampPlugin.h b/Plugins/TimestampPlugin.h index 6a245e116..6142cb825 100644 --- a/Plugins/TimestampPlugin.h +++ b/Plugins/TimestampPlugin.h @@ -24,14 +24,12 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "BasePlugin.h" #include "RouteParameters.h" -#include - class TimestampPlugin : public BasePlugin { public: - TimestampPlugin(QueryObjectsStorage * o) : objects(o) { - } - std::string GetDescriptor() const { return std::string("timestamp"); } - std::string GetVersionString() const { return std::string("0.3 (DL)"); } + TimestampPlugin(QueryObjectsStorage * o) + : objects(o), descriptor_string("timestamp") + { } + const std::string & GetDescriptor() const { return descriptor_string; } void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) { std::string tmp; @@ -70,6 +68,7 @@ public: } private: QueryObjectsStorage * objects; + std::string descriptor_string; }; #endif /* TIMESTAMPPLUGIN_H_ */ diff --git a/Plugins/ViaRoutePlugin.h b/Plugins/ViaRoutePlugin.h index cbeae3fe8..46f17bb3b 100644 --- a/Plugins/ViaRoutePlugin.h +++ b/Plugins/ViaRoutePlugin.h @@ -38,8 +38,6 @@ or see http://www.gnu.org/licenses/agpl.txt. #include -#include -#include #include #include @@ -49,17 +47,20 @@ private: std::vector & names; StaticGraph * graph; HashTable descriptorTable; - std::string pluginDescriptorString; SearchEngine * searchEnginePtr; public: - ViaRoutePlugin(QueryObjectsStorage * objects, std::string psd = "viaroute") : names(objects->names), pluginDescriptorString(psd) { + ViaRoutePlugin(QueryObjectsStorage * objects) + : + names(objects->names), + descriptor_string("viaroute") + { nodeHelpDesk = objects->nodeHelpDesk; graph = objects->graph; searchEnginePtr = new SearchEngine(graph, nodeHelpDesk, names); - descriptorTable.insert(std::make_pair("" , 0)); //default descriptor + descriptorTable.insert(std::make_pair("" , 0)); descriptorTable.insert(std::make_pair("json", 0)); descriptorTable.insert(std::make_pair("gpx" , 1)); } @@ -68,8 +69,8 @@ public: delete searchEnginePtr; } - std::string GetDescriptor() const { return pluginDescriptorString; } - std::string GetVersionString() const { return std::string("0.3 (DL)"); } + const std::string & GetDescriptor() const { return descriptor_string; } + void HandleRequest(const RouteParameters & routeParameters, http::Reply& reply) { //check number of parameters if( 2 > routeParameters.coordinates.size() ) { @@ -209,17 +210,7 @@ public: return; } private: - inline bool checkCoord(const _Coordinate & c) { - if( - c.lat > 90*COORDINATE_PRECISION || - c.lat < -90*COORDINATE_PRECISION || - c.lon > 180*COORDINATE_PRECISION || - c.lon < -180*COORDINATE_PRECISION - ) { - return false; - } - return true; - } + std::string descriptor_string; };