1 #ifndef VOL_IO_VOLUME_CACHE_H
2 #define VOL_IO_VOLUME_CACHE_H
3 
4 #include "volume.h"
5 
6 /* ----------------------------------------------------------------------------
7 @COPYRIGHT  :
8               Copyright 1993,1994,1995 David MacDonald,
9               McConnell Brain Imaging Centre,
10               Montreal Neurological Institute, McGill University.
11               Permission to use, copy, modify, and distribute this
12               software and its documentation for any purpose and without
13               fee is hereby granted, provided that the above copyright
14               notice appear in all copies.  The author and McGill University
15               make no representations about the suitability of this
16               software for any purpose.  It is provided "as is" without
17               express or implied warranty.
18 @VERSION    : $Header: /private-cvsroot/minc/volume_io/Include/volume_io/volume_cache.h,v 1.11 2005-05-19 21:19:28 bert Exp $
19 ---------------------------------------------------------------------------- */
20 
21 /* ----------------------------- MNI Header -----------------------------------
22 @NAME       : volume_cache.h
23 @INPUT      :
24 @OUTPUT     :
25 @RETURNS    :
26 @DESCRIPTION: Volume block caching mechanism for treating large volumes
27               as if they are in memory.
28 @METHOD     :
29 @GLOBALS    :
30 @CALLS      :
31 @CREATED    : Aug. 14, 1995   David MacDonald
32 @MODIFIED   :
33 ---------------------------------------------------------------------------- */
34 
35 #include  <volume_io/multidim.h>
36 
37 typedef  enum  { SLICE_ACCESS, RANDOM_VOLUME_ACCESS }
38                VIO_Cache_block_size_hints;
39 
40 #define  CACHE_DEBUGGING
41 #undef   CACHE_DEBUGGING
42 
43 typedef  struct  VIO_cache_block_struct
44 {
45     int                         block_index;
46     VIO_SCHAR                modified_flag;
47     VIO_multidim_array              array;
48     struct  VIO_cache_block_struct  *prev_used;
49     struct  VIO_cache_block_struct  *next_used;
50     struct  VIO_cache_block_struct  **prev_hash;
51     struct  VIO_cache_block_struct  *next_hash;
52 } VIO_cache_block_struct;
53 
54 typedef  struct
55 {
56     int       block_index_offset;
57     int       block_offset;
58 } VIO_cache_lookup_struct;
59 
60 typedef struct
61 {
62     int                         n_dimensions;
63     int                         file_offset[VIO_MAX_DIMENSIONS];
64     VIO_STR                     input_filename;
65 
66     VIO_STR                     output_filename;
67     nc_type                     file_nc_data_type;
68     VIO_BOOL                    file_signed_flag;
69     VIO_Real                    file_voxel_min;
70     VIO_Real                    file_voxel_max;
71     VIO_STR                     original_filename;
72     VIO_STR                     history;
73     minc_output_options         options;
74 
75     VIO_BOOL                    writing_to_temp_file;
76     int                         total_block_size;
77     int                         block_sizes[VIO_MAX_DIMENSIONS];
78     int                         blocks_per_dim[VIO_MAX_DIMENSIONS];
79     VIO_BOOL                    output_file_is_open;
80     VIO_BOOL                    must_read_blocks_before_use;
81     void                        *minc_file;
82     int                         n_blocks;
83     int                         max_cache_bytes;
84     int                         max_blocks;
85     int                         hash_table_size;
86     VIO_cache_block_struct      *head;
87     VIO_cache_block_struct      *tail;
88     VIO_cache_block_struct      **hash_table;
89 
90     VIO_cache_lookup_struct     *lookup[VIO_MAX_DIMENSIONS];
91     VIO_cache_block_struct      *previous_block;
92     int                         previous_block_index;
93 
94     VIO_BOOL                    debugging_on;
95     int                         n_accesses;
96     int                         output_every;
97     int                         n_hits;
98     int                         n_prev_hits;
99 } VIO_volume_cache_struct;
100 
101 #endif /* VOL_IO_VOLUME_CACHE_H */
102