Skip to content

Commit 7c40ac4

Browse files
committed
Add routine to get the relevant identifier
1 parent 54ae457 commit 7c40ac4

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ C_ROUTINES = \
9191
dat1InitHDF5.c \
9292
dau1CheckName.c \
9393
dau1CheckType.c \
94+
dat1RetrieveIdentifier.c \
9495
dat1RetrieveContainer.c
9596

9697
DAT_PAR: dat_par_f$(EXEEXT)

dat1.h

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ dat1New( const HDSLoc *locator, const char *name_str, const char *type_str,
155155
int ndim, const hdsdim dims[], int *status);
156156

157157
hid_t dat1RetrieveContainer( const HDSLoc *locator, int * status );
158+
hid_t dat1RetrieveIdentifier( const HDSLoc * locator, int * status );
158159

159160
HDSLoc * dat1FreeLoc( HDSLoc * locator, int * status );
160161

dat1RetrieveIdentifier.c

+98
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
*+
3+
* Name:
4+
* dat1RetrieveIdentifier
5+
6+
* Purpose:
7+
* Select the group or dataset ID from the supplied struct
8+
9+
* Language:
10+
* Starlink ANSI C
11+
12+
* Type of Module:
13+
* Library routine
14+
15+
* Invocation:
16+
* hid_t dat1RetrieveIdentifier( const HDSLoc * locator, int * status );
17+
18+
* Arguments:
19+
* locator = const HDSLoc * (Given)
20+
* HDS locator.
21+
* status = int* (Given and Returned)
22+
* Pointer to global status.
23+
24+
* Description:
25+
* In many APIs the system doesn't care whether the locator is associated
26+
* with a dataset or group so this routine returns the relevant ID.
27+
28+
* Authors:
29+
* TIMJ: Tim Jenness (Cornell)
30+
* {enter_new_authors_here}
31+
32+
* Notes:
33+
*
34+
35+
* History:
36+
* 2014-08-26 (TIMJ):
37+
* Initial version
38+
* {enter_further_changes_here}
39+
40+
* Copyright:
41+
* Copyright (C) 2014 Cornell University
42+
* All Rights Reserved.
43+
44+
* Licence:
45+
* Redistribution and use in source and binary forms, with or
46+
* without modification, are permitted provided that the following
47+
* conditions are met:
48+
*
49+
* - Redistributions of source code must retain the above copyright
50+
* notice, this list of conditions and the following disclaimer.
51+
*
52+
* - Redistributions in binary form must reproduce the above
53+
* copyright notice, this list of conditions and the following
54+
* disclaimer in the documentation and/or other materials
55+
* provided with the distribution.
56+
*
57+
* - Neither the name of the {organization} nor the names of its
58+
* contributors may be used to endorse or promote products
59+
* derived from this software without specific prior written
60+
* permission.
61+
*
62+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
63+
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
64+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
65+
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
66+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
67+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
68+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
69+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
70+
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
71+
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
72+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
73+
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
74+
* THE POSSIBILITY OF SUCH DAMAGE.
75+
76+
* Bugs:
77+
* {note_any_bugs_here}
78+
*-
79+
*/
80+
81+
#include "hdf5.h"
82+
83+
#include "hds1.h"
84+
#include "dat1.h"
85+
#include "hds.h"
86+
87+
#include "sae_par.h"
88+
89+
hid_t dat1RetrieveIdentifier( const HDSLoc * locator, int * status ) {
90+
91+
if (*status != SAI__OK) return 0;
92+
if (!locator) return 0;
93+
94+
if (locator->group_id > 0) return locator->group_id;
95+
if (locator->dataset_id > 0) return locator->dataset_id;
96+
return 0;
97+
98+
}

0 commit comments

Comments
 (0)