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