next up previous contents
Next: About this document ... Up: Data Object Attributes Previous: Data Object Attributes   Contents

Subsections

Getting and Setting Attributes

Attributes are held as QdObjects of the appropriate type, so that, for example VALIDMAX for a scalar data series would be accessed via a xref to a QdRScalar_var. Since the essential attributes are stored as xrefs in QdString format you will need only the following functions (QdUtils.h) to get and set these attributes:
$\bullet$
char * QuGetAttrText(char * name, QdObject_var obj);
This returns a pointer to the string value of a text attribute called name. This string should not be deleted.
$\bullet$
void QuSetTxtAttr(char *name, char * value, QdObject_var ptr);
This function sets the content of the text xref called name to be value for the QSAS object pointed to by ptr. It makes a copy of the input string value which may then be safely destroyed.
#include "Qdos.h"
#include "QdUtils.h"
QuSetTxtAttr(FRAME, "scalar>na", (QdObject_var) out_series);
QuSetTxtAttr(SI_CONVERSION, QuGetAttrText("SI_conversion", X_in),
   (QdObject_var) out_series);
QuSetTxtAttr("Method", "Magnitude of XY components only", 
             (QdObject_var) out_series);
The above example shows the creation of a new FRAME attribute with value ``scalar_na'', the copying of the attribute SI_CONVERSION from the input object to the output series, and the creation of a new user defined attribute to be called Method to record useful information with the data. The attribute names shown in upper case are standard strings defined in Xrefs.h and listed in the table (1).

In addition you can use following xref-methods to manipulate and copy general xrefs of a QSAS data object, and these may be of any QdObject type. The object Data_obj is a var pointer of any type derived from QdObject_var.

 Data_obj->change_xref(string& xref_name, QdObject_var xref_obj)
 Data_obj->copy_xrefs_from(QdObject_var from_obj)
 Data_obj->copy_xrefs_to(QdObject_var to_obj)
 Data_obj->delete_xref(string& xref_name)
 Data_obj->get_xref(string& xref_name)
 Data_obj->list_xref_names(vector<string>& sl)
 Data_obj->set_xref(string& xref_name, QdObject_var xref_obj)
 bool Data_obj->xref_exists(string& xref_name)
It is sufficient to pass a char * string in place of the string literal into these methods for the xref_name input arguments.

Useful functions for calculating attributes

In addition to the QDOS methods above there are some functions defined in qar.h which are useful for mathematical operations with QSAS data objects (qar.h):
$\bullet$
int QarAreUnitsSame(QdObject_var ptr1, QdObject_var ptr2),
e.g. if(QarAreUnitsSame(obj1,obj2) == QAR_OK){...} checks whether units attributes are identical.
$\bullet$
char * QarUNITS_product(QdObject_var in1_ptr, QdObject_var in2_ptr),
e.g. newunits = QarUNITS_product(obj1,obj2) to multiply units.
$\bullet$
char * QarSIConv_product(QdObject_var in1_ptr, QdObject_var in2_ptr),
e.g. newsiconv = QarSIConv_product(obj1,obj2) to multiply SI_conversion factors.
$\bullet$
char * QarSIConv_inverse(QdObject_var in1_ptr),
e.g. newsiconv = QarSIConv_inverse(obj1) to inverse SI_conversion factor.
$\bullet$
int QarTestConformalForVecProds(QdObject_var in1_ptr, QdObject_var in2_ptr),
e.g. if(QarTestConformalForVecProds(b_xyz,c_xyz) == QAR_OK){...} checks whether series are 3-component with identical frames.
$\bullet$
int QarAreFramesSame(QdObject_var ptr1, QdObject_var ptr2),
e.g. if(QarAreFramesSame(b_xyz,c_xyz) == QAR_OK){...} checks whether series have same frame.
$\bullet$
int QarTestJoined(QdObject_var do1,QdObject_var do2),
e.g. if(QarTestJoined(ss1,ss2) == QAR_OK){...}
to check whether two series have same size and - if timeseries - same timetags.


next up previous contents
Next: About this document ... Up: Data Object Attributes Previous: Data Object Attributes   Contents
Anthony Allen 2005-11-07