00001
00008 #ifndef _DRMS_SEGMENT_H
00009 #define _DRMS_SEGMENT_H
00010
00011 #include "drms_types.h"
00012 #include "drms.h"
00013 #include "drms_array.h"
00014
00015
00016
00017
00018
00019
00020
00021
00025 #define name2seg(rec, name) drms_segment_lookup(rec, name)
00026
00029 #define num2seg(rec, num) drms_segment_lookupnum(rec, num)
00030
00034
00035
00046 DRMS_Segment_t *drms_segment_lookup(DRMS_Record_t *record, const char *segname);
00047
00048
00058 DRMS_Segment_t *drms_segment_lookupnum(DRMS_Record_t *record, int segnum);
00059
00060
00061 DRMS_Segment_t *drms_segment_lookupindex(DRMS_Record_t *rec, int index, int followLink);
00062
00066
00067
00084 HContainer_t *drms_create_segment_prototypes(DRMS_Record_t *target,
00085 DRMS_Record_t *source,
00086 int *status);
00087
00088
00103 HContainer_t *drms_segment_createinfocon(DRMS_Env_t *drmsEnv,
00104 const char *seriesName,
00105 int *status);
00106
00114 void drms_segment_destroyinfocon(HContainer_t **info);
00115
00116
00117
00121
00122
00128 void drms_segment_print(DRMS_Segment_t *seg);
00135 void drms_segment_fprint(FILE *segfile, DRMS_Segment_t *seg);
00136
00137
00138
00158 void drms_segment_filename(DRMS_Segment_t *seg, char *filename);
00159
00160
00173 long long drms_segment_size(DRMS_Segment_t *seg, int *status);
00174
00175
00185 int drms_segment_segsmatch(const DRMS_Segment_t *s1, const DRMS_Segment_t *s2);
00186
00187
00188
00189
00190
00194
00195
00204 int drms_segment_setdims(DRMS_Segment_t *seg, DRMS_SegmentDimInfo_t *di);
00205
00206
00216 int drms_segment_getdims(DRMS_Segment_t *seg, DRMS_SegmentDimInfo_t *di);
00217
00218
00219
00223
00224
00244 void drms_segment_autoscale(DRMS_Segment_t *seg,
00245 DRMS_Array_t *arr,
00246 double *autobzero,
00247 double *autobscale);
00248
00249
00257 void drms_segment_setblocksize(DRMS_Segment_t *seg, int *blksz);
00258
00259
00270 void drms_segment_getblocksize(DRMS_Segment_t *seg, int *blksz);
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00299
00300
00319 FILE *drms_segment_fopen(DRMS_Segment_t *seg, const char *newfilename, int append, int *status);
00320
00332 DRMS_Array_t *drms_segment_read(DRMS_Segment_t *seg, DRMS_Type_t type,
00333 int *status);
00346 DRMS_Array_t *drms_segment_readslice(DRMS_Segment_t *seg, DRMS_Type_t type,
00347 axislen_t *start, axislen_t *end, int *status);
00348
00358 int drms_segment_fclose(FILE *fptr);
00359
00360
00361
00362
00421 int drms_segment_write(DRMS_Segment_t *seg, DRMS_Array_t *arr, int autoscale);
00422
00423 int drms_segment_writewithkeys(DRMS_Segment_t *seg, DRMS_Array_t *arr, int autoscale);
00424
00437 int drms_segment_writeslice(DRMS_Segment_t *seg,
00438 DRMS_Array_t *arr,
00439 axislen_t *start,
00440 axislen_t *end,
00441 int autoscale);
00442
00443 int drms_segment_writeslice_ext(DRMS_Segment_t *seg,
00444 DRMS_Array_t *arr,
00445 axislen_t *start,
00446 axislen_t *end,
00447 int *finaldims,
00448 int autoscale);
00449
00450
00451
00452
00463 int drms_segment_write_from_file(DRMS_Segment_t *seg, const char *infile);
00464
00465
00466
00467
00468 static inline int drms_segment_getnaxis(DRMS_Segment_t *seg)
00469 {
00470 return seg->info->naxis;
00471 }
00472
00473 static inline int drms_segment_ranksort(const void *he1, const void *he2)
00474 {
00475 DRMS_Segment_t *s1 = (DRMS_Segment_t *)hcon_getval(*((HContainerElement_t **)he1));
00476 DRMS_Segment_t *s2 = (DRMS_Segment_t *)hcon_getval(*((HContainerElement_t **)he2));
00477
00478 XASSERT(s1 && s2);
00479
00480 return (s1->info->segnum < s2->info->segnum) ? -1 : (s1->info->segnum > s2->info->segnum ? 1 : 0);
00481 }
00482
00483 DRMS_Segment_t *drms_template_segment_followlink(DRMS_Segment_t *srcseg, int *statret);
00484
00485 #endif
00486
00487