Cortex 6.0.0
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes

IECore::Writer Class Reference

#include <Writer.h>

Inheritance diagram for IECore::Writer:

List of all members.

Classes

class  WriterDescription

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.


Member Function Documentation

static WriterPtr IECore::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.

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.

const std::string& IECore::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().

const Object* IECore::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().

static void IECore::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.

static void IECore::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 '.'.

static void IECore::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 '.'.

void IECore::Writer::write ( )

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


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends