rasdaman API
memblockvec.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 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 General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with rasdaman community. If not, see <http://www.gnu.org/licenses/>.
16 *
17 * Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
18 rasdaman GmbH.
19 *
20 * For more information please see <http://www.rasdaman.org>
21 * or contact Peter Baumann via <baumann@rasdaman.com>.
22 /
33 #ifndef _MEMORY_BLOCK_VECTOR_H_
34 #define _MEMORY_BLOCK_VECTOR_H_
35 
36 #include "raslib/mddtypes.hh"
37 
38 
39 //@ManMemo: Module {\bf raslib}
40 
41 /*@Doc:
42  Auxiliary class, realizes a set of memory blocks of equal size that can
43  be extended to any size. Used by some children of r_LinCompStream.
44 */
45 
46 class r_Memory_Block_Vector
47 {
48 public:
51  r_Memory_Block_Vector( r_Bytes bsize=4096, unsigned int gran=8 );
53  ~r_Memory_Block_Vector( void );
55  inline unsigned int get_number( void ) const
56  {
57  return numBlocks;
58  }
60  inline r_Bytes get_block_size( void ) const
61  {
62  return blockSize;
63  }
65  inline unsigned int get_granularity( void ) const
66  {
67  return granularity;
68  }
70  void* operator[]( unsigned int idx ) const;
72  void* add( void );
74  void free_data( void );
77  r_Bytes get_size( r_Bytes lastFill ) const;
80  void copy_data( void* dest, r_Bytes lastFill ) const;
81 
82 protected:
84  void** blocks;
85  unsigned int numBlocks;
86  unsigned int maxBlocks;
88  r_Bytes blockSize;
90  unsigned int granularity;
91 };
92 
93 #endif