F5F.h

00001 /*
00002 //
00003 // $Id: F5F.h,v 1.42 2008/03/19 21:21:43 werner Exp $
00004 //
00005 */
00006 
00007 #ifndef __F5F_H
00008 #define __F5F_H
00009 
00010 #include <F5/F5L.h>
00011 #include <F5/F5Bchart.h>
00012 #include <F5/F5Path.h>
00013 
00014 #ifdef  __cplusplus
00015 extern "C"
00016 {
00017 #endif
00018 
00022 F5_API int F5Fset_metric_unit_description(F5Path*f, const char*unit);
00023         
00025 F5_API int F5Fis_group(const F5Path*);
00026 
00027 F5_API int F5LTset_dataspace(F5Path*f, int rank, hsize_t*dims);
00028 
00029 F5_API int F5LTexpand_dataspace(F5Path*f, int rank, hsize_t*dims);
00030 
00031 F5_API int F5Fexpand_dataspace(F5Path*fpath, int rank, hsize_t*Dims);
00032 
00066 F5_API hid_t F5file_type(F5Path*fpath, hid_t fieldtype);
00067 
00068 
00072 F5_API void F5close(F5Path*f);
00073 F5_API void F5closep(F5Path**f);
00074 
00087 F5_API int F5Fopen(F5Path*f, const char*fieldname);
00088 
00091 F5_API F5Path*F5FopenMostRecentSlice(hid_t File_id, double*t,
00092                                      const char*gridname,
00093                                      const char*fieldname,
00094                                      const char*coordinate_system); 
00095         
00099 F5_API void F5Fclose(F5Path*f);
00100 
00113 F5_API hid_t F5Fgrab(F5Path*f);
00114         
00115 
00120 F5_API hid_t F5Fget_type(F5Path*f);
00121 
00126 F5_API hid_t F5Tget_space(F5Path*f);
00127 
00140 F5_API hsize_t*F5Tpermute_dimensions(F5Path*fpath,
00141                                      int rank,
00142                                      hsize_t*target_dims,
00143                                      const hsize_t*source_dims);        
00144 
00167 F5_API int F5Tget_extent(F5Path*f, hsize_t*dims, int maxDims);
00168 
00174 F5_API int F5Tget_index_depth(F5Path*f, int*result);
00175 
00177 F5_API int F5LTget_skeleton_dimensionality(hid_t Top_hid);
00178 
00180 F5_API int F5Tget_refinement_level(F5Path*f, hsize_t*dims, int maxDims);
00181 
00199 F5_API int F5Fget_range(F5Path*f, void*min, void*max, hid_t memtype_id);
00200 
00205 F5_API int F5Fset_range(F5Path*f, const void*min, const void*max);
00206 
00216 F5_API int F5Fset_fragment_range(F5Path*f, const char*fragment_name, const void*min, const void*max);
00220 F5_API int F5Fget_fragment_range(F5Path*f, const char*fragment_name, void*min, void*max, hid_t mem_type_id);
00221         
00225 F5_API int F5Fget_average(F5Path*f,       void*avg); 
00226 F5_API int F5Fset_average(F5Path*f, const void*avg);
00227 
00232 F5_API int F5Fget_deviation(F5Path*f,       void*dev); 
00233 F5_API int F5Fset_deviation(F5Path*f, const void*dev);
00234 
00268 F5_API int F5Fcreate(F5Path*fpath, const char*fieldname, int dimension, hsize_t*dims,
00269                      hid_t fieldtype, hid_t property_id);
00270 
00271 enum F5ErrorCode_type
00272 {
00274         F5_SUCCESS       = 0,
00275 
00277         F5ERROR_INVALID_FPATH = -1,
00278 
00280         F5ERROR_INCONSISTENT_DATASPACE = -2,
00281 
00282         F5ERROR_ALREADY_EXISTS = -10,
00283         
00285         F5ERROR_COMPOUND_EXPECTED     = -30,
00287         F5ERROR_COMPONENTMAP_EXPECTED = -31,
00289         F5ERROR_COMPONENTMAP_INVALID  = -32,
00290         
00291         F5ERROR_NONSPECIFIED = -100
00292 };
00293 
00294 typedef enum F5ErrorCode_type F5ErrorCode;
00295 
00300 F5_API const char*F5Fwhatsup(F5ErrorCode);
00301 
00302 
00337 F5_API F5ErrorCode F5Fwrite(F5Path*fpath, const char*fieldname,
00338                             int dimension, hsize_t*dims,
00339                             hid_t fieldtype, hid_t memtype, const void * dataPtr,
00340                             hid_t property_id);
00341 
00350 F5_API F5ErrorCode F5FwriteIMAGE(F5Path*fpath, const char*fieldname,
00351                                  int dimension, hsize_t*dims,
00352                                  hid_t fieldtype, hid_t memtype, const void * dataPtr,
00353                                  hid_t property_id);
00354         
00355 F5_API F5ErrorCode F5Fwrite_1D(F5Path*fpath, const char*fieldname,
00356                                hsize_t nElements, hid_t fieldtype, hid_t memtype,
00357                                const void *dataPtr, hid_t property_id);
00358 
00366 F5_API int F5Fwrites(F5Path*fpath, const char*fieldname,
00367                      int dimension, hsize_t*dims,
00368                      hid_t fieldtype, hid_t memtype, const void ** dataPtr,
00369                      hid_t property_id);
00370 
00383 F5_API F5ErrorCode F5FwriteX(F5Path*fpath, const char*fieldname,
00384                              int rank, const hsize_t dims[],
00385                              hid_t fieldtype, hid_t memtype, 
00386                              const void *const dataPtr[], const int polynom_order[],
00387                              const int component_map[],
00388                              hid_t property_id);
00389 
00390 
00391 F5_API void F5FevalX(double*result, int Mrank, const int index[],
00392                      int components, const double*const polynomials[], const int polynom_order[],
00393                      const int component_map[]);
00394         
00395 
00403 F5_API int F5Fwrite_linear(F5Path*fpath, const char*fieldname,
00404                            int dimension, hsize_t*dims,
00405                            hid_t fieldtype, const void * base, const void*delta);
00406 
00407 
00454 F5_API int F5Fwrite_fraction(F5Path*fpath, const char*fieldname,
00455                              int rank, const hsize_t*full_dims, const hsize_t*fragment_dims,
00456                              hid_t fieldtype, hid_t memtype, const void * dataPtr,
00457                              const hsize_t*datastart,
00458                              const hsize_t*start_border, const hsize_t*end_border,
00459                              const char*fraction_name, hid_t property_id);
00460         
00486 F5_API int F5FSwrite_fraction(F5Path*fpath, const char*fieldname,
00487                               int rank, const hsize_t*full_dims, const hsize_t*fragment_dims,
00488                               hid_t fieldtype, hid_t memtype, const void *const* dataPtr,
00489                               const hsize_t*datastart, 
00490                               const hsize_t*start_border, const hsize_t*end_border,
00491                               const char*fraction_name, hid_t property_id,
00492                               int AllowFullCoverage);
00493 
00513 F5_API int F5Fwrite_linear_fraction(F5Path*fpath, const char*fieldname,
00514                                     int rank, const hsize_t*full_dims, const hsize_t*fragment_dims,
00515                                     hid_t fieldtype, const void * base, const void*delta,
00516                                     const hsize_t*datastart, 
00517                                     const char*fraction_name);
00523 F5_API ArrayType F5Fget_field_enum(const F5Path*fpath, const char*fieldname,
00524                                    int*major_version, int*minor_version, int*release_version);
00525         
00530 F5_API int F5Fis_linear(F5Path*fpath, const char*fieldname);
00531 
00532 F5_API int F5Fis_fragmented(F5Path*fpath, const char*fieldname);
00533 F5_API int F5Fis_separatedcompound(F5Path*fpath, const char*fieldname);
00534 
00544 F5_API int F5Fread_linear(F5Path*fpath,
00545                           hsize_t*dims,
00546                           hid_t fieldtype, void * base, void*delta);
00547 
00548 F5_API int F5Fread_linearo(F5Path*fpath, const char*fieldname,
00549                           hsize_t*dims,
00550                           hid_t fieldtype, void * base, void*delta);
00551 
00552         
00553 #ifdef  __cplusplus
00554 }    /* extern "C" */
00555 
00556 /* Experimental optional header-only C++ interface */
00557 #ifdef  ENABLE_F5_CPLUSPLUS
00558 namespace F5
00559 {
00560 
00561 class   Path
00562 {
00563         struct  pcnt
00564         {
00565                 int     refs;
00566                 F5Path*fpath;
00567         };
00568 
00569         pcnt*p;
00570 
00571 public:
00572         F5Path*fpath()
00573         {
00574                 if (p) return p->fpath;
00575                 return 0;
00576         }
00577 
00578         Path()
00579         : p(0)
00580         {}
00581 
00582         Path(const Path&P)
00583         : p(P.p)
00584         {
00585                 if (p) p->refs++;
00586         }
00587 
00588         ~Path()
00589         {
00590                 if (!p) return;
00591                 p->refs--;
00592                 if (p->refs<1)
00593                         F5close(p->fpath);
00594         }
00595 };
00596 
00597 struct  Timeslice : Path
00598 {};
00599 
00600 struct  Grid : Timeslice
00601 {};
00602 
00603 struct  Topology : Grid
00604 {
00605         hid_t   get_space()
00606         {
00607                 return F5Tget_space(fpath());
00608         }
00609 };
00610 
00611 struct  Field;
00612 
00613 struct  Representation : Topology
00614 {
00615         Field open(const char*fieldname);
00616 
00617         int write(const char*fieldname,
00618                      int dimension, hsize_t*dims,
00619                      hid_t fieldtype, hid_t memtype, const void * dataPtr,
00620                      hid_t property_id = F5P_DEFAULT)
00621         {
00622                 return F5Fwrite(fpath(), fieldname,
00623                                 dimension, dims,
00624                                 fieldtype, memtype, dataPtr,
00625                                 property_id);
00626         }
00627         
00628         int write1D(const char*fieldname,
00629                     hsize_t nElements, hid_t fieldtype, hid_t memtype,
00630                     const void *dataPtr, hid_t property_id = F5P_DEFAULT)
00631         {
00632                 return F5Fwrite1D(fpath(), fieldname,
00633                               nElements, fieldtype, memtype,
00634                               dataPtr, property_id);
00635         }
00636 
00637         int writes(const char*fieldname,
00638                                 int dimension, hsize_t*dims,
00639                                 hid_t fieldtype, hid_t memtype, const void ** dataPtr,
00640                                 hid_t property_id)
00641         {
00642                 return F5Fwrites(fpath(), fieldname,
00643                                 dimension, dims,
00644                                 fieldtype, memtype, dataPtr,
00645                                 property_id);
00646         }
00647 
00648         int write_linear(const char*fieldname,
00649                                    int dimension, hsize_t*dims,
00650                                    hid_t fieldtype, const void * base, const void*delta)
00651         {
00652                 return F5Fwrite_linear(fpath(), fieldname,
00653                                    dimension, dims,
00654                                    fieldtype, base, delta);
00655 
00656         }
00657 
00658         int write_fraction(const char*fieldname,
00659                                      int rank, const hsize_t*full_dims, const hsize_t*fragment_dims,
00660                                      hid_t fieldtype, hid_t memtype, const void * dataPtr,
00661                                      const hsize_t*datastart, 
00662                                      const hsize_t*start_border, const hsize_t*end_border,
00663                                      const char*fraction_name, hid_t property_id)
00664         {
00665                 return F5Fwrite_fraction(fpath(), fieldname,
00666                                      rank, full_dims, fragment_dims,
00667                                      fieldtype, memtype, dataPtr,
00668                                      datastart, 
00669                                      start_border, end_border,
00670                                      fraction_name, property_id);
00671         }
00672 
00673         int Swrite_fraction(const char*fieldname,
00674                                       int rank, const hsize_t*full_dims, const hsize_t*fragment_dims,
00675                                       hid_t fieldtype, hid_t memtype, const void ** dataPtr,
00676                                       const hsize_t*datastart, 
00677                                       const hsize_t*start_border, const hsize_t*end_border,
00678                                       const char*fraction_name, hid_t property_id)
00679         {
00680 
00681                 return F5FSwrite_fraction(fpath(), fieldname,
00682                                       rank, full_dims, fragment_dims,
00683                                       fieldtype, memtype, dataPtr,
00684                                       datastart, 
00685                                       start_border, end_border,
00686                                       fraction_name, hid_t property_id);
00687         }
00688 
00689         int write_linear_fraction(const char*fieldname,
00690                                             int rank, const hsize_t*dims, const hsize_t*fragment_dims,
00691                                             hid_t fieldtype, const void * base, const void*delta,
00692                                             const hsize_t*datastart, 
00693                                             const char*fraction_name)
00694         {
00695                 return F5Fwrite_linear_fraction(fpath(), fieldname,
00696                                             rank, dims, fragment_dims,
00697                                             fieldtype, base, delta,
00698                                             datastart, 
00699                                             fraction_name);
00700         }
00701 };
00702 
00703 struct  Field : Representation
00704 {
00705         hid_t get_type() const
00706         {
00707                 return F5Fget_type(fpath());
00708         }
00709 };
00710 
00711 
00712 inline  Field Representation::open(const char*fieldname)
00713 {
00714         F5Fopen(fpath(), fieldname);
00715         return Field(*this);
00716 }
00717 
00718 
00719 }
00720 #endif /* ENABLE_F5_CPLUSPLUS */
00721 
00722 #endif
00723 
00724 #endif  /* __F5F_H */
00725