1 /*************************************** 2 Type definitions for eXtended types. 3 4 Part of the Routino routing software. 5 ******************/ /****************** 6 This file Copyright 2008-2016, 2019 Andrew M. Bishop 7 8 This program is free software: you can redistribute it and/or modify 9 it under the terms of the GNU Affero General Public License as published by 10 the Free Software Foundation, either version 3 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU Affero General Public License for more details. 17 18 You should have received a copy of the GNU Affero General Public License 19 along with this program. If not, see <http://www.gnu.org/licenses/>. 20 ***************************************/ 21 22 23 #ifndef TYPESX_H 24 #define TYPESX_H /*+ To stop multiple inclusions. +*/ 25 26 27 #include <inttypes.h> 28 #include <stdint.h> 29 #include <string.h> 30 #include <stdlib.h> 31 32 33 /* Constants and macros for handling them */ 34 35 /*+ An undefined node ID. +*/ 36 #define NO_NODE_ID ((node_t)~0) 37 38 /*+ An undefined way ID. +*/ 39 #define NO_WAY_ID ((way_t)~0) 40 41 /*+ An undefined relation ID. +*/ 42 #define NO_RELATION_ID ((relation_t)~0) 43 44 /*+ The maximum number of segments per node (used to size temporary storage). +*/ 45 #define MAX_SEG_PER_NODE 64 46 47 48 /* Bit mask macro types and functions */ 49 50 #define BitMask uint32_t 51 52 #define LengthBitMask(xx) (1+(xx)/32) 53 54 #define AllocBitMask(xx) (BitMask*)calloc_logassert(LengthBitMask(xx),sizeof(BitMask)) 55 56 #define ClearAllBits(xx,yy) memset((xx), 0,(1+(yy)/32)*sizeof(BitMask)) 57 #define SetAllBits(xx,yy) memset((xx),~0,(1+(yy)/32)*sizeof(BitMask)) 58 59 #define ClearBit(xx,yy) (xx)[(yy)/32]&=~(((BitMask)1)<<((yy)%32)) 60 #define SetBit(xx,yy) (xx)[(yy)/32]|= (((BitMask)1)<<((yy)%32)) 61 62 #define IsBitSet(xx,yy) ((xx)[(yy)/32]& (((BitMask)1)<<((yy)%32))) 63 64 65 /* Simple Types */ 66 67 /*+ A node identifier - must be at least as large as index_t. +*/ 68 typedef uint64_t node_t; 69 70 /*+ A way identifier - must be at least as large as index_t. +*/ 71 typedef uint32_t way_t; 72 73 /*+ A relation identifier - must be at least as large as index_t. +*/ 74 typedef uint32_t relation_t; 75 76 77 /*+ A printf formatting string for a node_t type (this should match the node_t definition above). +*/ 78 #define Pnode_t PRIu64 /* PRIu32 and PRIu64 are defined in intypes.h */ 79 80 /*+ A printf formatting string for a way_t type (this should match the way_t definition above). +*/ 81 #define Pway_t PRIu32 /* PRIu32 and PRIu64 are defined in intypes.h */ 82 83 /*+ A printf formatting string for a relation_t type (this should match the relation_t definition above). +*/ 84 #define Prelation_t PRIu32 /* PRIu32 and PRIu64 are defined in intypes.h */ 85 86 87 /* Enumerated types */ 88 89 /*+ Turn restrictions. +*/ 90 typedef enum _TurnRestriction 91 { 92 TurnRestrict_None =0, 93 TurnRestrict_no_right_turn, 94 TurnRestrict_no_left_turn, 95 TurnRestrict_no_u_turn, 96 TurnRestrict_no_straight_on, 97 TurnRestrict_only_right_turn, 98 TurnRestrict_only_left_turn, 99 TurnRestrict_only_straight_on 100 } 101 TurnRestriction; 102 103 104 /* Data structures */ 105 106 typedef struct _NodeX NodeX; 107 108 typedef struct _NodesX NodesX; 109 110 typedef struct _SegmentX SegmentX; 111 112 typedef struct _SegmentsX SegmentsX; 113 114 typedef struct _WayX WayX; 115 116 typedef struct _WaysX WaysX; 117 118 typedef struct _RouteRelX RouteRelX; 119 120 typedef struct _TurnRelX TurnRelX; 121 122 typedef struct _RelationsX RelationsX; 123 124 125 #endif /* TYPESX_H */ 126