moved ImportNode/Edge into compile units

This commit is contained in:
Dennis Luxen 2014-05-29 18:31:02 +02:00
parent df3a7676eb
commit 3625308585
3 changed files with 36 additions and 110 deletions

View File

@ -35,6 +35,8 @@ configure_file(
${CMAKE_SOURCE_DIR}/Util/GitDescription.cpp ${CMAKE_SOURCE_DIR}/Util/GitDescription.cpp
) )
file(GLOB ExtractorGlob Extractor/*.cpp) file(GLOB ExtractorGlob Extractor/*.cpp)
file(GLOB ImporterGlob DataStructures/Import*.cpp)
add_library(IMPORT STATIC ${ImporterGlob})
set(ExtractorSources extractor.cpp ${ExtractorGlob}) set(ExtractorSources extractor.cpp ${ExtractorGlob})
add_executable(osrm-extract ${ExtractorSources}) add_executable(osrm-extract ${ExtractorSources})
@ -157,8 +159,8 @@ endif()
include_directories(${Boost_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(OSRM ${Boost_LIBRARIES} COORDLIB) target_link_libraries(OSRM ${Boost_LIBRARIES} COORDLIB)
target_link_libraries(osrm-extract ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB) target_link_libraries(osrm-extract ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB IMPORT)
target_link_libraries(osrm-prepare ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB) target_link_libraries(osrm-prepare ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB IMPORT)
target_link_libraries(osrm-routed ${Boost_LIBRARIES} OSRM UUID GITDESCRIPTION) target_link_libraries(osrm-routed ${Boost_LIBRARIES} OSRM UUID GITDESCRIPTION)
target_link_libraries(osrm-datastore ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB) target_link_libraries(osrm-datastore ${Boost_LIBRARIES} UUID GITDESCRIPTION COORDLIB)
@ -231,7 +233,7 @@ if(WITH_TOOLS)
find_package(GDAL) find_package(GDAL)
if(GDAL_FOUND) if(GDAL_FOUND)
add_executable(osrm-components Tools/components.cpp) add_executable(osrm-components Tools/components.cpp)
target_link_libraries(osrm-components ${TBB_LIBRARIES}) target_link_libraries(osrm-components ${TBB_LIBRARIES} IMPORT)
include_directories(${GDAL_INCLUDE_DIR}) include_directories(${GDAL_INCLUDE_DIR})
target_link_libraries( target_link_libraries(
osrm-components osrm-components

View File

@ -37,22 +37,7 @@ class NodeBasedEdge
{ {
public: public:
bool operator<(const NodeBasedEdge &e) const bool operator<(const NodeBasedEdge &e) const;
{
if (source() == e.source())
{
if (target() == e.target())
{
if (weight() == e.weight())
{
return (isForward() && isBackward() && ((!e.isForward()) || (!e.isBackward())));
}
return (weight() < e.weight());
}
return (target() < e.target());
}
return (source() < e.source());
}
explicit NodeBasedEdge(NodeID s, explicit NodeBasedEdge(NodeID s,
NodeID t, NodeID t,
@ -65,34 +50,21 @@ class NodeBasedEdge
bool ig, bool ig,
bool ar, bool ar,
bool cf, bool cf,
bool is_split) bool is_split);
: _source(s), _target(t), _name(n), _weight(w), _type(ty), forward(f), backward(b),
_roundabout(ra), _ignoreInGrid(ig), _accessRestricted(ar), _contraFlow(cf),
is_split(is_split)
{
if (ty < 0)
{
throw OSRMException("negative edge type");
}
}
NodeID target() const { return _target; } NodeID target() const;
NodeID source() const { return _source; } NodeID source() const;
NodeID name() const { return _name; } NodeID name() const;
EdgeWeight weight() const { return _weight; } EdgeWeight weight() const;
short type() const short type() const;
{ bool isBackward() const;
BOOST_ASSERT_MSG(_type >= 0, "type of ImportEdge invalid"); bool isForward() const;
return _type; bool isLocatable() const;
} bool isRoundabout() const;
bool isBackward() const { return backward; } bool ignoreInGrid() const;
bool isForward() const { return forward; } bool isAccessRestricted() const;
bool isLocatable() const { return _type != 14; } bool isContraFlow() const;
bool isRoundabout() const { return _roundabout; } bool IsSplit() const;
bool ignoreInGrid() const { return _ignoreInGrid; }
bool isAccessRestricted() const { return _accessRestricted; }
bool isContraFlow() const { return _contraFlow; }
bool IsSplit() const { return is_split; }
// TODO: names need to be fixed. // TODO: names need to be fixed.
NodeID _source; NodeID _source;
@ -108,61 +80,34 @@ class NodeBasedEdge
bool _contraFlow : 1; bool _contraFlow : 1;
bool is_split : 1; bool is_split : 1;
private: NodeBasedEdge() = delete;
NodeBasedEdge() {}
}; };
class EdgeBasedEdge class EdgeBasedEdge
{ {
public: public:
bool operator<(const EdgeBasedEdge &e) const bool operator<(const EdgeBasedEdge &e) const;
{
if (source() == e.source())
{
if (target() == e.target())
{
if (weight() == e.weight())
{
return (isForward() && isBackward() && ((!e.isForward()) || (!e.isBackward())));
}
return (weight() < e.weight());
}
return (target() < e.target());
}
return (source() < e.source());
}
template <class EdgeT> template <class EdgeT>
explicit EdgeBasedEdge(const EdgeT &myEdge) explicit EdgeBasedEdge(const EdgeT &myEdge);
: m_source(myEdge.source), m_target(myEdge.target), m_edgeID(myEdge.data.via),
m_weight(myEdge.data.distance), m_forward(myEdge.data.forward),
m_backward(myEdge.data.backward)
{
}
/** Default constructor. target and weight are set to 0.*/ /** Default constructor. target and weight are set to 0.*/
EdgeBasedEdge() EdgeBasedEdge();
: m_source(0), m_target(0), m_edgeID(0), m_weight(0), m_forward(false), m_backward(false)
{
}
explicit EdgeBasedEdge(const NodeID s, explicit EdgeBasedEdge(const NodeID s,
const NodeID t, const NodeID t,
const NodeID v, const NodeID v,
const EdgeWeight w, const EdgeWeight w,
const bool f, const bool f,
const bool b) const bool b);
: m_source(s), m_target(t), m_edgeID(v), m_weight(w), m_forward(f), m_backward(b)
{
}
NodeID target() const { return m_target; } NodeID target() const;
NodeID source() const { return m_source; } NodeID source() const;
EdgeWeight weight() const { return m_weight; } EdgeWeight weight() const;
NodeID id() const { return m_edgeID; } NodeID id() const;
bool isBackward() const { return m_backward; } bool isBackward() const;
bool isForward() const { return m_forward; } bool isForward() const;
private: private:
NodeID m_source; NodeID m_source;

View File

@ -31,30 +31,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "QueryNode.h" #include "QueryNode.h"
#include "../DataStructures/HashTable.h" #include "../DataStructures/HashTable.h"
#include <limits>
#include <string> #include <string>
struct ExternalMemoryNode : NodeInfo struct ExternalMemoryNode : NodeInfo
{ {
ExternalMemoryNode(int lat, int lon, unsigned int id, bool bollard, bool traffic_light) ExternalMemoryNode(int lat, int lon, unsigned int id, bool bollard, bool traffic_light);
: NodeInfo(lat, lon, id), bollard(bollard), trafficLight(traffic_light)
{
}
ExternalMemoryNode() : bollard(false), trafficLight(false) {} ExternalMemoryNode();
static ExternalMemoryNode min_value() { return ExternalMemoryNode(0, 0, 0, false, false); } static ExternalMemoryNode min_value();
static ExternalMemoryNode max_value() static ExternalMemoryNode max_value();
{
return ExternalMemoryNode(std::numeric_limits<int>::max(),
std::numeric_limits<int>::max(),
std::numeric_limits<unsigned>::max(),
false,
false);
}
NodeID key() const { return id; }
bool bollard; bool bollard;
bool trafficLight; bool trafficLight;
@ -64,15 +51,7 @@ struct ImportNode : public ExternalMemoryNode
{ {
HashTable<std::string, std::string> keyVals; HashTable<std::string, std::string> keyVals;
inline void Clear() inline void Clear();
{
keyVals.clear();
lat = 0;
lon = 0;
id = 0;
bollard = false;
trafficLight = false;
}
}; };
#endif /* IMPORTNODE_H_ */ #endif /* IMPORTNODE_H_ */