Imported Upstream version 3.3.2
[debian/amanda] / device-src / xfer-dest-taper.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 2009-2012 Zmanda, Inc.  All Rights Reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17  *
18  * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
19  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
20  */
21
22 #ifndef XFER_DEST_TAPER_H
23 #define XFER_DEST_TAPER_H
24
25 #include "amxfer.h"
26 #include "device.h"
27
28 /*
29  * class declaration for XferDestTaper (an abstract base class)
30  */
31
32 GType xfer_dest_taper_get_type(void);
33 #define XFER_DEST_TAPER_TYPE (xfer_dest_taper_get_type())
34 #define XFER_DEST_TAPER(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_taper_get_type(), XferDestTaper)
35 #define XFER_DEST_TAPER_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), xfer_dest_taper_get_type(), XferDestTaper const)
36 #define XFER_DEST_TAPER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), xfer_dest_taper_get_type(), XferDestTaperClass)
37 #define IS_XFER_DEST_TAPER(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), xfer_dest_taper_get_type ())
38 #define XFER_DEST_TAPER_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), xfer_dest_taper_get_type(), XferDestTaperClass)
39
40 typedef struct XferDestTaper_ {
41     XferElement __parent__;
42 } XferDestTaper;
43
44 typedef struct {
45     XferElementClass __parent__;
46
47     /* see xfer-device.h for details of these methods */
48     void (*start_part)(XferDestTaper *self, gboolean retry_part, dumpfile_t *header);
49     void (*use_device)(XferDestTaper *self, Device *device);
50     void (*cache_inform)(XferDestTaper *self, const char *filename, off_t offset,
51                          off_t length);
52     guint64 (*get_part_bytes_written)(XferDestTaper *self);
53 } XferDestTaperClass;
54
55 /* Start writing the next part to the given device.  The part will be written
56  * to the device given to use_device, which should be open and properly positioned.
57  * It should not have a file open yet.
58  *
59  * @param self: the XferDestTaper object
60  * @param retry_part: retry the previous (incomplete) part if true
61  * @param header: part header
62  */
63 void xfer_dest_taper_start_part(
64     XferElement *self,
65     gboolean retry_part,
66     dumpfile_t *header);
67
68 /* Prepare to write subsequent parts to the given device.  The device must
69  * not be started yet.  It is not necessary to call this method for the first
70  * device used in a transfer.
71  *
72  * @param self: the XferDestTaper object
73  * @param device: the device
74  */
75 void xfer_dest_taper_use_device(
76     XferElement *self,
77     Device *device);
78
79 /* Add a slice of data to the cache for the element.  This is used by the taper
80  * when reading from holding disk, to tell the element which holding disk files
81  * contain the data that might be needed when rewinding, but can be used in any
82  * situation where the part data is already on-disk.  The order of calls to this
83  * function dictates the order in whch the files will be read, and no gaps or
84  * overlaps are supported.  Note, too, that this must be called *before* any of
85  * the data in the new file is sent into the transfer.
86  *
87  * @param self: the XferDestTaper object
88  * @param filename: the fully qualified filename of the cache file
89  * @param offset: offset into the file at which data begins
90  * @param length: length of data in file
91  */
92 void xfer_dest_taper_cache_inform(
93     XferElement *self,
94     const char *filename,
95     off_t offset,
96     off_t length);
97
98 /* Return the number of bytes written for the current part.
99  *
100  * @param self: the XferDestTaper object
101  */
102 guint64 xfer_dest_taper_get_part_bytes_written(
103     XferElement *self);
104
105 #endif