Main Page   Class Hierarchy   Compound List   File List   Compound Members  

RIPCObject.h

00001 #ifndef __RIPC_OBJECT_H__
00002 #define __RIPC_OBJECT_H__
00003 
00004 #include <string.h>
00005 #include <assert.h>
00006 
00007 #include "RIPCdef.h"
00008 
00009 class RIPCPrimitive;
00010 
00011 class RIPC_DLL_ENTRY RIPCObject {    
00012   public:
00013     void*  data;
00014     size_t size;
00015 
00016     RIPCObject() 
00017     { 
00018         data = NULL;
00019         size = 0;
00020         deallocator = NULL;
00021     }
00022 
00023     RIPCObject(void* buf, size_t bufSize) 
00024     { 
00025         data = buf;
00026         size = bufSize;
00027         deallocator = NULL;
00028     }
00029 
00030     void assign(RIPCObject const& cp) 
00031     { 
00032         if (data == NULL) { 
00033             data = cp.data;
00034             size = cp.size;
00035             deallocator = cp.deallocator;
00036             container = cp.container;
00037         } else { 
00038             assert(size >= cp.size);
00039             size = cp.size;
00040             memcpy(data, cp.data, size);
00041         }
00042     }
00043 
00044     void deallocate() const 
00045     { 
00046         if (deallocator != NULL) {
00047             (*deallocator)(*this);
00048         }
00049     }
00050 
00051     void (*deallocator)(RIPCObject const& obj);
00052     RIPCPrimitive* container; // container to which object belongs
00053 };
00054 
00055 #endif

Generated on Tue Jul 8 20:27:56 2003 for RIPC by doxygen1.2.15