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