TSP: The Transport Sample Protocol



Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

gdisp_doubleArray.h

Go to the documentation of this file.
00001 
00042 #ifndef __DOUBLE_ARRAY_H__
00043 #define __DOUBLE_ARRAY_H__
00044 
00045 /*
00046  * samples    : pointer on samples,
00047  * nbSamples  : number of samples currently in array,
00048  * current    : index on current position,
00049  * first      : index on first position,
00050  * maxSamples : maximum samples possible to be added.
00051  */
00052 typedef struct DoubleArray_T_
00053 {
00054 
00055   gdouble  *samples;
00056   guint     nbSamples;
00057   guint     current;
00058   guint     first;
00059   guint     maxSamples;
00060 
00061 } DoubleArray_T;
00062 
00063 
00064 /*
00065  * Return a double sample element form an Array and an index.
00066  */
00067 #define DA_GET_SAMPLE_FROM_FIRST(pArray,i) \
00068         ((pArray)->samples[ (i + (pArray)->first) % (pArray)->nbSamples ])
00069 
00070 #define DA_GET_SAMPLE(pArray,i) \
00071         ((pArray)->samples[ (i) % (pArray)->nbSamples ])
00072 
00073 #define DA_GET_SAMPLE_PTR(pArray,i) \
00074         (&DA_GET_SAMPLE(pArray,i))
00075 
00076 /*
00077  * Sets the fields to default values and allocate a sample buffer.
00078  */
00079 DoubleArray_T *da_newSampleArray (guint maxSamples);
00080 
00081 /*
00082  * Destroy all memory allocated for this array.
00083  */
00084 void da_freeSampleArray (DoubleArray_T *dArray);
00085 
00086 /*
00087  * Add an array sample element.
00088  */
00089 void da_addSample (DoubleArray_T *dArray, gdouble dValue);
00090 
00091 /*
00092  * Accessors on data.
00093  */
00094 guint da_getFirstIndex   (DoubleArray_T *dArray);
00095 guint da_getCurrentIndex (DoubleArray_T *dArray);
00096 guint da_getNbSamples    (DoubleArray_T *dArray);
00097 
00098 /*
00099  * Get the samples available from specific position in circular array.
00100  */
00101 guint da_getLeftSamplesFromPos (DoubleArray_T *dArray, guint index);
00102 
00103 /*
00104  * Debug : Dump the values of the pointer.
00105  */
00106 void darray_printFields (DoubleArray_T *dArray);
00107 
00108 #endif /* __DOUBLE_ARRAY_H__ */
Framework Home Page.

Beware !! TSP wave is coming...