1 /* This file is part of GEGL.
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 3 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with GEGL; if not, see <https://www.gnu.org/licenses/>.
15  *
16  * Copyright 2006 Øyvind Kolås <pippin@gimp.org>
17  */
18 
19 #ifndef __GEGL_TILE_BACKEND_FILE_H__
20 #define __GEGL_TILE_BACKEND_FILE_H__
21 
22 #include "gegl-tile-backend.h"
23 #include "gegl-buffer-index.h"
24 
25 /***
26  * GeglTileBackendFile is a GeglTileBackend that store tiles in a unique file.
27  */
28 
29 G_BEGIN_DECLS
30 
31 #define GEGL_TYPE_TILE_BACKEND_FILE            (gegl_tile_backend_file_get_type ())
32 #define GEGL_TILE_BACKEND_FILE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_TILE_BACKEND_FILE, GeglTileBackendFile))
33 #define GEGL_TILE_BACKEND_FILE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  GEGL_TYPE_TILE_BACKEND_FILE, GeglTileBackendFileClass))
34 #define GEGL_IS_TILE_BACKEND_FILE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_TILE_BACKEND_FILE))
35 #define GEGL_IS_TILE_BACKEND_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  GEGL_TYPE_TILE_BACKEND_FILE))
36 #define GEGL_TILE_BACKEND_FILE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  GEGL_TYPE_TILE_BACKEND_FILE, GeglTileBackendFileClass))
37 
38 
39 typedef struct _GeglTileBackendFile      GeglTileBackendFile;
40 typedef struct _GeglTileBackendFileClass GeglTileBackendFileClass;
41 
42 typedef enum
43 {
44   OP_WRITE,
45   OP_WRITE_BLOCK,
46   OP_TRUNCATE,
47   OP_SYNC
48 } GeglFileBackendThreadOp;
49 
50 typedef struct
51 {
52   GeglBufferTile *tile;
53   /* reference to the writer queue links of this entry when writing
54      tile data or a GeglBufferBlock*/
55   GList          *tile_link;
56   GList          *block_link;
57 } GeglFileBackendEntry;
58 
59 typedef struct
60 {
61   gint                     length;    /* length of data if writing tile or
62                                          length of file if truncating */
63   guchar                  *source;
64   goffset                  offset;
65   GeglTileBackendFile     *file;      /* the file we are operating on */
66   GeglFileBackendThreadOp  operation; /* type of file operation, see above */
67   GeglFileBackendEntry    *entry;
68 } GeglFileBackendThreadParams;
69 
70 struct _GeglTileBackendFileClass
71 {
72   GeglTileBackendClass parent_class;
73 };
74 
75 GType gegl_tile_backend_file_get_type (void) G_GNUC_CONST;
76 
77 void  gegl_tile_backend_file_stats    (void);
78 
79 gboolean gegl_tile_backend_file_try_lock (GeglTileBackendFile *file);
80 gboolean gegl_tile_backend_file_unlock   (GeglTileBackendFile *file);
81 
82 G_END_DECLS
83 
84 #endif
85