MISR Toolkit  1.5.1
ag_nodesag.c
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Description: This file contains C routines for navigating among the group
4  nodes in an ODL tree. These routines augment the general
5  purpose routines for manipulating aggregate nodes by
6  providing mechanisms to locate group nodes, while
7  ignoring object nodes.
8 
9  Author: Randy Davis, University of Colorado LASP
10 
11  Creation Date: 13 March 1991
12  last Modified: 18 May 1991
13 
14  History:
15 
16  Creation - This set of routines was introduced in the Version 2.1
17  release of the ODLC library.
18 
19  Version 2.2 - 18 May 1991 - M. DeMore, Jet Propulsion Laboratory
20  Removed include statements that were Unix specific and placed them
21  in odldef.h.
22 
23 *****************************************************************************/
24 
25 #include "odldef.h"
26 #include "odlinter.h"
27 
28 
29 
30 /*****************************************************************************
31 
32  Routine: ParentGroup
33 
34  Description: Returns a pointer to the group containing an aggregate node.
35 
36  Input:
37  base_node - A pointer to an aggregate node.
38 
39  Output: If the input aggregate node is within a group, a pointer to that
40  group node is returned as the function value. If the input node
41  is not within a group, the NULL value is returned. The NULL
42  value is also returned if the input argument is NULL.
43 
44 *****************************************************************************/
45 
46 
48 
49 {
50  AGGREGATE node; /* Pointer to current aggregate node */
51 
52 
53  node = base_node;
54 
55  do
56  {
57  node = ParentAggregate (node);
58  } while (node != NULL && node->kind != KA_GROUP);
59 
60  return (node);
61 }
62 
63 
64 
65 
66 /*****************************************************************************
67 
68  Routine: NextGroup
69 
70  Description: Returns the next group node after the input aggregate node,
71  according to a pre-order traversal of the ODL tree.
72 
73  Input:
74  base_node - A pointer to the starting aggregate node.
75 
76  Output: A pointer to the next group node is returned as the function value.
77  The NULL value is returned if there is no next group node. The
78  NULL value is also returned if the input argument is NULL.
79 
80 *****************************************************************************/
81 
82 
84 
85 {
86  AGGREGATE node; /* Pointer to the next node */
87 
88 
89  node = base_node;
90 
91  do
92  {
93  node = NextAggregate (node);
94  } while (node != NULL && node->kind != KA_GROUP);
95 
96  return node;
97 }
98 
99 
100 
101 /*****************************************************************************
102 
103  Routine: NextSubGroup
104 
105  Description: Returns the next group of the base node after the one
106  pointed to by the start node.
107 
108  Input:
109  base_node - A pointer to the base aggregate node.
110  start_node - A pointer to the starting node.
111 
112  Output: A pointer to the next group sub-node of the base node is
113  returned as the function value. A NULL value indicates that
114  there is no next group sub-node. The NULL value is also
115  returned if the input argument is NULL.
116 
117 *****************************************************************************/
118 
119 
120 GROUP NextSubGroup (AGGREGATE base_node, AGGREGATE start_node)
121 
122 {
123  AGGREGATE node; /* Pointer to the next node */
124 
125 
126  node = start_node;
127 
128  do
129  {
130  node = NextSubAggregate (base_node, node);
131  } while (node != NULL && node->kind != KA_GROUP);
132 
133  return node;
134 }
135 
136 
137 
138 
139 /*****************************************************************************
140 
141  Routine: FindGroup
142 
143  Description: Finds a group node with a specified name. The search starts
144  with the base node and continues as necessary with all
145  of the base nodes's children, all their children, and
146  so on using a preorder search.
147 
148  Input:
149  base_node - A pointer to the starting aggregate node.
150  name - Pointer to a character string with the name of the
151  group to be located.
152 
153  Output: A pointer to the first group node that has the specified name.
154  If no match is found, then the NULL value is returned. The
155  NULL value is also returned if either of the input arguments
156  is NULL.
157 
158 *****************************************************************************/
159 
160 
161 GROUP FindGroup (AGGREGATE base_node, char *name)
162 
163 {
164  AGGREGATE node; /* Pointer to current node */
165 
166 
167  if (base_node == NULL || name == NULL)
168  {
169  return (NULL);
170  }
171 
172  /* Start searching with the base node and stop searching when we
173  find a group node with the specified name or when we have
174  visited all of the progeny of the base node */
175 
176  node = base_node;
177 
178  while (node != NULL)
179  {
180  if (node->kind == KA_GROUP && strcmp (node->name, name) == 0)
181  {
182  break;
183  }
184 
185  node = NextSubGroup (base_node, node);
186  }
187 
188  return (node);
189 }
190 
191 
192 
193 
194 /*****************************************************************************
195 
196  Routine: FindNextGroup
197 
198  Description: This routine is similar to routine FindGroup in that it
199  searches the progeny of the specified base node, except
200  that the search begins with the node specified by the second
201  argument. This is useful when there is more than one group
202  node with the same name in the search path.
203 
204  Input:
205  base_node - A pointer to the base aggregate node for the search.
206  start_node - A pointer to the starting node for the search. The
207  search does not include the start node.
208  name - Pointer to a character string with the name of the
209  group to be located.
210 
211  Output: A pointer to the next group node that has the specified name is
212  returned as the function value. If no match is found, then the
213  NULL value is returned. The NULL value is also returned if any
214  of the three input arguments are NULL.
215 
216 *****************************************************************************/
217 
218 
219 GROUP FindNextGroup (AGGREGATE base_node, AGGREGATE start_node, char *name)
220 {
221  AGGREGATE node; /* Pointer to current node */
222 
223 
224  if (base_node == NULL || start_node == NULL || name == NULL)
225  {
226  return (NULL);
227  }
228 
229  /* Start searching from the start node and stop searching when we find
230  a group node with the specified name or when we have visited all of
231  the progeny of the base node */
232 
233  node = NextSubGroup (base_node, start_node);
234 
235  while (node != NULL && strcmp (node->name, name) != 0)
236  {
237  node = NextSubGroup (base_node, node);
238  }
239 
240  return (node);
241 }
AGGREGATE ParentAggregate(AGGREGATE base_node)
Definition: a_nodesa.c:295
AGGREGATE NextAggregate(AGGREGATE base_node)
Definition: a_nodesa.c:342
GROUP FindGroup(AGGREGATE base_node, char *name)
Definition: ag_nodesag.c:161
AGGREGATE_KIND kind
Definition: odldef.h:115
GROUP FindNextGroup(AGGREGATE base_node, AGGREGATE start_node, char *name)
Definition: ag_nodesag.c:219
HDFFCLIBAPI _fcd name
GROUP ParentGroup(AGGREGATE base_node)
Definition: ag_nodesag.c:47
GROUP NextGroup(AGGREGATE base_node)
Definition: ag_nodesag.c:83
GROUP NextSubGroup(AGGREGATE base_node, AGGREGATE start_node)
Definition: ag_nodesag.c:120
AGGREGATE NextSubAggregate(AGGREGATE base_node, AGGREGATE start_node)
Definition: a_nodesa.c:410
char * name
Definition: odldef.h:112

MISR Toolkit - Copyright © 2005 - 2020 Jet Propulsion Laboratory
Generated on Fri Jun 19 2020 22:49:51