00001
00002
00003 #include "h5Dataset.h"
00004 #include "h5Object.h"
00005 #include "h5String.h"
00006 #include <assert.h>
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 int clH5Dataset_read(rcComm_t *conn, H5Dataset* d)
00017 {
00018 int ret_value = 0;
00019 H5Dataset *outd = NULL;
00020
00021 assert(d);
00022
00023 d->opID = H5DATASET_OP_READ;
00024
00025 ret_value = _clH5Dataset_read (conn, d, &outd);
00026 if( NULL == outd ) {
00027 rodsLog( LOG_ERROR, "clH5Dataset_read :: outd is null" );
00028 return 0;
00029 }
00030
00031 if (ret_value < 0)
00032 return (ret_value);
00033
00034
00035
00036 d->nvalue = outd->nvalue;
00037 d->value = outd->value;
00038 d->error = outd->error;
00039 d->time = outd->time;
00040 outd->value = NULL;
00041 outd->nvalue = 0;
00042
00043 H5Dataset_dtor (outd);
00044 free (outd);
00045
00046 return ret_value;
00047 }
00048
00049 int _clH5Dataset_read (rcComm_t *conn, H5Dataset* ind, H5Dataset** outd)
00050 {
00051 execMyRuleInp_t execMyRuleInp;
00052 msParamArray_t *outParamArray = NULL;
00053 msParamArray_t msParamArray;
00054 msParam_t *outMsParam;
00055 int status = 0;
00056
00057
00058 memset (&execMyRuleInp, 0, sizeof (execMyRuleInp));
00059 memset (&msParamArray, 0, sizeof (msParamArray));
00060 execMyRuleInp.inpParamArray = &msParamArray;
00061
00062
00063 rstrcpy (execMyRuleInp.myRule,
00064 "H5File_open||msiH5Dataset_read(*IND,*OUTD)|nop", META_STR_LEN);
00065
00066 rstrcpy (execMyRuleInp.outParamDesc, "*OUTD", LONG_NAME_LEN);
00067
00068 addMsParamToArray (execMyRuleInp.inpParamArray, "*IND", h5Dataset_MS_T, ind,
00069 NULL, 0);
00070
00071 status = rcExecMyRule (conn, &execMyRuleInp, &outParamArray);
00072
00073 if (status < 0) {
00074 rodsLogError (LOG_ERROR, status,
00075 "_clH5Dataset_read: rcExecMyRule error for %s.",
00076 ind->fullpath);
00077 clearMsParamArray (execMyRuleInp.inpParamArray, 0);
00078 return (status);
00079 }
00080
00081 if ((outMsParam = getMsParamByLabel (outParamArray, "*OUTD")) == NULL) {
00082 status = USER_PARAM_LABEL_ERR;
00083 rodsLogError (LOG_ERROR, status,
00084 "_clH5Dataset_read: outParamArray does not contain OUTD for %s.",
00085 ind->fullpath);
00086 } else {
00087 *outd = (H5Dataset *)outMsParam->inOutStruct;
00088 clearMsParamArray (outParamArray, 0);
00089
00090 free (outParamArray);
00091 }
00092
00093 clearMsParamArray (execMyRuleInp.inpParamArray, 0);
00094
00095 return (status);
00096
00097 }
00098
00099 int clH5Dataset_read_attribute(rcComm_t *conn, H5Dataset* ind)
00100 {
00101 int ret_value = 0;
00102 H5Dataset *outd = NULL;
00103
00104 assert(ind);
00105
00106 ind->opID = H5DATASET_OP_READ_ATTRIBUTE;
00107
00108 ret_value = _clH5Dataset_read_attribute (conn, ind, &outd);
00109 if( NULL == outd ) {
00110 rodsLog( LOG_ERROR, "clH5Dataset_read :: outd is null" );
00111 return 0;
00112 }
00113
00114 if (ret_value < 0)
00115 return (ret_value);
00116
00117
00118 ind->tclass = outd->tclass;
00119 ind->error = outd->error;
00120 ind->nattributes = outd->nattributes;
00121 ind->attributes = outd->attributes;
00122
00123 outd->attributes = NULL;
00124 outd->nattributes = 0;
00125
00126 H5Dataset_dtor (outd);
00127 free (outd);
00128
00129 return ret_value;
00130 }
00131
00132 int _clH5Dataset_read_attribute (rcComm_t *conn, H5Dataset* ind,
00133 H5Dataset** outd)
00134 {
00135 execMyRuleInp_t execMyRuleInp;
00136 msParamArray_t *outParamArray = NULL;
00137 msParamArray_t msParamArray;
00138 msParam_t *outMsParam;
00139 int status = 0;
00140
00141
00142 memset (&execMyRuleInp, 0, sizeof (execMyRuleInp));
00143 memset (&msParamArray, 0, sizeof (msParamArray));
00144 execMyRuleInp.inpParamArray = &msParamArray;
00145
00146
00147 rstrcpy (execMyRuleInp.myRule,
00148 "H5File_open||msiH5Dataset_read_attribute(*IND,*OUTD)|nop", META_STR_LEN);
00149
00150 rstrcpy (execMyRuleInp.outParamDesc, "*OUTD", LONG_NAME_LEN);
00151
00152 addMsParamToArray (execMyRuleInp.inpParamArray, "*IND", h5Dataset_MS_T, ind,
00153 NULL, 0);
00154
00155 status = rcExecMyRule (conn, &execMyRuleInp, &outParamArray);
00156 if (status < 0) {
00157 rodsLogError (LOG_ERROR, status,
00158 "_clH5Dataset_read_attribute: rcExecMyRule error for %s.",
00159 ind->fullpath);
00160 clearMsParamArray (execMyRuleInp.inpParamArray, 0);
00161 return (status);
00162 }
00163
00164 if ((outMsParam = getMsParamByLabel (outParamArray, "*OUTD")) == NULL) {
00165 status = USER_PARAM_LABEL_ERR;
00166 rodsLogError (LOG_ERROR, status,
00167 "_clH5Dataset_read_attribute: outParamArray does not contain OUTD for %s.",
00168 ind->fullpath);
00169 } else {
00170 *outd = (H5Dataset *)outMsParam->inOutStruct;
00171 clearMsParamArray (outParamArray, 0);
00172
00173 free (outParamArray);
00174 }
00175
00176 clearMsParamArray (execMyRuleInp.inpParamArray, 0);
00177
00178 return (status);
00179 }
00180