| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

mem_allocator.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26
27 #ifndef MEM_ALLOCATOR_HPP
28 #define MEM_ALLOCATOR_HPP
29
30 #include "../my_config.h"
31 #include "erreurs.hpp"
32
33 namespace libdar
34 {
35
36
39
41 class mem_manager;
42
44
45 class mem_allocator
46 {
47 public:
48 mem_allocator(mem_manager *ptr) { if(ptr == nullptr) throw SRC_BUG; manager = ptr; };
49 mem_allocator(const mem_allocator & ref) { throw SRC_BUG; };
50 const mem_allocator & operator = (const mem_allocator & ref) { throw SRC_BUG; };
51 virtual ~mem_allocator() {};
52
54 virtual void release(void *ptr) = 0;
55
57 virtual U_I max_percent_full() const = 0;
58
59 protected:
60 mem_manager & get_manager() { return *manager; };
61
62 private:
63 mem_manager *manager;
64 };
65
66
67
69
70 class mem_manager
71 {
72 public:
73 virtual ~mem_manager() {};
74
76 virtual void push_to_release_list(mem_allocator *ref) = 0;
77 };
78
79
81
82 } // end of namespace
83
84 #endif
libdar::mem_allocator::release
virtual void release(void *ptr)=0
this is the interface to use to release a memory block owned by this mem_allocator ...
libdar::mem_manager
generic interface of memory managers that create and delete mem_allocator objects depending on reques...
Definition: mem_allocator.hpp:70
libdar::mem_manager::push_to_release_list
virtual void push_to_release_list(mem_allocator *ref)=0
this is for the mem_allocator to inform its mem_manager that it has all its block released ...
libdar::mem_allocator
generic interface of objects that need to be informed that a memory block they manage has been releas...
Definition: mem_allocator.hpp:45
erreurs.hpp
contains all the excetion class thrown by libdar
libdar::mem_allocator::max_percent_full
virtual U_I max_percent_full() const =0
returns the maximum occupation reached for that object (used for debugging purposes) ...
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47