IECore::Writer Class Reference

#include <Writer.h>

Inheritance diagram for IECore::Writer:

IECore::Op IECore::Parameterised IECore::RunTimeTyped IECore::ParameterisedInterface IECore::RefCounted IECore::ImageWriter IECore::ObjectWriter IECore::ParticleWriter IECoreRI::RIBWriter IECore::CINImageWriter IECore::DPXImageWriter IECore::EXRImageWriter IECore::JPEGImageWriter IECore::TGAImageWriter IECore::TIFFImageWriter IECore::YUVImageWriter IECore::BINParticleWriter IECore::PDCParticleWriter IECoreRI::PTCParticleWriter

List of all members.

Classes

class  WriterDescription
struct  WriterFns

Public Member Functions

const std::string & fileName () const
const Objectobject () const
void write ()

Static Public Member Functions

static WriterPtr create (ObjectPtr object, const std::string &fileName)
static void supportedExtensions (std::vector< std::string > &extensions)
static void supportedExtensions (TypeId typeId, std::vector< std::string > &extensions)

Protected Types

typedef WriterPtr(* CreatorFn )(ObjectPtr object, const std::string &fileName)
typedef bool(* CanWriteFn )(ConstObjectPtr object, const std::string &fileName)

Protected Member Functions

 Writer (const std::string &description, TypeId writableType)
 Writer (const std::string &description, const ObjectParameter::TypeIdSet &writableTypes)
ObjectPtr doOperation (const CompoundObject *operands)
 Implemented to call doWrite(), so derived classes need only implement that.
virtual void doWrite (const CompoundObject *operands)=0

Static Protected Member Functions

static void registerWriter (const std::string &extensions, CanWriteFn canWrite, CreatorFn creator, TypeId typeId)

Protected Attributes

ParameterPtr m_objectParameter
FileNameParameterPtr m_fileNameParameter


Detailed Description

The Writer class defines an interface for creating files of arbitrary type from Object instances.

Member Typedef Documentation

typedef bool(* IECore::Writer::CanWriteFn)(ConstObjectPtr object, const std::string &fileName) [protected]

Definition of a function to answer the question can this object be written to this file?

typedef WriterPtr(* IECore::Writer::CreatorFn)(ObjectPtr object, const std::string &fileName) [protected]

Definition of a function which can create a Writer when given an object and fileName.


Constructor & Destructor Documentation

Writer::Writer ( const std::string &  description,
TypeId  writableType 
) [protected]

Writer::Writer ( const std::string &  description,
const ObjectParameter::TypeIdSet writableTypes 
) [protected]


Member Function Documentation

WriterPtr Writer::create ( ObjectPtr  object,
const std::string &  fileName 
) [static]

Creates and returns a Writer appropriate for saving the specified object to the specified file (the file extension is used to determine format). Throws an Exception if no suitable writer can be found.

ObjectPtr Writer::doOperation ( const CompoundObject operands  )  [protected, virtual]

Implemented to call doWrite(), so derived classes need only implement that.

Implements IECore::Op.

References doWrite(), and m_objectParameter.

virtual void IECore::Writer::doWrite ( const CompoundObject operands  )  [protected, pure virtual]

Must be implemented by subclasses to write object() to fileName(). Implementations should throw an Exception on failure.

Implemented in IECore::ObjectWriter, and IECoreRI::RIBWriter.

Referenced by doOperation().

const std::string & Writer::fileName (  )  const

Returns the name of the file this Writer is set to create. This is just a convenience returning the equivalent of parameters()->parameter<FileNameParameter>( "fileName" )->getTypedValue().

References m_fileNameParameter.

Referenced by IECoreRI::RIBWriter::doWrite(), IECore::ObjectWriter::doWrite(), and IECore::TIFFImageWriter::encodeChannels().

const Object * Writer::object (  )  const

Returns the Object this Writer will use to write the file. This is just a convenience returning the equivalent of parameters()->parameter<Parameter>( "object" )->getValue().

References m_objectParameter.

Referenced by IECoreRI::RIBWriter::doWrite(), IECore::ObjectWriter::doWrite(), IECore::ImageWriter::getImage(), and IECore::ParticleWriter::particleObject().

void Writer::registerWriter ( const std::string &  extensions,
CanWriteFn  canWrite,
CreatorFn  creator,
TypeId  typeId 
) [static, protected]

Registers a Writer type which is capable of writing files ending with the space separated extensions specified (e.g. "tif tiff"). Before creating a Writer the canWrite function will be called as a final check that the Writer is appropriate for the given Object type - if this returns true then the creator function will then be called. Typically you will not call this function directly to register a writer type - you will instead use the registration utility class below.

References IECore::InvalidTypeId, and IECore::CamelCase::split().

void Writer::supportedExtensions ( TypeId  typeId,
std::vector< std::string > &  extensions 
) [static]

Fills the passed vector with all the extensions for which a Writer of, or inherited from, the given type is available. Extensions are of the form "tif" - ie without a preceding '.'.

References IECore::RunTimeTyped::derivedTypeIds().

void Writer::supportedExtensions ( std::vector< std::string > &  extensions  )  [static]

Fills the passed vector with all the extensions for which a Writer is available. Extensions are of the form "tif" - ie without a preceding '.'.

void Writer::write (  ) 

Writes object() to fileName(). This just calls operate() and is provided for backwards compatibility and pretty syntax.

Todo:
Perhaps we should append the fileName() to any exceptions thrown by operate() before re-raising them?

References IECore::Op::operate().


Member Data Documentation

FileNameParameterPtr IECore::Writer::m_fileNameParameter [protected]

ParameterPtr IECore::Writer::m_objectParameter [protected]


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

Generated on Mon Jan 24 11:13:28 2011 for Cortex by doxygen 1.5.8