rasdaman complete source
storageman.hh
Go to the documentation of this file.
1 /*
2  * This file is part of rasdaman community.
3  *
4  * Rasdaman community is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Rasdaman community is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Copyright 2003 - 2010 Peter Baumann / rasdaman GmbH.
18  *
19  * For more information please see <http://www.rasdaman.org>
20  * or contact Peter Baumann via <baumann@rasdaman.com>.
21 */
22 
36 #ifndef _R_STORAGE_MAN_
37 #define _R_STORAGE_MAN_
38 
39 
40 // for size_t
41 #include <stdlib.h>
42 
43 #include "raslib/error.hh"
44 
45 
46 
47 //@ManMemo: Module {\bf raslib}
48 
49 /*@Doc:
50  r_Storage_Man provides an interface to a pair of heap management
51  functions for allocating and freeing blocks. I want to be able
52  to use constructs like sman1 = sman2, therefore I can't use
53  virtual functions to implement this.
54 */
55 
57 {
58 public:
59 
61  typedef void *(*storage_man_alloc)( size_t );
62  typedef void (*storage_man_free)( void *data );
63 
65  r_Storage_Man( void );
69  r_Storage_Man( const r_Storage_Man &src );
71  ~r_Storage_Man( void );
75  r_Storage_Man &operator=( const r_Storage_Man &src );
77  void *storage_alloc( size_t size ) const throw(r_Error);
79  void storage_free( void *data ) const;
80 
81 
82 protected:
86 };
87 
88 
89 /*@Doc:
90  r_Storage_Man_C implements C-style allocation using malloc/free
91 */
92 
94 {
95 public:
97  r_Storage_Man_C( void );
99  ~r_Storage_Man_C( void );
100 };
101 
102 
103 /*@Doc:
104  r_Storage_Man_CPP implements C++-style allocation using new/delete
105 */
106 
108 {
109 public:
111  r_Storage_Man_CPP( void );
113  ~r_Storage_Man_CPP( void );
114 };
115 
116 #endif
Definition: error.hh:88
Definition: storageman.hh:56
~r_Storage_Man(void)
destructor
Definition: storageman.hh:107
storage_man_free myfree
Definition: storageman.hh:85
void *(* storage_man_alloc)(size_t)
types of storage management functions
Definition: storageman.hh:61
storage_man_alloc myalloc
the storage functions
Definition: storageman.hh:84
void * storage_alloc(size_t size) const
allocation
~r_Storage_Man_CPP(void)
destructor
r_Storage_Man(void)
default constructor, switches to c-style allocation
~r_Storage_Man_C(void)
default destructor
void set_storage_functions(storage_man_alloc a, storage_man_free f)
setting the storage functions
void storage_free(void *data) const
deallocation
Definition: storageman.hh:93
void(* storage_man_free)(void *data)
Definition: storageman.hh:62
r_Storage_Man & operator=(const r_Storage_Man &src)
assignment
r_Storage_Man_CPP(void)
default constructor
r_Storage_Man_C(void)
default constructor