Skip to content

Commit dce901d

Browse files
authored
Remove unused NXputattra, NXgetattra, NXgetattrainfo and test -- ornl-next (#39036)
Remove unused NXputattra, NXgetattra, NXgetattrainfo and test (#39019) * remove unused NXputattra, NXgetattra, NXgetattrainfo and test * edits to cmake
1 parent b50d515 commit dce901d

File tree

7 files changed

+2
-530
lines changed

7 files changed

+2
-530
lines changed

Framework/Nexus/inc/MantidNexus/napi.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -341,23 +341,6 @@ MANTID_NEXUS_DLL NXstatus NXputdata(NXhandle handle, const void *data);
341341
*/
342342
MANTID_NEXUS_DLL NXstatus NXputattr(NXhandle handle, CONSTCHAR *name, const void *data, int iDataLen, NXnumtype iType);
343343

344-
/**
345-
* Write an attribute of any rank. The kind of attribute written depends on the
346-
* position in the file: at root level, a global attribute is written, if
347-
* agroup is open but no dataset, a group attribute is written, if a dataset is
348-
* open, a dataset attribute is written.
349-
* \param handle A NeXus file handle as initialized by NXopen.
350-
* \param name The name of the attribute.
351-
* \param data A pointer to the data to write for the attribute.
352-
* \param rank Rank of the attribute data
353-
* \param dim Dimension array for the attribute data
354-
* \param iType The NeXus data type of the attribute.
355-
* \return NX_OK on success, NX_ERROR in the case of an error.
356-
* \ingroup c_readwrite
357-
*/
358-
MANTID_NEXUS_DLL NXstatus NXputattra(NXhandle handle, CONSTCHAR *name, const void *data, const int rank,
359-
const int dim[], const NXnumtype iType);
360-
361344
/**
362345
* Write a subset of a multi dimensional dataset.
363346
* \param handle A NeXus file handle as initialized by NXopen.
@@ -515,27 +498,6 @@ MANTID_NEXUS_DLL NXstatus NXgetattrinfo(NXhandle handle, int *no_items);
515498
*/
516499
MANTID_NEXUS_DLL NXstatus NXgetnextattra(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType);
517500

518-
/**
519-
* Read an arbitrarily shaped attribute.
520-
* \param handle A NeXus file handle as initialized by NXopen.
521-
* \param name The name of the atrribute to read.
522-
* \param data A pointer to a memory area large enough to hold the attributes value.
523-
* \return NX_OK on success, NX_ERROR in the case of an error.
524-
* \ingroup c_readwrite
525-
*/
526-
MANTID_NEXUS_DLL NXstatus NXgetattra(NXhandle handle, const char *name, void *data);
527-
528-
/**
529-
* Get the information about the storage of the named attribute.
530-
* \param handle A NeXus file handle as initialized by NXopen.
531-
* \param rank Rank of the attribute data.
532-
* \param dim Dimension array for the attribute content.
533-
* \param iType A pointer to an integer which be set to the NeXus data type of the attribute.
534-
* \return NX_OK on success, NX_ERROR in the case of an error.
535-
* \ingroup c_metadata
536-
*/
537-
MANTID_NEXUS_DLL NXstatus NXgetattrainfo(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType);
538-
539501
/**
540502
* Retrieve link data for the currently open group. This link data can later on be used to link this
541503
* group into a different group.

Framework/Nexus/inc/MantidNexus/napi5.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ extern NXstatus NX5getgroupinfo(NXhandle handle, int *no_items, NXname name, NXn
4848
extern NXstatus NX5initgroupdir(NXhandle handle);
4949
extern NXstatus NX5initattrdir(NXhandle handle);
5050

51-
extern NXstatus NX5putattra(NXhandle handle, CONSTCHAR *name, const void *data, const int rank, const int dim[],
52-
const NXnumtype iType);
5351
extern NXstatus NX5getnextattra(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType);
54-
extern NXstatus NX5getattra(NXhandle handle, const char *name, void *data);
5552
extern NXstatus NX5getattrainfo(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType);
5653

5754
void NX5assignFunctions(pNexusFunction fHandle);

Framework/Nexus/inc/MantidNexus/napi_internal.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ typedef struct {
5151
NXstatus (*nxclosedata)(NXhandle handle);
5252
NXstatus (*nxputdata)(NXhandle handle, const void *data);
5353
NXstatus (*nxputattr)(NXhandle handle, CONSTCHAR *name, const void *data, int iDataLen, NXnumtype iType);
54-
NXstatus (*nxputattra)(NXhandle handle, CONSTCHAR *name, const void *data, const int rank, const int dim[],
55-
const NXnumtype iType);
5654
NXstatus (*nxputslab64)(NXhandle handle, const void *data, const int64_t start[], const int64_t size[]);
5755
NXstatus (*nxgetdataID)(NXhandle handle, NXlink *pLink);
5856
NXstatus (*nxmakelink)(NXhandle handle, NXlink *pLink);
@@ -64,8 +62,6 @@ typedef struct {
6462
NXstatus (*nxgetnextattr)(NXhandle handle, NXname pName, int *iLength, NXnumtype *iType);
6563
NXstatus (*nxgetnextattra)(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType);
6664
NXstatus (*nxgetattr)(NXhandle handle, const char *name, void *data, int *iDataLen, NXnumtype *iType);
67-
NXstatus (*nxgetattra)(NXhandle handle, const char *name, void *data);
68-
NXstatus (*nxgetattrainfo)(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType);
6965
NXstatus (*nxgetattrinfo)(NXhandle handle, int *no_items);
7066
NXstatus (*nxgetgroupID)(NXhandle handle, NXlink *pLink);
7167
NXstatus (*nxgetgroupinfo)(NXhandle handle, int *no_items, NXname name, NXname nxclass);

Framework/Nexus/src/napi.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,23 +1551,10 @@ NXstatus NXgetpath(NXhandle fid, char *path, int pathlen) {
15511551
return NXstatus::NX_OK;
15521552
}
15531553

1554-
NXstatus NXputattra(NXhandle handle, CONSTCHAR *name, const void *data, const int rank, const int dim[],
1555-
const NXnumtype iType) {
1556-
pNexusFunction pFunc = handleToNexusFunc(handle);
1557-
return LOCKED_CALL(pFunc->nxputattra(pFunc->pNexusData, name, data, rank, dim, iType));
1558-
}
15591554
NXstatus NXgetnextattra(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType) {
15601555
pNexusFunction pFunc = handleToNexusFunc(handle);
15611556
return LOCKED_CALL(pFunc->nxgetnextattra(pFunc->pNexusData, pName, rank, dim, iType));
15621557
}
1563-
NXstatus NXgetattra(NXhandle handle, const char *name, void *data) {
1564-
pNexusFunction pFunc = handleToNexusFunc(handle);
1565-
return LOCKED_CALL(pFunc->nxgetattra(pFunc->pNexusData, name, data));
1566-
}
1567-
NXstatus NXgetattrainfo(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType) {
1568-
pNexusFunction pFunc = handleToNexusFunc(handle);
1569-
return LOCKED_CALL(pFunc->nxgetattrainfo(pFunc->pNexusData, pName, rank, dim, iType));
1570-
}
15711558

15721559
/*--------------------------------------------------------------------
15731560
format NeXus time. Code needed in every NeXus file driver

Framework/Nexus/src/napi5.cpp

Lines changed: 0 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,81 +2285,6 @@ NXstatus NX5initgroupdir(NXhandle fid) {
22852285
return NXstatus::NX_OK;
22862286
}
22872287

2288-
/*------------------------------------------------------------------------*/
2289-
NXstatus NX5putattra(NXhandle handle, CONSTCHAR *name, const void *data, const int rank, const int dim[],
2290-
const NXnumtype iType) {
2291-
hid_t datatype1, dataspace;
2292-
hid_t type;
2293-
pNexusFile5 pFile;
2294-
int i;
2295-
hid_t vid, iATT;
2296-
herr_t iRet;
2297-
hsize_t mydim[H5S_MAX_RANK];
2298-
2299-
pFile = NXI5assert(handle);
2300-
2301-
for (i = 0; i < rank; i++) {
2302-
mydim[i] = static_cast<hsize_t>(dim[i]);
2303-
}
2304-
2305-
/* determine vid */
2306-
vid = getAttVID(pFile);
2307-
iATT = H5Aopen_by_name(vid, ".", name, H5P_DEFAULT, H5P_DEFAULT);
2308-
if (iATT > 0) {
2309-
H5Aclose(iATT);
2310-
iRet = H5Adelete(vid, name);
2311-
if (iRet < 0) {
2312-
NXReportError("ERROR: old attribute cannot be removed! ");
2313-
killAttVID(pFile, vid);
2314-
return NXstatus::NX_ERROR;
2315-
}
2316-
}
2317-
2318-
if (rank < 0) {
2319-
char pBuffer[256];
2320-
sprintf(pBuffer, "ERROR: invalid rank specified %s", name);
2321-
NXReportError(pBuffer);
2322-
return NXstatus::NX_ERROR;
2323-
}
2324-
2325-
type = nxToHDF5Type(iType);
2326-
2327-
datatype1 = H5Tcopy(type);
2328-
if (iType == NXnumtype::CHAR) {
2329-
H5Tset_size(datatype1, static_cast<size_t>(dim[rank - 1]));
2330-
dataspace = H5Screate_simple(rank - 1, mydim, NULL);
2331-
} else {
2332-
dataspace = H5Screate_simple(rank, mydim, NULL);
2333-
}
2334-
2335-
iATT = H5Acreate(vid, static_cast<const char *>(name), datatype1, dataspace, H5P_DEFAULT, H5P_DEFAULT);
2336-
2337-
if (iATT < 0) {
2338-
NXReportError("ERROR: creating attribute failed");
2339-
return NXstatus::NX_ERROR;
2340-
} else {
2341-
pFile->iCurrentA = iATT;
2342-
}
2343-
2344-
iRet = H5Awrite(pFile->iCurrentA, datatype1, data);
2345-
if (iRet < 0) {
2346-
NXReportError("ERROR: failure to write attribute");
2347-
return NXstatus::NX_ERROR;
2348-
}
2349-
2350-
// less than zero is an error so just accumulate them
2351-
iRet += H5Sclose(dataspace);
2352-
iRet += H5Tclose(datatype1);
2353-
iRet += H5Aclose(pFile->iCurrentA);
2354-
pFile->iCurrentA = 0;
2355-
if (iRet < 0) {
2356-
NXReportError("ERROR: HDF cannot close attribute");
2357-
return NXstatus::NX_ERROR;
2358-
}
2359-
2360-
return NXstatus::NX_OK;
2361-
}
2362-
23632288
/*------------------------------------------------------------------------*/
23642289
NXstatus NX5getnextattra(NXhandle handle, NXname pName, int *rank, int dim[], NXnumtype *iType) {
23652290
pNexusFile5 pFile;
@@ -2418,95 +2343,6 @@ NXstatus NX5getnextattra(NXhandle handle, NXname pName, int *rank, int dim[], NX
24182343
return NX5getattrainfo(handle, pName, rank, dim, iType);
24192344
}
24202345
/*------------------------------------------------------------------------*/
2421-
NXstatus NX5getattra(NXhandle handle, const char *name, void *data) {
2422-
pNexusFile5 pFile;
2423-
int iStart[H5S_MAX_RANK], status;
2424-
hid_t vid;
2425-
hid_t memtype_id, filespace, datatype;
2426-
H5T_class_t tclass;
2427-
hsize_t dims[H5S_MAX_RANK];
2428-
htri_t is_vlen_str = 0; /* false */
2429-
char **vstrdata = NULL;
2430-
2431-
pFile = NXI5assert(handle);
2432-
2433-
vid = getAttVID(pFile);
2434-
pFile->iCurrentA = H5Aopen_by_name(vid, ".", name, H5P_DEFAULT, H5P_DEFAULT);
2435-
if (pFile->iCurrentA < 0) {
2436-
pFile->iCurrentA = 0;
2437-
NXReportError("ERROR: unable to open attribute");
2438-
return NXstatus::NX_ERROR;
2439-
}
2440-
filespace = H5Aget_space(pFile->iCurrentA);
2441-
datatype = H5Aget_type(pFile->iCurrentA);
2442-
auto ndims = H5Sget_simple_extent_dims(filespace, dims, NULL);
2443-
2444-
is_vlen_str = H5Tis_variable_str(datatype);
2445-
if (ndims == 0 && is_vlen_str) {
2446-
/* this assumes a fixed size - is this dangerous? */
2447-
char *strdata = static_cast<char *>(calloc(512, sizeof(char)));
2448-
status = H5Aread(pFile->iCurrentA, H5S_ALL, &strdata);
2449-
if (status >= 0) {
2450-
#if defined(__GNUC__) && !(defined(__clang__))
2451-
#pragma GCC diagnostic push
2452-
#pragma GCC diagnostic ignored "-Wstringop-truncation"
2453-
#endif
2454-
std::strncpy(static_cast<char *>(data), strdata, strlen(strdata));
2455-
#if defined(__GNUC__) && !(defined(__clang__))
2456-
#pragma GCC diagnostic pop
2457-
#endif
2458-
}
2459-
free(strdata);
2460-
2461-
H5Sclose(filespace);
2462-
H5Tclose(datatype);
2463-
if (status < 0)
2464-
return NXstatus::NX_ERROR;
2465-
return NXstatus::NX_OK;
2466-
}
2467-
tclass = H5Tget_class(datatype);
2468-
/* stop gap kludge for fixed length strings */
2469-
if (tclass == H5T_STRING && !is_vlen_str) {
2470-
char *datatmp = NULL;
2471-
status = readStringAttribute(pFile->iCurrentA, &datatmp);
2472-
if (status < 0)
2473-
return NXstatus::NX_ERROR;
2474-
strcpy(static_cast<char *>(data), datatmp);
2475-
free(datatmp);
2476-
return NXstatus::NX_OK;
2477-
}
2478-
2479-
memset(iStart, 0, H5S_MAX_RANK * sizeof(int));
2480-
/* map datatypes of other plateforms */
2481-
if (is_vlen_str) {
2482-
vstrdata = static_cast<char **>(malloc((size_t)dims[0] * sizeof(char *)));
2483-
memtype_id = H5Tcopy(H5T_C_S1);
2484-
H5Tset_size(memtype_id, H5T_VARIABLE);
2485-
status = H5Aread(pFile->iCurrentA, memtype_id, vstrdata);
2486-
(static_cast<char *>(data))[0] = '\0';
2487-
if (status >= 0) {
2488-
for (hsize_t i = 0; i < dims[0]; ++i) {
2489-
if (vstrdata[i] != NULL) {
2490-
strcat(static_cast<char *>(data), vstrdata[i]);
2491-
}
2492-
}
2493-
}
2494-
H5Dvlen_reclaim(memtype_id, pFile->iCurrentS, H5P_DEFAULT, vstrdata);
2495-
free(vstrdata);
2496-
H5Tclose(memtype_id);
2497-
} else if (tclass == H5T_STRING) {
2498-
status = H5Aread(pFile->iCurrentA, datatype, data);
2499-
} else {
2500-
memtype_id = h5MemType(datatype);
2501-
status = H5Aread(pFile->iCurrentA, memtype_id, data);
2502-
}
2503-
if (status < 0) {
2504-
NXReportError("ERROR: failed to read attribute");
2505-
return NXstatus::NX_ERROR;
2506-
}
2507-
return NXstatus::NX_OK;
2508-
}
2509-
/*------------------------------------------------------------------------*/
25102346
NXstatus NX5getattrainfo(NXhandle handle, NXname name, int *rank, int dim[], NXnumtype *iType) {
25112347
pNexusFile5 pFile;
25122348
int iRet;
@@ -2605,10 +2441,7 @@ void NX5assignFunctions(pNexusFunction fHandle) {
26052441
fHandle->nxnativeexternallink = NX5nativeexternallink;
26062442
fHandle->nxnativeinquirefile = NX5nativeinquirefile;
26072443
fHandle->nxnativeisexternallink = NX5nativeisexternallink;
2608-
fHandle->nxputattra = NX5putattra;
26092444
fHandle->nxgetnextattra = NX5getnextattra;
2610-
fHandle->nxgetattra = NX5getattra;
2611-
fHandle->nxgetattrainfo = NX5getattrainfo;
26122445
}
26132446

26142447
#endif /* HDF5 */

Framework/Nexus/test/CMakeLists.txt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ add_executable(napi_test_hdf5 EXCLUDE_FROM_ALL napi_test.cpp napi_test_util.cpp
1919
target_link_libraries(napi_test_hdf5 PRIVATE Mantid::Nexus)
2020
add_test(NAME "${TEST_PREFIX}-C-HDF5-test" COMMAND napi_test_hdf5)
2121

22-
add_executable(napi_attra_test_hdf5 EXCLUDE_FROM_ALL napi_attra_test.cpp napi_test_util.cpp napi_test_util.h)
23-
target_link_libraries(napi_attra_test_hdf5 PRIVATE Mantid::Nexus)
24-
add_test(NAME "${TEST_PREFIX}-C-HDF5-attra-test" COMMAND napi_attra_test_hdf5)
25-
2622
add_executable(napi_test_cpp-hdf5 EXCLUDE_FROM_ALL napi_test_cpp.cpp napi_test_util.cpp napi_test_util.h)
2723
target_link_libraries(napi_test_cpp-hdf5 PRIVATE Mantid::Nexus)
2824
add_test(NAME "${TEST_PREFIX}-Cpp-HDF5-test" COMMAND napi_test_cpp-hdf5)
@@ -48,14 +44,8 @@ add_test(NAME "${TEST_PREFIX}-Cpp-leak-test-3" COMMAND napi_leak_test3)
4844

4945
# #### phony target to drag in all tests
5046
add_custom_target(
51-
"${TEST_PREFIX}"
52-
DEPENDS napi_test_hdf5
53-
napi_attra_test_hdf5
54-
napi_test_cpp-hdf5
55-
napi_test_nxunlimited
56-
napi_leak_test1
57-
napi_leak_test2
58-
napi_leak_test3
47+
"${TEST_PREFIX}" DEPENDS napi_test_hdf5 napi_test_cpp-hdf5 napi_test_nxunlimited napi_leak_test1 napi_leak_test2
48+
napi_leak_test3
5949
)
6050

6151
add_dependencies(FrameworkTests "${TEST_PREFIX}")

0 commit comments

Comments
 (0)