bit packing ImportEdge members

This commit is contained in:
Dennis Luxen 2013-08-16 13:34:28 +02:00
parent cf29621aa7
commit d851dd7196

View File

@ -18,16 +18,17 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt. or see http://www.gnu.org/licenses/agpl.txt.
*/ */
#ifndef EDGE_H #ifndef IMPORT_EDGE_H
#define EDGE_H #define IMPORT_EDGE_H
#include "../Util/OSRMException.h" #include "../Util/OSRMException.h"
#include <cassert> #include "../typedefs.h"
#include <boost/assert.hpp>
class NodeBasedEdge { class NodeBasedEdge {
public:
public:
bool operator< (const NodeBasedEdge& e) const { bool operator< (const NodeBasedEdge& e) const {
if (source() == e.source()) { if (source() == e.source()) {
if (target() == e.target()) { if (target() == e.target()) {
@ -58,9 +59,9 @@ public:
_target(t), _target(t),
_name(n), _name(n),
_weight(w), _weight(w),
_type(ty),
forward(f), forward(f),
backward(b), backward(b),
_type(ty),
_roundabout(ra), _roundabout(ra),
_ignoreInGrid(ig), _ignoreInGrid(ig),
_accessRestricted(ar), _accessRestricted(ar),
@ -75,8 +76,9 @@ public:
NodeID source() const {return _source; } NodeID source() const {return _source; }
NodeID name() const { return _name; } NodeID name() const { return _name; }
EdgeWeight weight() const {return _weight; } EdgeWeight weight() const {return _weight; }
short type() const {
short type() const { assert(_type >= 0); return _type; } BOOST_ASSERT_MSG(_type >= 0, "type of ImportEdge invalid");
return _type; }
bool isBackward() const { return backward; } bool isBackward() const { return backward; }
bool isForward() const { return forward; } bool isForward() const { return forward; }
bool isLocatable() const { return _type != 14; } bool isLocatable() const { return _type != 14; }
@ -85,28 +87,26 @@ public:
bool isAccessRestricted() const { return _accessRestricted; } bool isAccessRestricted() const { return _accessRestricted; }
bool isContraFlow() const { return _contraFlow; } bool isContraFlow() const { return _contraFlow; }
//TODO: names need to be fixed.
NodeID _source; NodeID _source;
NodeID _target; NodeID _target;
NodeID _name; NodeID _name;
EdgeWeight _weight; EdgeWeight _weight;
bool forward;
bool backward;
short _type; short _type;
bool _roundabout; bool forward:1;
bool _ignoreInGrid; bool backward:1;
bool _accessRestricted; bool _roundabout:1;
bool _contraFlow; bool _ignoreInGrid:1;
bool _accessRestricted:1;
bool _contraFlow:1;
private: private:
/** Default constructor. target and weight are set to 0.*/ NodeBasedEdge() { }
NodeBasedEdge() :
_source(0), _target(0), _name(0), _weight(0), forward(0), backward(0), _type(0), _roundabout(false), _ignoreInGrid(false), _accessRestricted(false), _contraFlow(false) { assert(false); } //shall not be used.
}; };
class EdgeBasedEdge { class EdgeBasedEdge {
public:
public:
bool operator< (const EdgeBasedEdge& e) const { bool operator< (const EdgeBasedEdge& e) const {
if (source() == e.source()) { if (source() == e.source()) {
if (target() == e.target()) { if (target() == e.target()) {
@ -141,7 +141,14 @@ public:
m_backward(false) m_backward(false)
{ } { }
explicit EdgeBasedEdge(const NodeID s, const NodeID t, const NodeID v, const EdgeWeight w, const bool f, const bool b) : explicit EdgeBasedEdge(
const NodeID s,
const NodeID t,
const NodeID v,
const EdgeWeight w,
const bool f,
const bool b
) :
m_source(s), m_source(s),
m_target(t), m_target(t),
m_edgeID(v), m_edgeID(v),
@ -156,6 +163,7 @@ public:
NodeID id() const { return m_edgeID; } NodeID id() const { return m_edgeID; }
bool isBackward() const { return m_backward; } bool isBackward() const { return m_backward; }
bool isForward() const { return m_forward; } bool isForward() const { return m_forward; }
private: private:
NodeID m_source; NodeID m_source;
NodeID m_target; NodeID m_target;
@ -167,4 +175,4 @@ private:
typedef NodeBasedEdge ImportEdge; typedef NodeBasedEdge ImportEdge;
#endif // EDGE_H #endif /* IMPORT_EDGE_H */