From da277d981681425169d51d67ff3c1d5856bc5d3c Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Sep 2013 14:23:06 +0200 Subject: [PATCH 01/11] Adding shared memory data types --- DataStructures/SharedMemoryFactory.h | 165 +++++++++++++++++++++ DataStructures/SharedMemoryVectorWrapper.h | 96 ++++++++++++ Server/DataStructures/SharedDataType.h | 26 ++++ 3 files changed, 287 insertions(+) create mode 100644 DataStructures/SharedMemoryFactory.h create mode 100644 DataStructures/SharedMemoryVectorWrapper.h create mode 100644 Server/DataStructures/SharedDataType.h diff --git a/DataStructures/SharedMemoryFactory.h b/DataStructures/SharedMemoryFactory.h new file mode 100644 index 000000000..9c908a187 --- /dev/null +++ b/DataStructures/SharedMemoryFactory.h @@ -0,0 +1,165 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 SHARED_MEMORY_FACTORY_H +#define SHARED_MEMORY_FACTORY_H + +#include "../Util/OSRMException.h" +#include "../Util/SimpleLogger.h" + +#include +#include +#include +#include + +#include +#include + +struct OSRMLockFile { + boost::filesystem::path operator()() { + boost::filesystem::path temp_dir = + boost::filesystem::temp_directory_path(); + SimpleLogger().Write(logDEBUG) << "creating lock file in " << temp_dir; + boost::filesystem::path lock_file = temp_dir / "osrm.lock"; + SimpleLogger().Write(logDEBUG) << "locking at " << lock_file; + return lock_file; + } +}; + +class SharedMemory : boost::noncopyable { + + //Remove shared memory on destruction + class shm_remove : boost::noncopyable { + private: + int m_shmid; + bool m_initialized; + public: + void SetID(int shmid) { + m_shmid = shmid; + m_initialized = true; + } + + shm_remove() : m_shmid(INT_MIN), m_initialized(false) {} + + ~shm_remove(){ + if(m_initialized) { + SimpleLogger().Write(logDEBUG) << + "automatic memory deallocation"; + boost::interprocess::xsi_shared_memory::remove(m_shmid); + } + } + + }; + +public: + void * Ptr() const { + return region.get_address(); + } + + template + SharedMemory( + const boost::filesystem::path & lock_file, + const IdentifierT id, + const unsigned size = 0 + ) : key( + lock_file.string().c_str(), + id + ) { + if( 0 == size ){ //read_only + shm = boost::interprocess::xsi_shared_memory ( + boost::interprocess::open_only, + key + ); + region = boost::interprocess::mapped_region ( + shm, + boost::interprocess::read_only + ); + } else { //writeable pointer + //remove previously allocated mem + RemoveSharedMemory(key); + shm = boost::interprocess::xsi_shared_memory ( + boost::interprocess::create_only, + key, + size + ); + region = boost::interprocess::mapped_region ( + shm, + boost::interprocess::read_write + ); + + remover.SetID( shm.get_shmid() ); + SimpleLogger().Write(logDEBUG) << + "writeable memory allocated " << size << " bytes"; + } + } + +private: + static void RemoveSharedMemory( + const boost::interprocess::xsi_key &key + ) { + try{ + SimpleLogger().Write(logDEBUG) << "deallocating prev memory"; + boost::interprocess::xsi_shared_memory xsi( + boost::interprocess::open_only, + key + ); + boost::interprocess::xsi_shared_memory::remove(xsi.get_shmid()); + } catch(boost::interprocess::interprocess_exception &e){ + if(e.get_error_code() != boost::interprocess::not_found_error) { + throw; + } + } + } + + boost::interprocess::xsi_key key; + boost::interprocess::xsi_shared_memory shm; + boost::interprocess::mapped_region region; + shm_remove remover; +}; + +template +class SharedMemoryFactory_tmpl : boost::noncopyable { +public: + template + static SharedMemory * Get( + const IdentifierT & id, + const unsigned size = 0 + ) { + try { + LockFileT lock_file; + if(0 == size && !boost::filesystem::exists(lock_file()) ) { + throw OSRMException("lock file does not exist, exiting"); + } + return new SharedMemory(lock_file(), id, size); + } catch(const boost::interprocess::interprocess_exception &e){ + SimpleLogger().Write(logWARNING) << + "caught exception: " << e.what() << + ", code " << e.get_error_code(); + throw OSRMException(e.what()); + } + }; + +private: + SharedMemoryFactory_tmpl() {} +}; + +typedef SharedMemoryFactory_tmpl<> SharedMemoryFactory; + +#endif /* SHARED_MEMORY_POINTER_FACTORY_H */ diff --git a/DataStructures/SharedMemoryVectorWrapper.h b/DataStructures/SharedMemoryVectorWrapper.h new file mode 100644 index 000000000..0773466d9 --- /dev/null +++ b/DataStructures/SharedMemoryVectorWrapper.h @@ -0,0 +1,96 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 SHARED_MEMORY_VECTOR_WRAPPER_H +#define SHARED_MEMORY_VECTOR_WRAPPER_H + +#include +#include +#include + +#include +#include + +template +class ShMemIterator : public std::iterator { + boost::shared_ptr p; +public: + ShMemIterator(boost::shared_ptr & x) :p(x) {} + ShMemIterator(const ShMemIterator & mit) : p(mit.p) {} + ShMemIterator& operator++() { + ++p; + return *this; + } + ShMemIterator operator++(int) { + ShMemIterator tmp(*this); + operator++(); + return tmp; + } + bool operator==(const ShMemIterator& rhs) { + return p==rhs.p; + } + bool operator!=(const ShMemIterator& rhs) { + return p!=rhs.p; + } + DataT& operator*() { + return *p; + } +}; + +template +class SharedMemoryWrapper { +private: + boost::shared_ptr m_ptr; + std::size_t m_size; + + SharedMemoryWrapper() {}; +public: + SharedMemoryWrapper(const DataT * ptr, std::size_t size) : + m_ptr(ptr), + m_size(size) + { } + + ShMemIterator begin() const { + return ShMemIterator(m_ptr); + } + + ShMemIterator end() const { + return ShMemIterator(m_ptr+m_size); + } + + std::size_t size() const { return m_size; } + + DataT & operator[](const int index) { + BOOST_ASSERT_MSG(index < m_size, "invalid size"); + return m_ptr[index]; + } +}; + +template +class ShMemVector : public + boost::conditional< + SharedMemory, + SharedMemoryWrapper, + std::vector + >::type +{ }; + + +#endif //SHARED_MEMORY_VECTOR_WRAPPER_H diff --git a/Server/DataStructures/SharedDataType.h b/Server/DataStructures/SharedDataType.h new file mode 100644 index 000000000..83cc6da81 --- /dev/null +++ b/Server/DataStructures/SharedDataType.h @@ -0,0 +1,26 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 SHARED_DATA_TYPE_H_ +#define SHARED_DATA_TYPE_H_ + +enum SharedDataType { NAMES_INDEX, NAMES_LIST }; + +#endif /* SHARED_DATA_TYPE_H_ */ From e19f54a378658767ca9b543472948a36d389bd52 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Sep 2013 14:23:06 +0200 Subject: [PATCH 02/11] Adding shared memory data types --- DataStructures/SharedMemoryFactory.h | 165 +++++++++++++++++++++ DataStructures/SharedMemoryVectorWrapper.h | 96 ++++++++++++ Server/DataStructures/SharedDataType.h | 26 ++++ 3 files changed, 287 insertions(+) create mode 100644 DataStructures/SharedMemoryFactory.h create mode 100644 DataStructures/SharedMemoryVectorWrapper.h create mode 100644 Server/DataStructures/SharedDataType.h diff --git a/DataStructures/SharedMemoryFactory.h b/DataStructures/SharedMemoryFactory.h new file mode 100644 index 000000000..9c908a187 --- /dev/null +++ b/DataStructures/SharedMemoryFactory.h @@ -0,0 +1,165 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 SHARED_MEMORY_FACTORY_H +#define SHARED_MEMORY_FACTORY_H + +#include "../Util/OSRMException.h" +#include "../Util/SimpleLogger.h" + +#include +#include +#include +#include + +#include +#include + +struct OSRMLockFile { + boost::filesystem::path operator()() { + boost::filesystem::path temp_dir = + boost::filesystem::temp_directory_path(); + SimpleLogger().Write(logDEBUG) << "creating lock file in " << temp_dir; + boost::filesystem::path lock_file = temp_dir / "osrm.lock"; + SimpleLogger().Write(logDEBUG) << "locking at " << lock_file; + return lock_file; + } +}; + +class SharedMemory : boost::noncopyable { + + //Remove shared memory on destruction + class shm_remove : boost::noncopyable { + private: + int m_shmid; + bool m_initialized; + public: + void SetID(int shmid) { + m_shmid = shmid; + m_initialized = true; + } + + shm_remove() : m_shmid(INT_MIN), m_initialized(false) {} + + ~shm_remove(){ + if(m_initialized) { + SimpleLogger().Write(logDEBUG) << + "automatic memory deallocation"; + boost::interprocess::xsi_shared_memory::remove(m_shmid); + } + } + + }; + +public: + void * Ptr() const { + return region.get_address(); + } + + template + SharedMemory( + const boost::filesystem::path & lock_file, + const IdentifierT id, + const unsigned size = 0 + ) : key( + lock_file.string().c_str(), + id + ) { + if( 0 == size ){ //read_only + shm = boost::interprocess::xsi_shared_memory ( + boost::interprocess::open_only, + key + ); + region = boost::interprocess::mapped_region ( + shm, + boost::interprocess::read_only + ); + } else { //writeable pointer + //remove previously allocated mem + RemoveSharedMemory(key); + shm = boost::interprocess::xsi_shared_memory ( + boost::interprocess::create_only, + key, + size + ); + region = boost::interprocess::mapped_region ( + shm, + boost::interprocess::read_write + ); + + remover.SetID( shm.get_shmid() ); + SimpleLogger().Write(logDEBUG) << + "writeable memory allocated " << size << " bytes"; + } + } + +private: + static void RemoveSharedMemory( + const boost::interprocess::xsi_key &key + ) { + try{ + SimpleLogger().Write(logDEBUG) << "deallocating prev memory"; + boost::interprocess::xsi_shared_memory xsi( + boost::interprocess::open_only, + key + ); + boost::interprocess::xsi_shared_memory::remove(xsi.get_shmid()); + } catch(boost::interprocess::interprocess_exception &e){ + if(e.get_error_code() != boost::interprocess::not_found_error) { + throw; + } + } + } + + boost::interprocess::xsi_key key; + boost::interprocess::xsi_shared_memory shm; + boost::interprocess::mapped_region region; + shm_remove remover; +}; + +template +class SharedMemoryFactory_tmpl : boost::noncopyable { +public: + template + static SharedMemory * Get( + const IdentifierT & id, + const unsigned size = 0 + ) { + try { + LockFileT lock_file; + if(0 == size && !boost::filesystem::exists(lock_file()) ) { + throw OSRMException("lock file does not exist, exiting"); + } + return new SharedMemory(lock_file(), id, size); + } catch(const boost::interprocess::interprocess_exception &e){ + SimpleLogger().Write(logWARNING) << + "caught exception: " << e.what() << + ", code " << e.get_error_code(); + throw OSRMException(e.what()); + } + }; + +private: + SharedMemoryFactory_tmpl() {} +}; + +typedef SharedMemoryFactory_tmpl<> SharedMemoryFactory; + +#endif /* SHARED_MEMORY_POINTER_FACTORY_H */ diff --git a/DataStructures/SharedMemoryVectorWrapper.h b/DataStructures/SharedMemoryVectorWrapper.h new file mode 100644 index 000000000..0773466d9 --- /dev/null +++ b/DataStructures/SharedMemoryVectorWrapper.h @@ -0,0 +1,96 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 SHARED_MEMORY_VECTOR_WRAPPER_H +#define SHARED_MEMORY_VECTOR_WRAPPER_H + +#include +#include +#include + +#include +#include + +template +class ShMemIterator : public std::iterator { + boost::shared_ptr p; +public: + ShMemIterator(boost::shared_ptr & x) :p(x) {} + ShMemIterator(const ShMemIterator & mit) : p(mit.p) {} + ShMemIterator& operator++() { + ++p; + return *this; + } + ShMemIterator operator++(int) { + ShMemIterator tmp(*this); + operator++(); + return tmp; + } + bool operator==(const ShMemIterator& rhs) { + return p==rhs.p; + } + bool operator!=(const ShMemIterator& rhs) { + return p!=rhs.p; + } + DataT& operator*() { + return *p; + } +}; + +template +class SharedMemoryWrapper { +private: + boost::shared_ptr m_ptr; + std::size_t m_size; + + SharedMemoryWrapper() {}; +public: + SharedMemoryWrapper(const DataT * ptr, std::size_t size) : + m_ptr(ptr), + m_size(size) + { } + + ShMemIterator begin() const { + return ShMemIterator(m_ptr); + } + + ShMemIterator end() const { + return ShMemIterator(m_ptr+m_size); + } + + std::size_t size() const { return m_size; } + + DataT & operator[](const int index) { + BOOST_ASSERT_MSG(index < m_size, "invalid size"); + return m_ptr[index]; + } +}; + +template +class ShMemVector : public + boost::conditional< + SharedMemory, + SharedMemoryWrapper, + std::vector + >::type +{ }; + + +#endif //SHARED_MEMORY_VECTOR_WRAPPER_H diff --git a/Server/DataStructures/SharedDataType.h b/Server/DataStructures/SharedDataType.h new file mode 100644 index 000000000..83cc6da81 --- /dev/null +++ b/Server/DataStructures/SharedDataType.h @@ -0,0 +1,26 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 SHARED_DATA_TYPE_H_ +#define SHARED_DATA_TYPE_H_ + +enum SharedDataType { NAMES_INDEX, NAMES_LIST }; + +#endif /* SHARED_DATA_TYPE_H_ */ From 1e5c4b0d79ba2b513e2a6a2e88c5215e2110d3e2 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Sep 2013 18:35:43 +0200 Subject: [PATCH 03/11] Facade base class to provide all data access --- Server/DataStructures/BaseDataFacade.h | 75 ++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Server/DataStructures/BaseDataFacade.h diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h new file mode 100644 index 000000000..b8e4f415f --- /dev/null +++ b/Server/DataStructures/BaseDataFacade.h @@ -0,0 +1,75 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 QUERY_DATA_FACADE_H +#define QUERY_DATA_FACADE_H + +//Exposes all data access interfaces to the algorithms via base class ptr + +#include "../../DataStructures/Coordinate.h" +#include "../../DataStructures/PhantomNodes.h" +#include "../../DataStructures/TurnInstructions.h" +#include "../../typedefs.h" + +#include + +class QueryDataFacade { +public: + QueryDataFacade() { } + virtual ~QueryDataFacade() { } + + //search graph access + //TODO + + //node and edge information access + virtual FixedPointCoordinate GetCoordinateOfNode( + const unsigned id + ) const = 0; + + virtual TurnInstruction GetTurnInstructionForEdgeID( + const unsigned id + ) const = 0; + + virtual NodeID GetNumberOfNodes( ) const = 0; + + virtual bool LocateClosestEndPointForCoordinate( + const FixedPointCoordinate& input_coordinate, + FixedPointCoordinate& result, + const unsigned zoom_level = 18 + ) const = 0; + + virtual bool FindPhantomNodeForCoordinate( + const FixedPointCoordinate & input_coordinate, + PhantomNode & resulting_phantom_node, + const unsigned zoom_level + ) const = 0; + + virtual unsigned GetCheckSum() const = 0; + + virtual unsigned GetNameIndexFromEdgeID(const unsigned id) const = 0; + virtual void GetName( + const unsigned name_id, + std::string & result + ) const = 0; + +}; + + +#endif // QUERY_DATA_FACADE_H From 66d58bf047c68f16e9c77afe7dd1dd39be9e2ab2 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Sep 2013 18:37:08 +0200 Subject: [PATCH 04/11] instantiate different inherited class at bcp that provides all data --- Library/OSRM.cpp | 163 ++++++++++++++++++++++++++--------------------- Library/OSRM.h | 3 +- 2 files changed, 92 insertions(+), 74 deletions(-) diff --git a/Library/OSRM.cpp b/Library/OSRM.cpp index 79f6b869f..1ddb5e62d 100644 --- a/Library/OSRM.cpp +++ b/Library/OSRM.cpp @@ -20,80 +20,97 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "OSRM.h" -OSRM::OSRM(const char * server_ini_path) { - if( !testDataFile(server_ini_path) ){ - std::string error_message = std::string(server_ini_path) + " not found"; - throw OSRMException(error_message.c_str()); +OSRM::OSRM(const char * server_ini_path, const bool use_shared_memory) + : use_shared_memory(use_shared_memory) +{ + if( !use_shared_memory ) { + if( !testDataFile(server_ini_path) ){ + std::string error_message = std::string(server_ini_path) + " not found"; + throw OSRMException(error_message.c_str()); + } + + IniFile serverConfig(server_ini_path); + + boost::filesystem::path base_path = + boost::filesystem::absolute(server_ini_path).parent_path(); + + if ( !serverConfig.Holds("hsgrData")) { + throw OSRMException("no ram index file name in server ini"); + } + if ( !serverConfig.Holds("ramIndex") ) { + throw OSRMException("no mem index file name in server ini"); + } + if ( !serverConfig.Holds("fileIndex") ) { + throw OSRMException("no nodes file name in server ini"); + } + if ( !serverConfig.Holds("nodesData") ) { + throw OSRMException("no nodes file name in server ini"); + } + if ( !serverConfig.Holds("edgesData") ) { + throw OSRMException("no edges file name in server ini"); + } + + boost::filesystem::path hsgr_path = boost::filesystem::absolute( + serverConfig.GetParameter("hsgrData"), + base_path + ); + + boost::filesystem::path ram_index_path = boost::filesystem::absolute( + serverConfig.GetParameter("ramIndex"), + base_path + ); + + boost::filesystem::path file_index_path = boost::filesystem::absolute( + serverConfig.GetParameter("fileIndex"), + base_path + ); + + boost::filesystem::path node_data_path = boost::filesystem::absolute( + serverConfig.GetParameter("nodesData"), + base_path + ); + boost::filesystem::path edge_data_path = boost::filesystem::absolute( + serverConfig.GetParameter("edgesData"), + base_path + ); + boost::filesystem::path name_data_path = boost::filesystem::absolute( + serverConfig.GetParameter("namesData"), + base_path + ); + boost::filesystem::path timestamp_path = boost::filesystem::absolute( + serverConfig.GetParameter("timestamp"), + base_path + ); + + objects = new QueryObjectsStorage( + hsgr_path.string(), + ram_index_path.string(), + file_index_path.string(), + node_data_path.string(), + edge_data_path.string(), + name_data_path.string(), + timestamp_path.string() + ); + + RegisterPlugin(new HelloWorldPlugin()); + RegisterPlugin(new LocatePlugin(objects)); + RegisterPlugin(new NearestPlugin(objects)); + RegisterPlugin(new TimestampPlugin(objects)); + RegisterPlugin(new ViaRoutePlugin(objects)); + + } else { + //TODO: fetch pointers from shared memory + + //TODO: objects = new QueryObjectsStorage() + + //TODO: generate shared memory plugins + RegisterPlugin(new HelloWorldPlugin()); + RegisterPlugin(new LocatePlugin(objects)); + RegisterPlugin(new NearestPlugin(objects)); + RegisterPlugin(new TimestampPlugin(objects)); + RegisterPlugin(new ViaRoutePlugin(objects)); + } - - IniFile serverConfig(server_ini_path); - - boost::filesystem::path base_path = - boost::filesystem::absolute(server_ini_path).parent_path(); - - if ( !serverConfig.Holds("hsgrData")) { - throw OSRMException("no ram index file name in server ini"); - } - if ( !serverConfig.Holds("ramIndex") ) { - throw OSRMException("no mem index file name in server ini"); - } - if ( !serverConfig.Holds("fileIndex") ) { - throw OSRMException("no nodes file name in server ini"); - } - if ( !serverConfig.Holds("nodesData") ) { - throw OSRMException("no nodes file name in server ini"); - } - if ( !serverConfig.Holds("edgesData") ) { - throw OSRMException("no edges file name in server ini"); - } - - boost::filesystem::path hsgr_path = boost::filesystem::absolute( - serverConfig.GetParameter("hsgrData"), - base_path - ); - - boost::filesystem::path ram_index_path = boost::filesystem::absolute( - serverConfig.GetParameter("ramIndex"), - base_path - ); - - boost::filesystem::path file_index_path = boost::filesystem::absolute( - serverConfig.GetParameter("fileIndex"), - base_path - ); - - boost::filesystem::path node_data_path = boost::filesystem::absolute( - serverConfig.GetParameter("nodesData"), - base_path - ); - boost::filesystem::path edge_data_path = boost::filesystem::absolute( - serverConfig.GetParameter("edgesData"), - base_path - ); - boost::filesystem::path name_data_path = boost::filesystem::absolute( - serverConfig.GetParameter("namesData"), - base_path - ); - boost::filesystem::path timestamp_path = boost::filesystem::absolute( - serverConfig.GetParameter("timestamp"), - base_path - ); - - objects = new QueryObjectsStorage( - hsgr_path.string(), - ram_index_path.string(), - file_index_path.string(), - node_data_path.string(), - edge_data_path.string(), - name_data_path.string(), - timestamp_path.string() - ); - - RegisterPlugin(new HelloWorldPlugin()); - RegisterPlugin(new LocatePlugin(objects)); - RegisterPlugin(new NearestPlugin(objects)); - RegisterPlugin(new TimestampPlugin(objects)); - RegisterPlugin(new ViaRoutePlugin(objects)); } OSRM::~OSRM() { diff --git a/Library/OSRM.h b/Library/OSRM.h index bb3caa7d9..17e27a1c8 100644 --- a/Library/OSRM.h +++ b/Library/OSRM.h @@ -47,12 +47,13 @@ class OSRM : boost::noncopyable { typedef boost::unordered_map PluginMap; QueryObjectsStorage * objects; public: - OSRM(const char * server_ini_path); + OSRM(const char * server_ini_path, const bool use_shared_memory = false); ~OSRM(); void RunQuery(RouteParameters & route_parameters, http::Reply & reply); private: void RegisterPlugin(BasePlugin * plugin); PluginMap pluginMap; + const bool use_shared_memory; }; #endif //OSRM_H From 1bd24f7042713628858741a04b4477ef3278c4c8 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Sep 2013 18:37:52 +0200 Subject: [PATCH 05/11] remove unneeded white spaces --- Server/DataStructures/QueryObjectsStorage.cpp | 2 +- Server/DataStructures/QueryObjectsStorage.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Server/DataStructures/QueryObjectsStorage.cpp b/Server/DataStructures/QueryObjectsStorage.cpp index e0ec72e40..fa17e5dbe 100644 --- a/Server/DataStructures/QueryObjectsStorage.cpp +++ b/Server/DataStructures/QueryObjectsStorage.cpp @@ -69,7 +69,7 @@ QueryObjectsStorage::QueryObjectsStorage( SimpleLogger().Write() << "Loading Timestamp"; std::ifstream timestampInStream(timestamp_path.c_str()); if(!timestampInStream) { - SimpleLogger().Write(logWARNING) << timestamp_path << " not found"; + SimpleLogger().Write(logWARNING) << timestamp_path << " not found"; } getline(timestampInStream, timestamp); diff --git a/Server/DataStructures/QueryObjectsStorage.h b/Server/DataStructures/QueryObjectsStorage.h index fd5419283..b9923dfce 100644 --- a/Server/DataStructures/QueryObjectsStorage.h +++ b/Server/DataStructures/QueryObjectsStorage.h @@ -36,7 +36,6 @@ or see http://www.gnu.org/licenses/agpl.txt. #include #include - struct QueryObjectsStorage { typedef StaticGraph QueryGraph; typedef QueryGraph::InputEdge InputEdge; From 8753dbdb0f2f57a796410f1bb9a9579e4e54c464 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Sep 2013 18:45:33 +0200 Subject: [PATCH 06/11] added graph data access --- Server/DataStructures/BaseDataFacade.h | 34 +++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h index b8e4f415f..1c3c3c660 100644 --- a/Server/DataStructures/BaseDataFacade.h +++ b/Server/DataStructures/BaseDataFacade.h @@ -30,13 +30,43 @@ or see http://www.gnu.org/licenses/agpl.txt. #include +template class QueryDataFacade { public: QueryDataFacade() { } virtual ~QueryDataFacade() { } //search graph access - //TODO + virtual unsigned GetNumberOfNodes() const = 0; + + virtual unsigned GetNumberOfEdges() const = 0; + + virtual unsigned GetOutDegree( const NodeID n ) const = 0; + + virtual NodeID GetTarget( const EdgeID e ) const = 0; + + virtual EdgeDataT &GetEdgeData( const EdgeID e ) = 0; + + virtual const EdgeDataT &GetEdgeData( const EdgeID e ) const = 0; + + virtual EdgeID BeginEdges( const NodeID n ) const = 0; + + virtual EdgeID EndEdges( const NodeID n ) const = 0; + + //searches for a specific edge + virtual EdgeID FindEdge( const NodeID from, const NodeID to ) const = 0; + + virtual EdgeID FindEdgeInEitherDirection( + const NodeID from, + const NodeID to + ) const = 0; + + virtual EdgeID FindEdgeIndicateIfReverse( + const NodeID from, + const NodeID to, + bool & result + ) const = 0; + //node and edge information access virtual FixedPointCoordinate GetCoordinateOfNode( @@ -47,8 +77,6 @@ public: const unsigned id ) const = 0; - virtual NodeID GetNumberOfNodes( ) const = 0; - virtual bool LocateClosestEndPointForCoordinate( const FixedPointCoordinate& input_coordinate, FixedPointCoordinate& result, From f844e9e70258abdadd4885c44af64ca1317e7c8c Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Tue, 17 Sep 2013 18:55:53 +0200 Subject: [PATCH 07/11] plugging in base facade ptr --- Library/OSRM.h | 4 ++++ Server/DataStructures/BaseDataFacade.h | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Library/OSRM.h b/Library/OSRM.h index 17e27a1c8..5e37f2c6d 100644 --- a/Library/OSRM.h +++ b/Library/OSRM.h @@ -29,6 +29,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Plugins/NearestPlugin.h" #include "../Plugins/TimestampPlugin.h" #include "../Plugins/ViaRoutePlugin.h" +#include "../Server/DataStructures/BaseDataFacade.h" #include "../Server/DataStructures/RouteParameters.h" #include "../Util/IniFile.h" #include "../Util/InputFileUtil.h" @@ -44,8 +45,11 @@ or see http://www.gnu.org/licenses/agpl.txt. #include class OSRM : boost::noncopyable { +private: typedef boost::unordered_map PluginMap; QueryObjectsStorage * objects; + BaseDataFacade * query_data_facade; + public: OSRM(const char * server_ini_path, const bool use_shared_memory = false); ~OSRM(); diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h index 1c3c3c660..2316d27f3 100644 --- a/Server/DataStructures/BaseDataFacade.h +++ b/Server/DataStructures/BaseDataFacade.h @@ -31,10 +31,10 @@ or see http://www.gnu.org/licenses/agpl.txt. #include template -class QueryDataFacade { +class BaseDataFacade { public: - QueryDataFacade() { } - virtual ~QueryDataFacade() { } + BaseDataFacade() { } + virtual ~BaseDataFacade() { } //search graph access virtual unsigned GetNumberOfNodes() const = 0; @@ -67,7 +67,6 @@ public: bool & result ) const = 0; - //node and edge information access virtual FixedPointCoordinate GetCoordinateOfNode( const unsigned id @@ -96,7 +95,6 @@ public: const unsigned name_id, std::string & result ) const = 0; - }; From 003c1df53e5a3dbbaa3827dfb5be3ee6529208e9 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 18 Sep 2013 17:49:49 +0200 Subject: [PATCH 08/11] Mockups for data facades --- DataStructures/NodeInformationHelpDesk.h | 2 + DataStructures/StaticGraph.h | 27 ++++-- Library/OSRM.cpp | 1 + Library/OSRM.h | 3 + Server/DataStructures/BaseDataFacade.h | 1 + Server/DataStructures/InternalDataFacade.h | 94 +++++++++++++++++++++ Server/DataStructures/SharedDataFacade.h | 95 ++++++++++++++++++++++ 7 files changed, 214 insertions(+), 9 deletions(-) create mode 100644 Server/DataStructures/InternalDataFacade.h create mode 100644 Server/DataStructures/SharedDataFacade.h diff --git a/DataStructures/NodeInformationHelpDesk.h b/DataStructures/NodeInformationHelpDesk.h index 120f11ff6..cda10cd40 100644 --- a/DataStructures/NodeInformationHelpDesk.h +++ b/DataStructures/NodeInformationHelpDesk.h @@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or see http://www.gnu.org/licenses/agpl.txt. */ +//TODO: Umbauen in Private Data Facade + #ifndef NODEINFORMATIONHELPDESK_H_ #define NODEINFORMATIONHELPDESK_H_ diff --git a/DataStructures/StaticGraph.h b/DataStructures/StaticGraph.h index 6a5d0a6a8..b193b3ef4 100644 --- a/DataStructures/StaticGraph.h +++ b/DataStructures/StaticGraph.h @@ -22,13 +22,14 @@ or see http://www.gnu.org/licenses/agpl.txt. #define STATICGRAPH_H_INCLUDED #include "../DataStructures/Percent.h" +#include "../DataStructures/SharedMemoryVectorWrapper.h" #include "../Util/SimpleLogger.h" #include "../typedefs.h" #include #include -template< typename EdgeDataT> +template< typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph { public: typedef NodeID NodeIterator; @@ -40,8 +41,9 @@ public: NodeIterator source; NodeIterator target; bool operator<( const InputEdge& right ) const { - if ( source != right.source ) + if ( source != right.source ) { return source < right.source; + } return target < right.target; } }; @@ -82,16 +84,22 @@ public: } } - StaticGraph( std::vector<_StrNode> & nodes, std::vector<_StrEdge> & edges) { + StaticGraph( + ShMemVector<_StrNode, UseSharedMemory> & nodes, + ShMemVector<_StrEdge, UseSharedMemory> & edges + ) { _numNodes = nodes.size(); _numEdges = edges.size(); _nodes.swap(nodes); _edges.swap(edges); - //Add dummy node to end of _nodes array; - _nodes.push_back(_nodes.back()); - + if( !UseSharedMemory ) { + //Add dummy node to end of _nodes array; + _nodes.push_back(_nodes.back()); + } else { + //TODO: Move to graph array construction + } #ifndef NDEBUG Percent p(GetNumberOfNodes()); for(unsigned u = 0; u < GetNumberOfNodes(); ++u) { @@ -176,8 +184,9 @@ public: EdgeIterator tmp = FindEdge( from, to ); if(UINT_MAX == tmp) { tmp = FindEdge( to, from ); - if(UINT_MAX != tmp) + if(UINT_MAX != tmp) { result = true; + } } return tmp; } @@ -187,8 +196,8 @@ private: NodeIterator _numNodes; EdgeIterator _numEdges; - std::vector< _StrNode > _nodes; - std::vector< _StrEdge > _edges; + ShMemVector< _StrNode, UseSharedMemory > _nodes; + ShMemVector< _StrEdge, UseSharedMemory > _edges; }; #endif // STATICGRAPH_H_INCLUDED diff --git a/Library/OSRM.cpp b/Library/OSRM.cpp index 1ddb5e62d..bc5179fd2 100644 --- a/Library/OSRM.cpp +++ b/Library/OSRM.cpp @@ -102,6 +102,7 @@ OSRM::OSRM(const char * server_ini_path, const bool use_shared_memory) //TODO: fetch pointers from shared memory //TODO: objects = new QueryObjectsStorage() + query_data_facade = new SharedDataFacade(); //TODO: generate shared memory plugins RegisterPlugin(new HelloWorldPlugin()); diff --git a/Library/OSRM.h b/Library/OSRM.h index 5e37f2c6d..74e331f1c 100644 --- a/Library/OSRM.h +++ b/Library/OSRM.h @@ -30,6 +30,8 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Plugins/TimestampPlugin.h" #include "../Plugins/ViaRoutePlugin.h" #include "../Server/DataStructures/BaseDataFacade.h" +#include "../Server/DataStructures/InternalDataFacade.h" +#include "../Server/DataStructures/SharedDataFacade.h" #include "../Server/DataStructures/RouteParameters.h" #include "../Util/IniFile.h" #include "../Util/InputFileUtil.h" @@ -40,6 +42,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include #include #include +#include #include #include diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h index 2316d27f3..1812789a6 100644 --- a/Server/DataStructures/BaseDataFacade.h +++ b/Server/DataStructures/BaseDataFacade.h @@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../../DataStructures/Coordinate.h" #include "../../DataStructures/PhantomNodes.h" #include "../../DataStructures/TurnInstructions.h" +#include "../../Util/OSRMException.h" #include "../../typedefs.h" #include diff --git a/Server/DataStructures/InternalDataFacade.h b/Server/DataStructures/InternalDataFacade.h new file mode 100644 index 000000000..80c4d6ffb --- /dev/null +++ b/Server/DataStructures/InternalDataFacade.h @@ -0,0 +1,94 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 INTERNAL_DATA_FACADE +#define INTERNAL_DATA_FACADE + +#include "BaseDataFacade.h" + +template +class InternalDataFacade : public BaseDataFacade { + +private: + +public: + //search graph access + unsigned GetNumberOfNodes() const { return 0; } + + unsigned GetNumberOfEdges() const { return 0; } + + unsigned GetOutDegree( const NodeID n ) const { return 0; } + + NodeID GetTarget( const EdgeID e ) const { return 0; } + + EdgeDataT &GetEdgeData( const EdgeID e ) { return EdgeDataT(); } + + const EdgeDataT &GetEdgeData( const EdgeID e ) const { return EdgeDataT(); } + + EdgeID BeginEdges( const NodeID n ) const { return 0; } + + EdgeID EndEdges( const NodeID n ) const { return 0; } + + //searches for a specific edge + EdgeID FindEdge( const NodeID from, const NodeID to ) const { return 0; } + + EdgeID FindEdgeInEitherDirection( + const NodeID from, + const NodeID to + ) const { return 0; } + + EdgeID FindEdgeIndicateIfReverse( + const NodeID from, + const NodeID to, + bool & result + ) const { return 0; } + + //node and edge information access + FixedPointCoordinate GetCoordinateOfNode( + const unsigned id + ) const { return FixedPointCoordinate(); }; + + TurnInstruction GetTurnInstructionForEdgeID( + const unsigned id + ) const { return 0; } + + bool LocateClosestEndPointForCoordinate( + const FixedPointCoordinate& input_coordinate, + FixedPointCoordinate& result, + const unsigned zoom_level = 18 + ) const { return false; } + + bool FindPhantomNodeForCoordinate( + const FixedPointCoordinate & input_coordinate, + PhantomNode & resulting_phantom_node, + const unsigned zoom_level + ) const { return false; } + + unsigned GetCheckSum() const { return 0; } + + unsigned GetNameIndexFromEdgeID(const unsigned id) const { return 0; }; + + void GetName( + const unsigned name_id, + std::string & result + ) const { return; }; +}; + +#endif // INTERNAL_DATA_FACADE diff --git a/Server/DataStructures/SharedDataFacade.h b/Server/DataStructures/SharedDataFacade.h new file mode 100644 index 000000000..4f3bc8880 --- /dev/null +++ b/Server/DataStructures/SharedDataFacade.h @@ -0,0 +1,95 @@ +/* + open source routing machine + Copyright (C) Dennis Luxen, others 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 INTERNAL_DATA_FACADE +#define INTERNAL_DATA_FACADE + +#include "BaseDataFacade.h" + +template +class SharedDataFacade : public BaseDataFacade { + +private: + +public: + + //search graph access + unsigned GetNumberOfNodes() const { return 0; } + + unsigned GetNumberOfEdges() const { return 0; } + + unsigned GetOutDegree( const NodeID n ) const { return 0; } + + NodeID GetTarget( const EdgeID e ) const { return 0; } + + EdgeDataT &GetEdgeData( const EdgeID e ) { return EdgeDataT(); } + + const EdgeDataT &GetEdgeData( const EdgeID e ) const { return EdgeDataT(); } + + EdgeID BeginEdges( const NodeID n ) const { return 0; } + + EdgeID EndEdges( const NodeID n ) const { return 0; } + + //searches for a specific edge + EdgeID FindEdge( const NodeID from, const NodeID to ) const { return 0; } + + EdgeID FindEdgeInEitherDirection( + const NodeID from, + const NodeID to + ) const { return 0; } + + EdgeID FindEdgeIndicateIfReverse( + const NodeID from, + const NodeID to, + bool & result + ) const { return 0; } + + //node and edge information access + FixedPointCoordinate GetCoordinateOfNode( + const unsigned id + ) const { return FixedPointCoordinate(); }; + + TurnInstruction GetTurnInstructionForEdgeID( + const unsigned id + ) const { return 0; } + + bool LocateClosestEndPointForCoordinate( + const FixedPointCoordinate& input_coordinate, + FixedPointCoordinate& result, + const unsigned zoom_level = 18 + ) const { return false; } + + bool FindPhantomNodeForCoordinate( + const FixedPointCoordinate & input_coordinate, + PhantomNode & resulting_phantom_node, + const unsigned zoom_level + ) const { return false; } + + unsigned GetCheckSum() const { return 0; } + + unsigned GetNameIndexFromEdgeID(const unsigned id) const { return 0; }; + + void GetName( + const unsigned name_id, + std::string & result + ) const { return; }; +}; + +#endif // INTERNAL_DATA_FACADE From d907be264b00362543a47cc389f11e6253de2218 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 18 Sep 2013 18:32:50 +0200 Subject: [PATCH 09/11] make plugins templates that plug into data facade --- Plugins/LocatePlugin.h | 5 ++++- Plugins/NearestPlugin.h | 9 ++++++--- Plugins/TimestampPlugin.h | 6 ++++-- Plugins/ViaRoutePlugin.h | 5 +++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Plugins/LocatePlugin.h b/Plugins/LocatePlugin.h index 22a5ac3c5..ac559451f 100644 --- a/Plugins/LocatePlugin.h +++ b/Plugins/LocatePlugin.h @@ -29,9 +29,12 @@ or see http://www.gnu.org/licenses/agpl.txt. /* * This Plugin locates the nearest node in the road network for a given coordinate. */ +//TODO: Rework data access to go through facade + +template class LocatePlugin : public BasePlugin { public: - LocatePlugin(QueryObjectsStorage * objects) : descriptor_string("locate") { + LocatePlugin(DataFacadeT * objects) : descriptor_string("locate") { nodeHelpDesk = objects->nodeHelpDesk; } const std::string & GetDescriptor() const { return descriptor_string; } diff --git a/Plugins/NearestPlugin.h b/Plugins/NearestPlugin.h index 1f011bd4b..d662b79c7 100644 --- a/Plugins/NearestPlugin.h +++ b/Plugins/NearestPlugin.h @@ -24,15 +24,18 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "BasePlugin.h" #include "../DataStructures/NodeInformationHelpDesk.h" -#include "../Server/DataStructures/QueryObjectsStorage.h" #include "../Util/StringUtil.h" /* * This Plugin locates the nearest point on a street in the road network for a given coordinate. */ + +//TODO: Rework data access to go through facade + +template class NearestPlugin : public BasePlugin { public: - NearestPlugin(QueryObjectsStorage * objects ) + NearestPlugin(DataFacadeT * objects ) : m_query_objects(objects), descriptor_string("nearest") @@ -114,7 +117,7 @@ public: } private: - QueryObjectsStorage * m_query_objects; + DataFacadeT * m_query_objects; HashTable descriptorTable; std::string descriptor_string; }; diff --git a/Plugins/TimestampPlugin.h b/Plugins/TimestampPlugin.h index ba0510c3e..38514e957 100644 --- a/Plugins/TimestampPlugin.h +++ b/Plugins/TimestampPlugin.h @@ -22,10 +22,12 @@ or see http://www.gnu.org/licenses/agpl.txt. #define TIMESTAMPPLUGIN_H_ #include "BasePlugin.h" +//TODO: Rework data access to go through facade +template class TimestampPlugin : public BasePlugin { public: - TimestampPlugin(QueryObjectsStorage * o) + TimestampPlugin(DataFacadeT * o) : objects(o), descriptor_string("timestamp") { } const std::string & GetDescriptor() const { return descriptor_string; } @@ -66,7 +68,7 @@ public: reply.headers[0].value = tmp; } private: - QueryObjectsStorage * objects; + DataFacadeT * objects; std::string descriptor_string; }; diff --git a/Plugins/ViaRoutePlugin.h b/Plugins/ViaRoutePlugin.h index 5233104b6..6b5f11d15 100644 --- a/Plugins/ViaRoutePlugin.h +++ b/Plugins/ViaRoutePlugin.h @@ -30,7 +30,6 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../Descriptors/BaseDescriptor.h" #include "../Descriptors/GPXDescriptor.h" #include "../Descriptors/JSONDescriptor.h" -#include "../Server/DataStructures/QueryObjectsStorage.h" #include "../Util/SimpleLogger.h" #include "../Util/StringUtil.h" @@ -41,6 +40,8 @@ or see http://www.gnu.org/licenses/agpl.txt. #include #include +//TODO: Rework data access to go through facade +template class ViaRoutePlugin : public BasePlugin { private: NodeInformationHelpDesk * nodeHelpDesk; @@ -49,7 +50,7 @@ private: SearchEngine * searchEnginePtr; public: - ViaRoutePlugin(QueryObjectsStorage * objects) + ViaRoutePlugin(DataFacadeT * objects) : // objects(objects), descriptor_string("viaroute") From e67541e82fc5589e6627f137fb906f45e1cf8cef Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 18 Sep 2013 18:33:10 +0200 Subject: [PATCH 10/11] Further includes in Facades --- Server/DataStructures/BaseDataFacade.h | 1 - Server/DataStructures/InternalDataFacade.h | 4 ++++ Server/DataStructures/SharedDataFacade.h | 4 ++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Server/DataStructures/BaseDataFacade.h b/Server/DataStructures/BaseDataFacade.h index 1812789a6..53302b5be 100644 --- a/Server/DataStructures/BaseDataFacade.h +++ b/Server/DataStructures/BaseDataFacade.h @@ -98,5 +98,4 @@ public: ) const = 0; }; - #endif // QUERY_DATA_FACADE_H diff --git a/Server/DataStructures/InternalDataFacade.h b/Server/DataStructures/InternalDataFacade.h index 80c4d6ffb..fd006bc5b 100644 --- a/Server/DataStructures/InternalDataFacade.h +++ b/Server/DataStructures/InternalDataFacade.h @@ -21,8 +21,12 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef INTERNAL_DATA_FACADE #define INTERNAL_DATA_FACADE +//implements all data storage when shared memory is _NOT_ used + #include "BaseDataFacade.h" +#include "../../DataStructures/StaticGraph.h" + template class InternalDataFacade : public BaseDataFacade { diff --git a/Server/DataStructures/SharedDataFacade.h b/Server/DataStructures/SharedDataFacade.h index 4f3bc8880..4a23919b6 100644 --- a/Server/DataStructures/SharedDataFacade.h +++ b/Server/DataStructures/SharedDataFacade.h @@ -21,8 +21,12 @@ or see http://www.gnu.org/licenses/agpl.txt. #ifndef INTERNAL_DATA_FACADE #define INTERNAL_DATA_FACADE +//implements all data storage when shared memory is _NOT_ used + #include "BaseDataFacade.h" +#include "../../DataStructures/StaticGraph.h" + template class SharedDataFacade : public BaseDataFacade { From cc94ab64116c828d9ed65cd4d766e7fd872d530b Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 19 Sep 2013 10:19:54 +0200 Subject: [PATCH 11/11] use empty() instead of comparisons --- Plugins/LocatePlugin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/LocatePlugin.h b/Plugins/LocatePlugin.h index ac559451f..6f233a352 100644 --- a/Plugins/LocatePlugin.h +++ b/Plugins/LocatePlugin.h @@ -55,7 +55,7 @@ public: //json // JSONParameter = routeParameters.options.Find("jsonp"); - if("" != routeParameters.jsonpParameter) { + if(!routeParameters.jsonpParameter.empty()) { reply.content += routeParameters.jsonpParameter; reply.content += "("; } @@ -81,7 +81,7 @@ public: reply.content += ",\"transactionId\": \"OSRM Routing Engine JSON Locate (v0.3)\""; reply.content += ("}"); reply.headers.resize(3); - if("" != routeParameters.jsonpParameter) { + if(!routeParameters.jsonpParameter.empty()) { reply.content += ")"; reply.headers[1].name = "Content-Type"; reply.headers[1].value = "text/javascript";