Disk ARchive  2.5.2
Full featured and portable backup and archiving tool
mem_allocator.hpp
Go to the documentation of this file.
00001 /*********************************************************************/
00002 // dar - disk archive - a backup/restoration program
00003 // Copyright (C) 2002-2052 Denis Corbin
00004 //
00005 // This program is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU General Public License
00007 // as published by the Free Software Foundation; either version 2
00008 // of the License, or (at your option) any later version.
00009 //
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 // to contact the author : http://dar.linux.free.fr/email.html
00020 /*********************************************************************/
00021 
00025 
00026 
00027 #ifndef MEM_ALLOCATOR_HPP
00028 #define MEM_ALLOCATOR_HPP
00029 
00030 #include "../my_config.h"
00031 #include "erreurs.hpp"
00032 
00033 namespace libdar
00034 {
00035 
00036 
00039 
00041     class mem_manager;
00042 
00044 
00045     class mem_allocator
00046     {
00047     public:
00048     mem_allocator(mem_manager *ptr) { if(ptr == nullptr) throw SRC_BUG; manager = ptr; };
00049     mem_allocator(const mem_allocator & ref) { throw SRC_BUG; };
00050     const mem_allocator & operator = (const mem_allocator & ref) { throw SRC_BUG; };
00051     virtual ~mem_allocator() {};
00052 
00054     virtual void release(void *ptr) = 0;
00055 
00057     virtual U_I max_percent_full() const = 0;
00058 
00059     protected:
00060     mem_manager & get_manager() { return *manager; };
00061 
00062     private:
00063     mem_manager *manager;
00064     };
00065 
00066 
00067 
00069 
00070     class mem_manager
00071     {
00072     public:
00073     virtual ~mem_manager() {};
00074 
00076     virtual void push_to_release_list(mem_allocator *ref) = 0;
00077     };
00078 
00079 
00081 
00082 } // end of namespace
00083 
00084 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines