Commit ce35ea15 authored by John Douglas Veitch's avatar John Douglas Veitch 💬
Browse files

LALInferenceXML progress. Write a complete table.

Original: 86f799755e130fb10bb7cf2f32bd6680afe31c41
parent 8aeddbeb
......@@ -54,7 +54,7 @@ size_t LALInferenceTypeSize[] = {sizeof(INT4),
static char *colNameToParamName(const char *colName);
LALInferenceVariableItem *LALInferenceGetItem(LALInferenceVariables *vars,const char *name)
LALInferenceVariableItem *LALInferenceGetItem(const LALInferenceVariables *vars,const char *name)
/* (this function is only to be used internally) */
/* Returns pointer to item for given item name. */
{
......@@ -94,7 +94,7 @@ LALInferenceParamVaryType LALInferenceGetVariableVaryType(LALInferenceVariables
}
void *LALInferenceGetVariable(LALInferenceVariables * vars,const char * name)
void *LALInferenceGetVariable(const LALInferenceVariables * vars,const char * name)
/* Return the value of variable name from the vars structure by walking the list */
{
LALInferenceVariableItem *item;
......@@ -130,7 +130,7 @@ INT4 LALInferenceGetVariableDimensionNonFixed(LALInferenceVariables *vars)
}
LALInferenceVariableType LALInferenceGetVariableType(LALInferenceVariables *vars, const char *name)
LALInferenceVariableType LALInferenceGetVariableType(const LALInferenceVariables *vars, const char *name)
{
return LALInferenceGetItem(vars,name)->type;
}
......
......@@ -158,7 +158,7 @@ void LALInferencePrintVariableItem(char *out, LALInferenceVariableItem *ptr);
/** Return a pointer to the variable asked for */
void *LALInferenceGetVariable(LALInferenceVariables * vars, const char * name);
void *LALInferenceGetVariable(const LALInferenceVariables * vars, const char * name);
/** Get number of dimensions in this variable */
INT4 LALInferenceGetVariableDimension(LALInferenceVariables *vars);
/** Get number of dimensions which are not fixed to a certain value */
......@@ -169,7 +169,7 @@ LALInferenceVariableType LALInferenceGetVariableTypeByIndex(LALInferenceVariable
/** Get the type of the variable, returns LALInferenceVariableType (see above) */
LALInferenceVariableType LALInferenceGetVariableType(LALInferenceVariables *vars, const char *name);
LALInferenceVariableType LALInferenceGetVariableType(const LALInferenceVariables *vars, const char *name);
/** Get the LALInferenceParamVaryType of the variable, see types above */
LALInferenceParamVaryType LALInferenceGetVariableVaryType(LALInferenceVariables *vars, const char *name);
......@@ -334,7 +334,7 @@ void LALInferenceExecuteFT(LALInferenceIFOData *IFOdata);
void LALInferenceExecuteInvFT(LALInferenceIFOData *IFOdata);
/** Return the list node for "name" - do not rely on this */
LALInferenceVariableItem *LALInferenceGetItem(LALInferenceVariables *vars,const char *name);
LALInferenceVariableItem *LALInferenceGetItem(const LALInferenceVariables *vars,const char *name);
/** Return the list node for the idx-th item - do not rely on this */
LALInferenceVariableItem *LALInferenceGetItemNr(LALInferenceVariables *vars, int idx);
......
......@@ -71,16 +71,15 @@ xmlNodePtr XLALInferenceVariablesArray2VOTTable(const LALInferenceVariables **va
{
xmlNodePtr fieldNodeList=NULL;
xmlNodePtr paramNodeList=NULL;
xmlNodePtr dataContentNode=NULL;
xmlNodePtr xmlTABLEDATAnode=NULL;
xmlNodePtr VOTtableNode=NULL;
xmlNodePtr tmpNode=NULL;
xmlNodePtr field_ptr,param_ptr,data_ptr;
xmlNodePtr field_ptr,param_ptr;
LALInferenceVariableItem *varitem=NULL;
void *valuearray=NULL;
void **valuearrays=NULL;
UINT4 Nfields=0,i,j,field;
UINT4 Nfields=0,i,j;
const char *fn = __func__;
char *tablename=NULL;
int err;
......@@ -123,18 +122,21 @@ xmlNodePtr XLALInferenceVariablesArray2VOTTable(const LALInferenceVariables **va
}
valuearrays=calloc(Nfields,sizeof(void *));
VOTABLE_DATATYPE *dataTypes=calloc(Nfields,sizeof(VOTABLE_DATATYPE));
/* Build array of DATA */
for(field_ptr=fieldNodeList,j=0;field_ptr!=NULL;field_ptr=field_ptr->next,j++)
{
const char *name=field_ptr->name;
UINT4 typesize=LALInferenceTypeSize[LALInferenceGetVariableType(varsArray[0],name)];
const xmlChar *name=field_ptr->name;
char parname[VARNAME_MAX];
sprintf(parname,"%s",name);
UINT4 typesize=LALInferenceTypeSize[LALInferenceGetVariableType(varsArray[0],parname)];
valuearrays[j]=calloc(N,typesize);
dataTypes[j]=field_ptr->type;
for(i=0;i<N;i++)
{
memcpy(&(valuearrays[j][i]),LALInferenceGetVariable(varsArray[i],name),typesize);
memcpy((char *)valuearrays[j]+i*typesize,LALInferenceGetVariable(varsArray[i],parname),typesize);
}
}
va_list ap=NULL;
UINT4 row,col;
/* create TABLEDATA node */
......@@ -161,7 +163,7 @@ xmlNodePtr XLALInferenceVariablesArray2VOTTable(const LALInferenceVariables **va
}
/* ----- loop over columns and generate each table element */
for ( col = 0; col < nFields; col ++ )
for ( col = 0; col < Nfields; col ++ )
{
/* create TD node */
xmlNodePtr xmlThisEntryNode = NULL;
......@@ -199,15 +201,15 @@ xmlNodePtr XLALInferenceVariablesArray2VOTTable(const LALInferenceVariables **va
} /* for row < numRows */
}
/* Create a TABLE from the FIELDs and TABLEDATA nodes */
/* Create a TABLE from the FIELDs and TABLEDATA nodes */
sprintf(tablename,"LALInferenceXMLTable");
VOTtableNode= XLALCreateVOTTableNode (tablename, fieldNodeList, xmlTABLEDATAnode );
/* Attach PARAMs to TABLE node */
if(paramNodeList!=xmlAddChildNodeList(VOTtableNode,paramNodeList)){
XLALPrintError("%s: xmlAddChildNodeList failed\n",fn);
if(!xmlAddChildList(VOTtableNode,paramNodeList)){
XLALPrintError("%s: xmlAddChildList failed\n",fn);
err=XLAL_EFAILED;
goto failed;
}
......@@ -301,7 +303,7 @@ xmlNodePtr LALInferenceVariableItem2VOTFieldNode(LALInferenceVariableItem *varit
/* Special case for string */
if(varitem->type==LALINFERENCE_string_t)
return(XLALCreateVOTFieldNode(varitem->name,unitName,VOT_CHAR,"*");
return(XLALCreateVOTFieldNode(varitem->name,unitName,VOT_CHAR,"*"));
/* Check the type of the item */
vo_type=LALInferenceVariableType2VOT(varitem->type);
......@@ -321,7 +323,7 @@ xmlNodePtr LALInferenceVariableItem2VOTParamNode(LALInferenceVariableItem *varit
/* Special case for string */
if(varitem->type==LALINFERENCE_string_t)
return(XLALCreateVOTParamNode(varitem->name,unitName,VOT_CHAR,"*",varitem->value);
return(XLALCreateVOTParamNode(varitem->name,unitName,VOT_CHAR,"*",varitem->value));
/* Check the type of the item */
vo_type=LALInferenceVariableType2VOT(varitem->type);
......
......@@ -219,7 +219,12 @@ VOTABLE_DATATYPE XLALVOTString2Datatype ( const CHAR *datatypeString );
const char* XLALVOTElement2String ( VOTABLE_ELEMENT element );
const char* XLALVOTAttribute2String ( VOTABLE_ATTRIBUTE elementAttribute );
const char *
XLALVOTprintfFromArray ( VOTABLE_DATATYPE datatype, /**< [in] atomic dataypte of element to write */
const char *fmt, /**< [in] format string: if NULL we use default-fmt for datatype */
void *arrayPtr, /**< [in] pointer to array of data values */
UINT4 arrayIndex /**< [in] index of element to write: arrayPtr[index] */
);
/* C++ protection */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment