CudappMemoryBase.h

Go to the documentation of this file.
00001 #ifndef CUDAPPMEMORYBASE_H_
00002 #define CUDAPPMEMORYBASE_H_
00003 
00004 #include "CudappSupportModule.h"
00005 #include <stdlib.h>
00006 #include <stddef.h>
00007 #include <ostream>
00008 namespace Cudapp
00009 {
00010     class Memory;
00011     class DeviceMemory;
00012     class LocalMemory;
00013     class HostMemory;
00014     class MemoryArray;
00015     class MemoryPitch;
00016 
00017     class CUDA_SUPPORT_EXPORT MemoryBase
00018     {
00019         friend class Memory;
00020     public:
00021         virtual ~MemoryBase();
00022 
00024         virtual void Free() = 0;
00025         virtual void MemSet(int value) = 0;
00026         size_t GetSize() const { return Size; }
00027 
00029         typedef enum {
00030             MemoryOnDevice, 
00031             MemoryOnHost,  
00032         } MemoryLocation;
00033 
00034         MemoryLocation GetMemoryLocation() const { return this->Location; }
00035 
00036         virtual bool CopyTo(void* dst, size_t byte_count, size_t offset = 0, MemoryLocation dst_loc = MemoryOnHost) const = 0;
00037         virtual bool CopyFrom(const void* src, size_t byte_count, size_t offset = 0, MemoryLocation src_loc = MemoryOnHost) = 0;
00038 
00040         virtual bool CopyTo(MemoryBase* dst) const { return false; /* To give you a sense what this does:  dst->CopyFromInternal(this); */ }
00041 
00042         virtual void PrintSelf(std::ostream &os) const;
00043 
00044     protected:
00045         MemoryBase();
00046         MemoryBase(const MemoryBase&);
00047         MemoryBase& operator=(const MemoryBase&);
00048 
00049         size_t Size;    
00050         MemoryLocation Location;
00051 
00052         virtual bool CopyFromInternal(const Memory* src) { return false; } 
00053         virtual bool CopyFromInternal(const MemoryPitch* src) { return false; } 
00054         virtual bool CopyFromInternal(const MemoryArray* src) { return false; } 
00055     };
00056 
00057     inline std::ostream& operator<<(std::ostream& os, const MemoryBase& in){
00058         in.PrintSelf(os);
00059         return os; 
00060     }
00061 }
00062 #endif /*CUDAPPMEMORYBASE_H_*/

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1