memory_manager.h

Go to the documentation of this file.
00001 /*****************************************************************************/
00002 /*!
00003  * \file memory_manager.h
00004  * 
00005  * Author: Sergey Berezin
00006  * 
00007  * Created: Thu Apr  3 16:47:14 2003
00008  *
00009  * <hr>
00010  * Copyright (C) 2003 by the Board of Trustees of Leland Stanford
00011  * Junior University and by New York University. 
00012  *
00013  * License to use, copy, modify, sell and/or distribute this software
00014  * and its documentation for any purpose is hereby granted without
00015  * royalty, subject to the terms and conditions defined in the \ref
00016  * LICENSE file provided with this distribution.  In particular:
00017  *
00018  * - The above copyright notice and this permission notice must appear
00019  * in all copies of the software and related documentation.
00020  *
00021  * - THE SOFTWARE IS PROVIDED "AS-IS", WITHOUT ANY WARRANTIES,
00022  * EXPRESSED OR IMPLIED.  USE IT AT YOUR OWN RISK.
00023  * 
00024  * <hr>
00025  * 
00026  * Class MemoryManager: allocates/deallocates memory for objects of a
00027  * requested size.  Some instanced of this class may be specialized to
00028  * a specific object size, and the actual memory may be allocated in
00029  * big chunks, for efficiency.
00030  *
00031  * Typical use of this class is to create 
00032  * MemoryManager* mm = new MemoryManagerChunks(sizeof(YourClass)); 
00033  * where YourClass has operators new and delete redefined:
00034  * void* YourClass::operator new(size_t size, MemoryManager* mm)
00035  * { return mm->newData(size); }
00036  * void YourClass::delete(void*) { } // do not deallocate memory here
00037  * Then, create objects with obj = new(mm) YourClass(), and destroy them with
00038  * delete obj; mm->deleteData(obj);
00039  */
00040 /*****************************************************************************/
00041 
00042 #ifndef _CVC_lite__memory_manager_h
00043 #define _CVC_lite__memory_manager_h
00044 
00045 namespace CVCL {
00046 
00047 class MemoryManager {
00048  public:
00049   // Destructor
00050   virtual ~MemoryManager() { }
00051 
00052   virtual void* newData(size_t size) = 0;
00053 
00054   virtual void deleteData(void* d) = 0;
00055 }; // end of class MemoryManager
00056 
00057 }
00058 
00059 #endif

Generated on Thu Apr 13 16:57:32 2006 for CVC Lite by  doxygen 1.4.4