CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cvmfs::FileSink Class Reference

#include <sink_file.h>

Inheritance diagram for cvmfs::FileSink:
Collaboration diagram for cvmfs::FileSink:

Public Member Functions

 FileSink (FILE *destination_file)
 
 FileSink (FILE *destination_file, bool is_owner)
 
virtual ~FileSink ()
 
virtual int64_t Write (const void *buf, uint64_t sz)
 
virtual int Reset ()
 
virtual int Purge ()
 
virtual bool IsValid ()
 
virtual int Flush ()
 
virtual bool Reserve (size_t)
 
virtual bool RequiresReserve ()
 
virtual std::string Describe ()
 
void Adopt (FILE *file, bool is_owner=true)
 
FILE * file ()
 
- Public Member Functions inherited from cvmfs::Sink
virtual ~Sink ()
 
void Release ()
 

Private Attributes

FILE * file_
 

Additional Inherited Members

- Protected Member Functions inherited from cvmfs::Sink
 Sink (bool is_owner)
 
- Protected Attributes inherited from cvmfs::Sink
bool is_owner_
 

Detailed Description

FileSink is a data sink that write to a given FILE. It does not require any space reservation. It can change to which file to write to using Adopt().

By default FileSink is not the owner of FILE, so the outside entity has to take care of opening and closing the FILE.

Definition at line 25 of file sink_file.h.

Constructor & Destructor Documentation

cvmfs::FileSink::FileSink ( FILE *  destination_file)
inlineexplicit

Definition at line 27 of file sink_file.h.

cvmfs::FileSink::FileSink ( FILE *  destination_file,
bool  is_owner 
)
inline

Definition at line 29 of file sink_file.h.

virtual cvmfs::FileSink::~FileSink ( )
inlinevirtual

Definition at line 32 of file sink_file.h.

Member Function Documentation

void cvmfs::FileSink::Adopt ( FILE *  file,
bool  is_owner = true 
)

Allows the sink to adopt data that was initialized outside this class. The sink can become the new owner of the data, or not.

Definition at line 75 of file sink_file.cc.

Here is the call graph for this function:

std::string cvmfs::FileSink::Describe ( )
virtual

Return a string representation describing the type of sink and its status

Implements cvmfs::Sink.

Definition at line 70 of file sink_file.cc.

Here is the call graph for this function:

FILE* cvmfs::FileSink::file ( )
inline

Definition at line 109 of file sink_file.h.

Referenced by Adopt().

Here is the caller graph for this function:

virtual int cvmfs::FileSink::Flush ( )
inlinevirtual

Commit data to the sink

Returns
success = 0 failure = -errno

Implements cvmfs::Sink.

Definition at line 64 of file sink_file.h.

virtual bool cvmfs::FileSink::IsValid ( )
inlinevirtual
Returns
true if the object is correctly initialized.

Implements cvmfs::Sink.

Definition at line 55 of file sink_file.h.

Referenced by Describe().

Here is the caller graph for this function:

int cvmfs::FileSink::Purge ( )
virtual

Purges all resources leaving the sink in an invalid state. More aggressive version of Reset(). For some sinks and depending on owner status it might do the same as Reset().

Returns
Success = 0 Failure = -errno

Implements cvmfs::Sink.

Definition at line 53 of file sink_file.cc.

Here is the call graph for this function:

virtual bool cvmfs::FileSink::RequiresReserve ( )
inlinevirtual

Returns if the specific sink type needs reservation of (data) space

Returns
true - reservation is needed false - no reservation is needed

Implements cvmfs::Sink.

Definition at line 94 of file sink_file.h.

virtual bool cvmfs::FileSink::Reserve ( size_t  )
inlinevirtual

Reserves new space in sinks that require reservation (see RequiresReserve)

Successful if the requested size is smaller than already space reserved, or if the sink is the owner of the data and can allocate enough new space.

Note
If successful, always resets the current position to 0.

Fails if 1) sink is not the owner of the data and more than the current size is requested 2) more space is requested than allowed (max_size_)

Returns
success = true failure = false

Implements cvmfs::Sink.

Definition at line 84 of file sink_file.h.

int cvmfs::FileSink::Reset ( )
virtual

Truncate all written data and start over at position zero.

Returns
Success = 0 Failure = -1

Implements cvmfs::Sink.

Definition at line 38 of file sink_file.cc.

Referenced by Purge().

Here is the caller graph for this function:

int64_t cvmfs::FileSink::Write ( const void *  buf,
uint64_t  sz 
)
virtual

Appends data to the sink

Returns
on success: number of bytes written (can be less than requested) on failure: -errno.

Appends data to the sink

Returns
on success: number of bytes written on failure: -errno.

Implements cvmfs::Sink.

Definition at line 19 of file sink_file.cc.

Member Data Documentation

FILE* cvmfs::FileSink::file_
private

Definition at line 114 of file sink_file.h.

Referenced by Adopt(), file(), Flush(), IsValid(), Purge(), Reset(), Write(), and ~FileSink().


The documentation for this class was generated from the following files: