From b51d3da7e59ad3ae4c1d05a6a617e8c9e082d375 Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 18 Sep 2013 17:49:49 +0200 Subject: [PATCH] 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, 213 insertions(+), 10 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 08b1a272d..0c8537a80 100644 --- a/DataStructures/NodeInformationHelpDesk.h +++ b/DataStructures/NodeInformationHelpDesk.h @@ -26,6 +26,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +//TODO: Umbauen in Private Data Facade + #ifndef NODEINFORMATIONHELPDESK_H_ #define NODEINFORMATIONHELPDESK_H_ diff --git a/DataStructures/StaticGraph.h b/DataStructures/StaticGraph.h index 9b83ab944..b536c7866 100644 --- a/DataStructures/StaticGraph.h +++ b/DataStructures/StaticGraph.h @@ -29,13 +29,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #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; @@ -47,8 +48,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; } }; @@ -89,16 +91,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) { @@ -183,8 +191,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; } @@ -194,8 +203,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 063c81d6b..0061dade4 100644 --- a/Library/OSRM.cpp +++ b/Library/OSRM.cpp @@ -28,7 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "OSRM.h" #include - OSRM::OSRM(boost::unordered_map& paths) { objects = new QueryObjectsStorage( paths ); RegisterPlugin(new HelloWorldPlugin()); diff --git a/Library/OSRM.h b/Library/OSRM.h index 0015f6203..4bc3fdfca 100644 --- a/Library/OSRM.h +++ b/Library/OSRM.h @@ -37,6 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #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/InputFileUtil.h" #include "../Util/OSRMException.h" @@ -47,6 +49,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #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