rasdaman complete source
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 
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;
90  unsigned int granularity;
91 };
92 
93 #endif
unsigned int granularity
the granularity
Definition: memblockvec.hh:90
unsigned int get_granularity(void) const
return granularity
Definition: memblockvec.hh:65
r_Memory_Block_Vector(r_Bytes bsize=4096, unsigned int gran=8)
constructor, receiving the size of each memory block and the granularity for extending the number of ...
r_Bytes blockSize
the size of the blocks
Definition: memblockvec.hh:88
~r_Memory_Block_Vector(void)
destructor
void ** blocks
the array of memory block pointers
Definition: memblockvec.hh:84
unsigned int get_number(void) const
return number of blocks
Definition: memblockvec.hh:55
r_Bytes get_size(r_Bytes lastFill) const
get number of bytes stored. lastFill is the number of bytes used in the last block ...
void * operator[](unsigned int idx) const
get a block
unsigned int maxBlocks
Definition: memblockvec.hh:86
Definition: memblockvec.hh:46
void * add(void)
add a new block and return a pointer to it
void free_data(void)
free all blocks (but not the vector, call the destructor for that)
unsigned int numBlocks
Definition: memblockvec.hh:85
unsigned int r_Bytes
Definition: mddtypes.hh:56
r_Bytes get_block_size(void) const
return block size
Definition: memblockvec.hh:60
void copy_data(void *dest, r_Bytes lastFill) const
Copy the data stored in blocks into linear memory. lastFill is the number of bytes in the last block...