osrm-backend/DataStructures/Restriction.h

134 lines
3.5 KiB
C
Raw Normal View History

2012-08-27 11:40:59 -04:00
/*
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 RESTRICTION_H_
#define RESTRICTION_H_
2013-08-14 05:59:46 -04:00
#include "../typedefs.h"
2012-08-27 11:40:59 -04:00
#include <climits>
2013-08-14 05:59:46 -04:00
struct TurnRestriction {
2012-08-27 11:40:59 -04:00
NodeID viaNode;
NodeID fromNode;
NodeID toNode;
struct Bits { //mostly unused
2013-08-14 05:59:46 -04:00
Bits()
:
2013-07-08 08:51:55 -04:00
isOnly(false),
unused1(false),
unused2(false),
unused3(false),
unused4(false),
unused5(false),
unused6(false),
2013-08-14 05:59:46 -04:00
unused7(false)
{ }
2013-07-08 08:51:55 -04:00
2013-07-08 04:27:41 -04:00
bool isOnly:1;
bool unused1:1;
bool unused2:1;
bool unused3:1;
bool unused4:1;
bool unused5:1;
bool unused6:1;
bool unused7:1;
2012-08-27 11:40:59 -04:00
} flags;
2013-08-14 05:59:46 -04:00
TurnRestriction(NodeID viaNode) :
viaNode(viaNode),
2013-07-08 08:51:55 -04:00
fromNode(UINT_MAX),
toNode(UINT_MAX) {
}
2013-08-14 05:59:46 -04:00
TurnRestriction(const bool isOnly = false) :
2013-07-08 08:51:55 -04:00
viaNode(UINT_MAX),
fromNode(UINT_MAX),
toNode(UINT_MAX) {
2012-08-27 11:40:59 -04:00
flags.isOnly = isOnly;
}
};
struct _RawRestrictionContainer {
2013-08-14 05:59:46 -04:00
TurnRestriction restriction;
2012-08-27 11:40:59 -04:00
EdgeID fromWay;
EdgeID toWay;
unsigned viaNode;
2013-08-14 05:59:46 -04:00
_RawRestrictionContainer(
EdgeID fromWay,
EdgeID toWay,
NodeID vn,
unsigned vw
) :
fromWay(fromWay),
toWay(toWay),
viaNode(vw)
{
restriction.viaNode = vn;
}
_RawRestrictionContainer(
bool isOnly = false
) :
fromWay(UINT_MAX),
toWay(UINT_MAX),
viaNode(UINT_MAX)
{
restriction.flags.isOnly = isOnly;
}
2012-08-27 11:40:59 -04:00
static _RawRestrictionContainer min_value() {
return _RawRestrictionContainer(0, 0, 0, 0);
}
static _RawRestrictionContainer max_value() {
return _RawRestrictionContainer(UINT_MAX, UINT_MAX, UINT_MAX, UINT_MAX);
}
};
2013-07-08 08:51:55 -04:00
struct CmpRestrictionContainerByFrom : public std::binary_function<_RawRestrictionContainer, _RawRestrictionContainer, bool> {
2012-08-27 11:40:59 -04:00
typedef _RawRestrictionContainer value_type;
bool operator () (const _RawRestrictionContainer & a, const _RawRestrictionContainer & b) const {
return a.fromWay < b.fromWay;
}
value_type max_value() {
return _RawRestrictionContainer::max_value();
}
value_type min_value() {
return _RawRestrictionContainer::min_value();
}
};
struct CmpRestrictionContainerByTo: public std::binary_function<_RawRestrictionContainer, _RawRestrictionContainer, bool> {
typedef _RawRestrictionContainer value_type;
bool operator () (const _RawRestrictionContainer & a, const _RawRestrictionContainer & b) const {
return a.toWay < b.toWay;
}
value_type max_value() {
return _RawRestrictionContainer::max_value();
}
value_type min_value() {
return _RawRestrictionContainer::min_value();
}
};
#endif /* RESTRICTION_H_ */