vtf-logo

PackedGridDataBucket.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 #ifndef _included_PackedGridDataBucket_h
00004 #define _included_PackedGridDataBucket_h
00005 
00011 #include "DAGHParams.h"
00012 #include "DAGHDefaults.h"
00013 
00014 #include "DAGHSfc.h"
00015 #include "BBox.h"
00016 
00017 #include "PackedDataBucketVoid.h"
00018 #include "ObjectCounter.h"
00019 
00020 #include <iosfwd>
00021 #include <cstring>
00022 
00023 /* Bucket/Message Types */
00024 #define DAGHSingle      (1)
00025 #define DAGHPacked      (2)
00026 
00027 #ifndef DAGHBktGFNameWidth
00028 #define DAGHBktGFNameWidth      (32)
00029 #endif
00030 
00035 struct gdhdr
00036   {
00037    friend std::ostream& operator<<(std::ostream& os, const struct gdhdr& hdr);
00038 
00040    short int type;
00042    short int owner;     
00044    short unsigned gfid;
00046    short gfdatatype;
00048    short gfstaggertype;
00050    char gfname[DAGHBktGFNameWidth];
00052    BBox bbox;
00054    short int time;
00056    int time_value;
00058    char physical_time[sizeof(double)];
00060    short int level;     
00062    short int index;     
00063 
00064    inline gdhdr() {};
00065    gdhdr(struct gdhdr& other);
00066 
00067    gdhdr(const BBox& bb, 
00068          const unsigned gf, const int gft, const int gfs, const char* gfn,
00069          const int t, const int tv, const int l, const int index,
00070          const int who, const int type);
00071 
00072    static unsigned gdbsize(const unsigned dsize);
00073   };
00074 
00075 #define GridDataBucketVoidNULL  ((GridDataBucketVoid *)0)
00076 
00087 class GridDataBucketVoid : public DataBucketVoid, public ObjectCounter
00088   {
00089    int bkttype;
00090 
00091 private:
00092    GridDataBucketVoid(const GridDataBucketVoid&);       
00093    void operator = (const GridDataBucketVoid&);
00094 
00095 public:
00096    inline GridDataBucketVoid* alias()
00097         { return((GridDataBucketVoid *) ObjectCounter::alias()); }
00098 
00099    GridDataBucketVoid(const BBox& bb, const unsigned gf,
00100            const int time, const int time_value, const int level, const int index,
00101            const int who, const unsigned datasize, const int type);
00102 
00103    GridDataBucketVoid(const BBox& bb, const unsigned gf, const int gfdtype, 
00104                       const int gfstype, const char* gfname, const int time, 
00105                       const int time_value, const int level, const int index,
00106                        const int who, const unsigned datasize, const int type);
00107 
00108    inline GridDataBucketVoid(const int n, unsigned* dsizes, const int type)
00109         : DataBucketVoid(sizeof(struct gdhdr), dsizes, n), bkttype(type) {}
00110 
00111    void add(const BBox& bb, const unsigned gf, const int time, const int time_value,  
00112             const int level, const int index, const int who, const int n);
00113 
00114    void add(const BBox& bb, const unsigned gf, const int gfdtype, const int gfstype,
00115             const char* gfname, const int time, const int time_value, const int level,  
00116             const int index, const int who, const int n);
00117 
00118    inline GridDataBucketVoid(const void* package)
00119          :DataBucketVoid((const union drecord *) package) 
00120    { bkttype = ((struct gdhdr *) DataBucketVoid::head())->type; }
00121 
00122    inline GridDataBucketVoid(void* package)
00123         :DataBucketVoid((union drecord *) package) 
00124    { bkttype = ((struct gdhdr *) DataBucketVoid::head())->type; }
00125 
00126    inline GridDataBucketVoid(const void* package, const int n)
00127          :DataBucketVoid((const union drecord *) package, n) 
00128    { bkttype = ((struct gdhdr *) DataBucketVoid::head())->type = DAGHSingle; }
00129 
00130    GridDataBucketVoid(const struct gdhdr& other, const unsigned datasize);
00131 
00132    inline int type() const { return (bkttype); }
00133 
00134    inline struct gdhdr *head()
00135         { return ( (struct gdhdr *) DataBucketVoid::head() ); }
00136    inline struct gdhdr *head(const int i)
00137         { return ( (struct gdhdr *) DataBucketVoid::head(i) ); }
00138 
00139    inline BBox const &bbox() const
00140         { return (((struct gdhdr *) DataBucketVoid::head())->bbox); }
00141    inline BBox const &bbox(const int i) const
00142         { return (((struct gdhdr *) DataBucketVoid::head(i))->bbox); }
00143 
00144    inline short int owner() const
00145         { return (((struct gdhdr *) DataBucketVoid::head())->owner); }
00146    inline short int owner(const int i) const
00147         { return (((struct gdhdr *) DataBucketVoid::head(i))->owner); }
00148 
00149    inline short int time() const
00150         { return ( ((struct gdhdr *) DataBucketVoid::head())->time); }
00151    inline short int time(const int i) const
00152         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->time); }
00153 
00154    inline short int time_value() const
00155         { return ( ((struct gdhdr *) DataBucketVoid::head())->time_value); }
00156    inline short int time_value(const int i) const
00157         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->time_value); }
00158 
00159    inline short int level() const
00160         { return ( ((struct gdhdr *) DataBucketVoid::head())->level); }
00161    inline short int level(const int i) const
00162         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->level); }
00163 
00164    inline short int index() const
00165         { return ( ((struct gdhdr *) DataBucketVoid::head())->index); }
00166    inline short int index(const int i) const
00167         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->index); }
00168 
00169    inline short unsigned gfid() const
00170         { return ( ((struct gdhdr *) DataBucketVoid::head())->gfid); }
00171    inline short unsigned gfid(const int i) const
00172         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfid); }
00173 
00174    inline short gfdatatype() const
00175         { return ( ((struct gdhdr *) DataBucketVoid::head())->gfdatatype); }
00176    inline short gfdatatype(const int i) const
00177         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfdatatype); }
00178 
00179    inline short gfstaggertype() const
00180         { return ( ((struct gdhdr *) DataBucketVoid::head())->gfstaggertype); }
00181    inline short gfstaggertype(const int i) const
00182         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfstaggertype); }
00183 
00184    inline char *gfname() const
00185         { return ( ((struct gdhdr *) DataBucketVoid::head())->gfname); }
00186    inline char *gfname(const int i) const
00187         { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfname); }
00188 
00189    inline void setgfname(const char *name) const
00190    { std::strncpy(((struct gdhdr *)DataBucketVoid::head())->gfname,
00191      name,DAGHBktGFNameWidth-1); }
00192    inline void setgfname(const char *name, const int i) const
00193    { std::strncpy(((struct gdhdr *)DataBucketVoid::head(i))->gfname,
00194      name,DAGHBktGFNameWidth-1); }
00195   };
00196 
00205 template <class Type>
00206 class GridDataBucket: public GridDataBucketVoid
00207   {
00208 private:
00209    GridDataBucket(const GridDataBucket<Type>&); 
00210    void operator = (const GridDataBucket<Type>&);
00211 
00212 public:
00213    inline GridDataBucket(const BBox& bb, const unsigned gf,
00214           const int time, const int time_value, const int level, const int index, const int who, 
00215           const int type=DAGHSingle)
00216         : GridDataBucketVoid(bb, gf, time, time_value, level, index, who, 
00217                              sizeof(Type), type) {}
00218 
00219    inline GridDataBucket(const BBox& bb, const unsigned gf, 
00220           const int gfdtype, const int gfstype, const char* gfname,
00221           const int time, const int time_value, const int level, const int index, const int who, 
00222           const int type=DAGHSingle)
00223         : GridDataBucketVoid(bb, gf, gfdtype, gfstype, gfname, time, time_value,  
00224                              level, index, who, sizeof(Type), type) {}
00225 
00226    inline GridDataBucket(const void* package) 
00227         : GridDataBucketVoid(package) {}
00228 
00229    inline GridDataBucket(void* package) 
00230         : GridDataBucketVoid(package) {}
00231 
00232    inline GridDataBucket(const void* package, const int n) 
00233         : GridDataBucketVoid(package, n) {}
00234 
00235    inline GridDataBucket(const int n, unsigned* dsizes, 
00236                          const int type) //=DAGHSingle)
00237         : GridDataBucketVoid(n, dsizes, type) {}
00238 
00239    inline Type const *data() const
00240         { return ( (Type *) DataBucketVoid::data() ); }
00241    inline Type *data(void)
00242         { return ( (Type *) DataBucketVoid::data() ); }
00243 
00244    inline Type const *data(const int i) const
00245         { return ( (Type *) DataBucketVoid::data(i) ); }
00246    inline Type *data(const int i)
00247         { return ( (Type *) DataBucketVoid::data(i) ); }
00248   };
00249 
00250 #endif

Generated on Fri Aug 24 13:00:29 2007 for AMROC's Hierachical Data Structures - by  doxygen 1.4.7