AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

PackedDataBucketVoid.h

Go to the documentation of this file.
00001 #ifndef _included_PackedDataBucketVoid_h
00002 #define _included_PackedDataBucketVoid_h
00003 
00009 #include <iostream.h>
00010 #include <assert.h>
00011 #include <memory.h>
00012 
00013 #ifdef DEBUG_PRINT_DBKT_MEMORY
00014 #include "DAGHMemoryTrace.h"
00015 #endif
00016 
00017 struct dbkthdr 
00018   { unsigned headsize; unsigned datasize; int cnt; };
00019 
00020 struct dbkthdrdata 
00021   {
00022    unsigned headsize; unsigned datasize; int cnt;
00023    unsigned data[1]; 
00024   };
00025 
00026 union drecord 
00027   {
00028    struct dbkthdr head;
00029    struct dbkthdrdata rec;
00030   };
00031    
00036 class DataBucketVoid
00037   {
00038    unsigned headsize;
00039    unsigned datasize;
00040    int cnt;
00041    unsigned *hs;
00042    unsigned *ds;
00043    union drecord *bkt;
00044 
00045 private:
00046    DataBucketVoid(const DataBucketVoid&);       
00047    void operator = (const DataBucketVoid&);
00048 
00049 public:
00050    inline DataBucketVoid(void)
00051         : headsize(0), datasize(0), cnt(0), hs(0), ds(0), bkt(0) {}
00052 
00053    DataBucketVoid(unsigned const hsize, unsigned const dsize);
00054    DataBucketVoid(unsigned *hsize, unsigned *dsize, int const n);
00055    DataBucketVoid(unsigned hsize, unsigned *dsize, int const n);
00056    DataBucketVoid(union drecord const *package);
00057    DataBucketVoid(union drecord *package);
00058    DataBucketVoid(union drecord const *package, int const n);
00059 
00060    inline ~DataBucketVoid(void) 
00061      { 
00062 
00063 #ifdef DEBUG_PRINT_DBKT_MEMORY
00064       DAGHMemoryTrace::free(sizeof(unsigned)*cnt); // hs
00065       DAGHMemoryTrace::free(sizeof(unsigned)*cnt); // ds
00066       DAGHMemoryTrace::free(sizeof(char)*(headsize+datasize));
00067 #endif
00068 
00069       if (hs) delete [] hs; 
00070       if (ds) delete [] ds;
00071       if (bkt) delete [] ((char *)bkt); 
00072      }
00073 
00074    inline int num(void) const
00075         { return (cnt); }
00076    inline int num(void) 
00077         { return (cnt); }
00078 
00079    inline void *head(void)
00080         { return ((void *) ((union drecord *)((char *)(bkt)+hs[0]))->rec.data); }
00081    inline void const *head(void) const
00082         { return ((void *) ((union drecord *)((char *)(bkt)+hs[0]))->rec.data); }
00083 
00084    inline void *head(int const i)
00085         { assert (i<cnt); 
00086           return ((void *) ((union drecord *)((char *)(bkt)+hs[i]))->rec.data); }
00087    inline void const *head(int const i) const
00088         { assert (i<cnt);
00089           return ((void *) ((union drecord *)((char *)(bkt)+hs[i]))->rec.data); }
00090 
00091    inline void *data(void)
00092         { return ((void *) ((char *)(bkt)+ds[0])); }
00093    inline void const *data(void) const
00094         { return ((void *) ((char *)(bkt)+ds[0])); }
00095 
00096    inline void *data(int const i)
00097         { assert (i<cnt);
00098           return ((void *) ((char *)(bkt)+ds[i])); }
00099    inline void const *data(int const i) const
00100         { assert (i<cnt);
00101           return ((void *) ((char *)(bkt)+ds[i])); }
00102 
00103    inline void *pack(unsigned& size)
00104         { size = headsize+datasize; return((void *) bkt); }
00105    inline void pack(void *&package, unsigned& size)
00106         { size = headsize+datasize; package = (void *) bkt; }
00107   };
00108 
00109 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04