GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-381f661b3f
v2-defs.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002 Roberto Micarelli
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * best view tabstop=4
21  */
22 
23 #define _DGL_V2 1
24 #undef _DGL_V1
25 
26 /*
27  * Define function names
28  */
29 
30 #if defined(DGL_DEFINE_TREE_PROCS) || defined(DGL_DEFINE_FLAT_PROCS)
31 /* sp-template */
32 #undef DGL_SP_DIJKSTRA_FUNC
33 #undef DGL_SPAN_DEPTHFIRST_SPANNING_FUNC
34 #undef DGL_SPAN_MINIMUM_SPANNING_FUNC
35 #undef _DGL_OUTEDGESET
36 #undef _DGL_INEDGESET
37 #undef _DGL_EDGE_TAILNODE
38 #undef _DGL_EDGE_HEADNODE
39 #endif
40 
41 /*
42  * TREE version algorithms
43  */
44 #if defined(DGL_DEFINE_TREE_PROCS)
45 /* sp-template */
46 #define DGL_SP_DIJKSTRA_FUNC dgl_dijkstra_V2_TREE
47 /* span-template */
48 #define DGL_SPAN_DEPTHFIRST_SPANNING_FUNC dgl_span_depthfirst_spanning_V2_TREE
49 #define DGL_SPAN_MINIMUM_SPANNING_FUNC dgl_span_minimum_spanning_V2_TREE
50 /* portable actions */
51 #define _DGL_OUTEDGESET(pg, pn) DGL_GET_NODE_OUTEDGESET_FUNC(pg, pn)
52 #define _DGL_INEDGESET(pg, pn) DGL_GET_NODE_INEDGESET_FUNC(pg, pn)
53 #define _DGL_EDGE_HEADNODE(pg, pl) \
54  DGL_GET_NODE_FUNC(pg, DGL_EDGE_HEADNODE_OFFSET(pl))
55 #define _DGL_EDGE_TAILNODE(pg, pl) \
56  DGL_GET_NODE_FUNC(pg, DGL_EDGE_TAILNODE_OFFSET(pl))
57 #endif
58 
59 /*
60  * FLAT version algorithms
61  */
62 #if defined(DGL_DEFINE_FLAT_PROCS)
63 /* sp-template */
64 #define DGL_SP_DIJKSTRA_FUNC dgl_dijkstra_V2_FLAT
65 /* span-template */
66 #define DGL_SPAN_DEPTHFIRST_SPANNING_FUNC dgl_span_depthfirst_spanning_V2_FLAT
67 #define DGL_SPAN_MINIMUM_SPANNING_FUNC dgl_span_minimum_spanning_V2_FLAT
68 /* portable actions */
69 #define _DGL_OUTEDGESET(pg, pn) \
70  DGL_EDGEBUFFER_SHIFT(pg, DGL_NODE_EDGESET_OFFSET(pn))
71 #define _DGL_INEDGESET(pg, pn) \
72  ((dglInt32_t *)(DGL_EDGEBUFFER_SHIFT(pg, DGL_NODE_EDGESET_OFFSET(pn))) + \
73  *(dglInt32_t *)(DGL_EDGEBUFFER_SHIFT(pg, DGL_NODE_EDGESET_OFFSET(pn))) + \
74  1)
75 #define _DGL_EDGE_HEADNODE(pg, pl) \
76  DGL_NODEBUFFER_SHIFT(pg, DGL_EDGE_HEADNODE_OFFSET(pl))
77 #define _DGL_EDGE_TAILNODE(pg, pl) \
78  DGL_NODEBUFFER_SHIFT(pg, DGL_EDGE_TAILNODE_OFFSET(pl))
79 #endif
80 
81 #if !defined(DGL_DEFINE_TREE_PROCS) && !defined(DGL_DEFINE_FLAT_PROCS)
82 
83 /* sp-template */
84 #define DGL_SP_CACHE_INITIALIZE_FUNC dgl_sp_cache_initialize_V2
85 #define DGL_SP_CACHE_RELEASE_FUNC dgl_sp_cache_release_V2
86 #define DGL_SP_CACHE_REPORT_FUNC dgl_sp_cache_report_V2
87 #define DGL_SP_CACHE_DISTANCE_FUNC dgl_sp_cache_distance_V2
88 
89 /* nodemgmt-template */
90 #define DGL_ADD_NODE_FUNC dgl_add_node_V2
91 #define DGL_DEL_NODE_OUTEDGE_FUNC dgl_del_node_outedge_V2
92 #define DGL_DEL_NODE_INEDGE_FUNC dgl_del_node_inedge_V2
93 #define DGL_DEL_NODE_FUNC dgl_del_node_V2
94 #define DGL_GET_NODE_FUNC dgl_get_node_V2
95 #define DGL_GET_NODE_OUTEDGESET_FUNC dgl_getnode_outedgeset_V2
96 #define DGL_GET_NODE_INEDGESET_FUNC dgl_getnode_inedgeset_V2
97 
98 /* edgemgmt-template */
99 #define DGL_ADD_EDGE_FUNC dgl_add_edge_V2
100 #define DGL_GET_EDGE_FUNC dgl_get_edge_V2
101 #define DGL_DEL_EDGE_FUNC dgl_del_edge_V2
102 
103 /* misc-template */
104 #define DGL_EDGE_T_INITIALIZE_FUNC dgl_edge_t_initialize_V2
105 #define DGL_EDGE_T_RELEASE_FUNC dgl_edge_t_release_V2
106 #define DGL_EDGE_T_FIRST_FUNC dgl_edge_t_first_V2
107 #define DGL_EDGE_T_NEXT_FUNC dgl_edge_t_next_V2
108 #define DGL_NODE_T_INITIALIZE_FUNC dgl_node_t_initialize_V2
109 #define DGL_NODE_T_RELEASE_FUNC dgl_node_t_release_V2
110 #define DGL_NODE_T_FIRST_FUNC dgl_node_t_first_V2
111 #define DGL_NODE_T_NEXT_FUNC dgl_node_t_next_V2
112 #define DGL_NODE_T_FIND_FUNC dgl_node_t_find_V2
113 #define DGL_EDGESET_T_INITIALIZE_FUNC dgl_edgeset_t_initialize_V2
114 #define DGL_EDGESET_T_RELEASE_FUNC dgl_edgeset_t_release_V2
115 #define DGL_EDGESET_T_FIRST_FUNC dgl_edgeset_t_first_V2
116 #define DGL_EDGESET_T_NEXT_FUNC dgl_edgeset_t_next_V2
117 #define DGL_FLATTEN_FUNC dgl_flatten_V2
118 #define DGL_UNFLATTEN_FUNC dgl_unflatten_V2
119 
120 /*
121  *
122  */
123 
124 /* Node
125  */
126 #define DGL_NODE_ALLOC DGL_NODE_ALLOC_v2
127 #define DGL_NODE_SIZEOF DGL_NODE_SIZEOF_v2
128 #define DGL_NODE_WSIZE DGL_NODE_WSIZE_v2
129 #define DGL_NODE_STATUS DGL_NODE_STATUS_v2
130 #define DGL_NODE_ID DGL_NODE_ID_v2
131 #define DGL_NODE_ATTR_PTR DGL_NODE_ATTR_PTR_v2
132 #define DGL_NODE_EDGESET_OFFSET DGL_NODE_EDGESET_OFFSET_v2
133 
134 /* Edge
135  */
136 #define DGL_EDGE_ALLOC DGL_EDGE_ALLOC_v2
137 #define DGL_EDGE_SIZEOF DGL_EDGE_SIZEOF_v2
138 #define DGL_EDGE_WSIZE DGL_EDGE_WSIZE_v2
139 #define DGL_EDGE_STATUS DGL_EDGE_STATUS_v2
140 #define DGL_EDGE_COST DGL_EDGE_COST_v2
141 #define DGL_EDGE_ID DGL_EDGE_ID_v2
142 #define DGL_EDGE_ATTR_PTR DGL_EDGE_ATTR_PTR_v2
143 #define DGL_EDGE_HEADNODE_OFFSET DGL_EDGE_HEADNODE_OFFSET_v2
144 #define DGL_EDGE_TAILNODE_OFFSET DGL_EDGE_TAILNODE_OFFSET_v2
145 
146 /* Edgeset
147  */
148 #define DGL_ILA_TOARR DGL_ILA_TOARR_v2
149 #define DGL_EDGESET_OFFSET DGL_EDGESET_OFFSET_v2
150 #define DGL_EDGESET_EDGEARRAY_PTR DGL_EDGESET_EDGEARRAY_PTR_v2
151 #define DGL_EDGESET_EDGECOUNT DGL_EDGESET_EDGECOUNT_v2
152 #define DGL_EDGESET_EDGE_PTR DGL_EDGESET_EDGE_PTR_v2
153 #define DGL_EDGESET_ALLOC DGL_EDGESET_ALLOC_v2
154 #define DGL_EDGESET_REALLOC DGL_EDGESET_REALLOC_v2
155 #define DGL_EDGESET_SIZEOF DGL_EDGESET_SIZEOF_v2
156 #define DGL_EDGESET_WSIZE DGL_EDGESET_WSIZE_v2
157 
158 /* Misc
159  */
160 #define DGL_NODEBUFFER_SHIFT DGL_NODEBUFFER_SHIFT_v2
161 #define DGL_NODEBUFFER_OFFSET DGL_NODEBUFFER_OFFSET_v2
162 #define DGL_EDGEBUFFER_SHIFT DGL_EDGEBUFFER_SHIFT_v2
163 #define DGL_EDGEBUFFER_OFFSET DGL_EDGEBUFFER_OFFSET_v2
164 
165 #define DGL_FOREACH_NODE DGL_FOREACH_NODE_v2
166 #define DGL_FOREACH_EDGE DGL_FOREACH_EDGE_v2
167 
168 /*
169  * Tree-node portability
170  */
171 #define DGL_T_NODEITEM_TYPE dglTreeNode2_s
172 #define DGL_T_NODEITEM_NodePTR(p) ((p)->pv)
173 #define DGL_T_NODEITEM_Set_NodePTR(p, ptr) ((p)->pv = (ptr))
174 #define DGL_T_NODEITEM_OutEdgesetPTR(p) ((p)->pv2)
175 #define DGL_T_NODEITEM_Set_OutEdgesetPTR(p, ptr) ((p)->pv2 = (ptr))
176 #define DGL_T_NODEITEM_InEdgesetPTR(p) ((p)->pv3)
177 #define DGL_T_NODEITEM_Set_InEdgesetPTR(p, ptr) ((p)->pv3 = (ptr))
178 #define DGL_T_NODEITEM_Compare dglTreeNode2Compare
179 #define DGL_T_NODEITEM_Cancel dglTreeNode2Cancel
180 #define DGL_T_NODEITEM_Add dglTreeNode2Add
181 #define DGL_T_NODEITEM_Alloc dglTreeNode2Alloc
182 
183 #endif