Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsDataAccessor.h

Go to the documentation of this file.
00001 /*
00002  * $Id: dsDataAccessor.h,v 1.7 2004/06/10 10:58:17 dsamersoff Exp $
00003  */
00004 
00005 #ifndef dsDataAccessor_h 
00006 #define dsDataAccessor_h 
00007 
00008 #ifdef HAVE_CONFIG_H
00009 # include <config.h>
00010 #endif
00011 
00012 #include <dsSmartException.h>
00013 #include <dsutil.h>
00014 
00015 DECLARE_EXCEPTION(dsDataAccessor);
00016 
00021 class dsDataAccessorItem 
00022 {
00023 public:
00024     void *body;
00025 
00026     dsDataAccessorItem() { body = 0; }
00027     dsDataAccessorItem(void *xbody) { body = xbody; }
00028 };
00029 
00033 class dsDataPair
00034 {
00035 
00036    bool _copy_value;
00037 
00038 public:
00039    char *key;
00040    void *val;
00041    size_t vsize;
00042       
00043 
00044    dsDataPair()
00045     { key = 0;
00046       val = 0; 
00047       vsize = 0;
00048     }
00049 
00050    dsDataPair(const char *xkey, void *xval)
00051     { 
00052       key = ds_strdup(xkey); 
00053       val = xval; 
00054       vsize = 0;
00055       _copy_value = false; 
00056       
00057     }
00058 
00059    dsDataPair(const char *xkey, const char *xval)
00060     { 
00061       key = ds_strdup(xkey); 
00062       val = ds_strdup(xval);
00063       vsize = strlen(xval)+1;
00064       _copy_value = true; 
00065       
00066     }
00067 
00068    dsDataPair(const char *xkey, const void *xval, size_t size)
00069     { 
00070       key = ds_strdup(xkey); 
00071       val = new char[size];
00072       memmove(val,xval,size);
00073       vsize = size;
00074 
00075       _copy_value = true; 
00076       
00077     }
00078 
00079 
00080 
00081    dsDataPair(const char *xkey)
00082     { 
00083       key = ds_strdup(xkey); 
00084       val = 0; 
00085       vsize = 0;
00086       _copy_value = false; 
00087     }
00088 
00089 
00090    ~dsDataPair()
00091     {  if ( key )
00092                 delete[] key;
00093        if (val && _copy_value)
00094                delete (char *)val;
00095     }  
00096 
00097 };
00098 
00099 
00105 class dsDataAccessor 
00106 {
00107 
00108 protected:
00109 
00110    enum DACleanupMode 
00111    {
00112      cmPASSIVE, 
00113      cmPURGE    
00114    };
00115 
00119    DACleanupMode _purge; 
00120 
00124    dsDataAccessor(DACleanupMode purge)
00125    { _purge = purge;
00126    }
00127 
00132     virtual  void *insert(void * a, bool replace) = 0;
00133     
00137     virtual void *remove(void * a) = 0;
00138 
00142     virtual void* seek(void *a) = 0;
00143 
00147     virtual void *walk(){ return 0; }
00148 };
00149 
00150 #endif

Generated on Mon May 16 18:26:57 2005 for libdms4 by doxygen1.3-rc2