DD::Image::FileWriter Class Reference

Inherits DD::Image::Writer.

Public Member Functions

 FileWriter (Write *)
 
 ~FileWriter ()
 
virtual void finish ()
 Called when processing is finished for the current file.
 
- Public Member Functions inherited from DD::Image::Writer
void setFlags (FlagMask flags, bool newValue=true)
 
void clearFlags (FlagMask flags)
 
bool anyFlags (FlagMask newFlags) const
 test whether the Writer has any of the given flags
 
bool allFlags (FlagMask newFlags) const
 test whether the Writer has all of the given flags
 
 Writer (Write *i)
 
virtual ~Writer ()
 
virtual bool movie () const
 
virtual void execute ()
 
virtual void knobs (Knob_Callback cb)
 
bool aborted () const
 Allows a writer to check directly if its op has been aborted.
 
virtual void setLUT (LUT *lut)
 
WriterImplgetImpl ()
 
WriterImplgetImpl () const
 

Protected Member Functions

bool open ()
 
bool close ()
 
bool write (const void *, FILE_OFFSET)
 
bool write (FILE_OFFSET, const void *, FILE_OFFSET)
 
bool seek (FILE_OFFSET)
 
FILE_OFFSET tell () const
 
std::string getTempFileName (const char *pActualFileName=nullptr) const
 Returns a temporary file name for the current output file (e. g. filename.ext.tmp) More...
 
- Protected Member Functions inherited from DD::Image::Writer
LUTlut ()
 
virtual LUTdefaultLUT () const
 
virtual bool isDefaultLUTKnob (DD::Image::Knob *knob) const
 
const Iop::Infoinfo () const
 
int width () const
 
int height () const
 
virtual bool clipToFormat () const
 
virtual int split_input (int i) const
 
virtual const OutputContextinputContext (int n, OutputContext &c) const
 
int depth () const
 
int num_channels () const
 
ChannelSet channel_mask (int num_channels) const
 
Channel channel (int index) const
 
bool premult () const
 
Iopinput0 ()
 
const Iopinput0 () const
 
void get (int y, int x, int r, ChannelMask channels, Row &row)
 
const char * filename () const
 
std::string createFileHash ()
 
std::string getHash () const
 
void renameFromHash ()
 
void to_byte (int z, uchar *, const float *, const float *, int W, int delta=1)
 
void to_short (int z, U16 *, const float *, const float *, int W, int bits=16, int delta=1)
 
void to_float (int z, float *, const float *, const float *, int W, int delta=1)
 
void progressFraction (double f)
 
void progressFraction (int a, int b)
 
std::set< int > executingViews () const
 

Protected Attributes

void * file
 Actually a FILE* but I don't want the <stdio.h> header!
 
FILE_OFFSET offset
 Current offset into file.
 
- Protected Attributes inherited from DD::Image::Writer
Writeiop
 Points at the Write that created this.
 
std::string _hash
 

Related Functions

(Note that these are not member functions.)

typedef unsigned long FILE_OFFSET
 
typedef unsigned long FILE_OFFSET
 

Additional Inherited Members

- Public Types inherited from DD::Image::Writer
typedef U64 FlagMask
 
- Static Public Member Functions inherited from DD::Image::Writer
static void flip (U16 *p, int n)
 
static void flip (U32 *p, int n)
 
static void tolsb (U32 *p, int n)
 
static void tomsb (U32 *p, int n)
 
static void tolsb (U16 *p, int n)
 
static void tomsb (U16 *p, int n)
 
- Static Public Attributes inherited from DD::Image::Writer
static const FlagMask DONT_CHECK_INPUT0_CHANNELS
 

Detailed Description

Writer subclass to write a single Unix file. You must subclass this and implement several virtual functions to write pieces of a file. This takes care of opening and closing the file.

Constructor & Destructor Documentation

FileWriter::FileWriter ( Write iop)

This does not open the file. Instead a subclass should call open() as the first statement in execute() and then return if open fails.

References file.

FileWriter::~FileWriter ( )

Destruction closes the temporary file if execute() did not call close().

References file.

Member Function Documentation

bool FileWriter::open ( )
protected

Open the output file. This file is created with a temporary name so that the original file is not replaced until the write is successful. This returns false and calls iop->error() if it can't open the file.

References DD::Image::Op::critical(), file, DD::Image::Writer::filename(), getTempFileName(), DD::Image::Writer::iop, and offset.

bool FileWriter::close ( )
protected

Close the output file. If there have not been any errors this will mv the temporary file to the correct place.

References DD::Image::Writer::aborted(), DD::Image::Op::critical(), file, DD::Image::Writer::filename(), getTempFileName(), and DD::Image::Writer::iop.

bool FileWriter::write ( const void *  buf,
FILE_OFFSET  length 
)
protected

Write length bytes to the file. Call iop->error() on any errors and returns false. Returns true on success.

References DD::Image::Op::critical(), file, DD::Image::Writer::iop, and offset.

Referenced by write().

bool FileWriter::write ( FILE_OFFSET  off,
const void *  buf,
FILE_OFFSET  length 
)
protected

Same as "seek(off) && write(buf, length)", this writes length bytes to the file at offset and leaves the pointer after that.

References seek(), and write().

bool FileWriter::seek ( FILE_OFFSET  off)
protected

Move the write pointer to offset. This is done efficiently if the pointer is already at that point. Calls iop->error() on any errors and returns false. Returns true on success.

References DD::Image::Op::critical(), file, DD::Image::Writer::iop, and offset.

Referenced by write().

FILE_OFFSET DD::Image::FileWriter::tell ( ) const
inlineprotected

Returns where the pointer currently is.

std::string FileWriter::getTempFileName ( const char *  pActualFileName = nullptr) const
protected

Returns a temporary file name for the current output file (e. g. filename.ext.tmp)

Returns a temporary file name for the given actual file name. e. g. filename.ext -> filename.ext.tmp Pass in NULL to use the current filename().

References DD::Image::Writer::filename().

Referenced by close(), finish(), and open().

Friends And Related Function Documentation

typedef unsigned long FILE_OFFSET
related

This type may need to be replaced on 64-bit file systems.

typedef unsigned long FILE_OFFSET
related

This type may need to be replaced on 64-bit file systems.



©2021 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk