Mockups for data facades

This commit is contained in:
Dennis Luxen 2013-09-18 17:49:49 +02:00
parent 861dbd5977
commit b51d3da7e5
7 changed files with 213 additions and 10 deletions

View File

@ -26,6 +26,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
//TODO: Umbauen in Private Data Facade
#ifndef NODEINFORMATIONHELPDESK_H_ #ifndef NODEINFORMATIONHELPDESK_H_
#define NODEINFORMATIONHELPDESK_H_ #define NODEINFORMATIONHELPDESK_H_

View File

@ -29,13 +29,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define STATICGRAPH_H_INCLUDED #define STATICGRAPH_H_INCLUDED
#include "../DataStructures/Percent.h" #include "../DataStructures/Percent.h"
#include "../DataStructures/SharedMemoryVectorWrapper.h"
#include "../Util/SimpleLogger.h" #include "../Util/SimpleLogger.h"
#include "../typedefs.h" #include "../typedefs.h"
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
template< typename EdgeDataT> template< typename EdgeDataT, bool UseSharedMemory = false>
class StaticGraph { class StaticGraph {
public: public:
typedef NodeID NodeIterator; typedef NodeID NodeIterator;
@ -47,8 +48,9 @@ public:
NodeIterator source; NodeIterator source;
NodeIterator target; NodeIterator target;
bool operator<( const InputEdge& right ) const { bool operator<( const InputEdge& right ) const {
if ( source != right.source ) if ( source != right.source ) {
return source < right.source; return source < right.source;
}
return target < right.target; 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(); _numNodes = nodes.size();
_numEdges = edges.size(); _numEdges = edges.size();
_nodes.swap(nodes); _nodes.swap(nodes);
_edges.swap(edges); _edges.swap(edges);
//Add dummy node to end of _nodes array; if( !UseSharedMemory ) {
_nodes.push_back(_nodes.back()); //Add dummy node to end of _nodes array;
_nodes.push_back(_nodes.back());
} else {
//TODO: Move to graph array construction
}
#ifndef NDEBUG #ifndef NDEBUG
Percent p(GetNumberOfNodes()); Percent p(GetNumberOfNodes());
for(unsigned u = 0; u < GetNumberOfNodes(); ++u) { for(unsigned u = 0; u < GetNumberOfNodes(); ++u) {
@ -183,8 +191,9 @@ public:
EdgeIterator tmp = FindEdge( from, to ); EdgeIterator tmp = FindEdge( from, to );
if(UINT_MAX == tmp) { if(UINT_MAX == tmp) {
tmp = FindEdge( to, from ); tmp = FindEdge( to, from );
if(UINT_MAX != tmp) if(UINT_MAX != tmp) {
result = true; result = true;
}
} }
return tmp; return tmp;
} }
@ -194,8 +203,8 @@ private:
NodeIterator _numNodes; NodeIterator _numNodes;
EdgeIterator _numEdges; EdgeIterator _numEdges;
std::vector< _StrNode > _nodes; ShMemVector< _StrNode, UseSharedMemory > _nodes;
std::vector< _StrEdge > _edges; ShMemVector< _StrEdge, UseSharedMemory > _edges;
}; };
#endif // STATICGRAPH_H_INCLUDED #endif // STATICGRAPH_H_INCLUDED

View File

@ -28,7 +28,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "OSRM.h" #include "OSRM.h"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
OSRM::OSRM(boost::unordered_map<const std::string,boost::filesystem::path>& paths) { OSRM::OSRM(boost::unordered_map<const std::string,boost::filesystem::path>& paths) {
objects = new QueryObjectsStorage( paths ); objects = new QueryObjectsStorage( paths );
RegisterPlugin(new HelloWorldPlugin()); RegisterPlugin(new HelloWorldPlugin());

View File

@ -37,6 +37,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../Plugins/TimestampPlugin.h" #include "../Plugins/TimestampPlugin.h"
#include "../Plugins/ViaRoutePlugin.h" #include "../Plugins/ViaRoutePlugin.h"
#include "../Server/DataStructures/BaseDataFacade.h" #include "../Server/DataStructures/BaseDataFacade.h"
#include "../Server/DataStructures/InternalDataFacade.h"
#include "../Server/DataStructures/SharedDataFacade.h"
#include "../Server/DataStructures/RouteParameters.h" #include "../Server/DataStructures/RouteParameters.h"
#include "../Util/InputFileUtil.h" #include "../Util/InputFileUtil.h"
#include "../Util/OSRMException.h" #include "../Util/OSRMException.h"
@ -47,6 +49,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/assert.hpp> #include <boost/assert.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/noncopyable.hpp> #include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <vector> #include <vector>

View File

@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "../../DataStructures/Coordinate.h" #include "../../DataStructures/Coordinate.h"
#include "../../DataStructures/PhantomNodes.h" #include "../../DataStructures/PhantomNodes.h"
#include "../../DataStructures/TurnInstructions.h" #include "../../DataStructures/TurnInstructions.h"
#include "../../Util/OSRMException.h"
#include "../../typedefs.h" #include "../../typedefs.h"
#include <string> #include <string>

View File

@ -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 EdgeDataT>
class InternalDataFacade : public BaseDataFacade<EdgeDataT> {
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

View File

@ -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 EdgeDataT>
class SharedDataFacade : public BaseDataFacade<EdgeDataT> {
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