IECore::Reader Class Reference

#include <Reader.h>

Inheritance diagram for IECore::Reader:

IECore::Op IECore::Parameterised IECore::RunTimeTyped IECore::ParameterisedInterface IECore::RefCounted IECore::BINMeshReader IECore::IDXReader::IDXReader IECore::IFFHairReader IECore::ImageReader IECore::ObjectReader IECore::OBJReader IECore::ParticleReader IECoreRI::SLOReader

List of all members.

Classes

class  ReaderDescription
struct  ReaderFns

Public Member Functions

 IE_CORE_DECLARERUNTIMETYPED (Reader, Op)
const std::string & fileName () const
virtual CompoundObjectPtr readHeader ()
ObjectPtr read ()

Protected Member Functions

 Reader (const std::string &description, ParameterPtr resultParameter=0)

Protected Attributes

FileNameParameterPtr m_fileNameParameter

Factory functions

////////////////////////////////////////////////////////////////////////

typedef boost::function
< ReaderPtr(const std::string
&fileName)> 
CreatorFn
typedef boost::function< bool(const
std::string &fileName)> 
CanReadFn
static ReaderPtr create (const std::string &fileName)
static void supportedExtensions (std::vector< std::string > &extensions)
static void supportedExtensions (TypeId typeId, std::vector< std::string > &extensions)
static void registerReader (const std::string &extensions, CanReadFn canRead, CreatorFn creator, TypeId typeId)


Detailed Description

The Reader class defines an interface for loading files of arbitrary type in the form of Object instances.

Member Typedef Documentation

typedef boost::function<bool ( const std::string &fileName )> IECore::Reader::CanReadFn

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

typedef boost::function<ReaderPtr ( const std::string &fileName )> IECore::Reader::CreatorFn

Definition of a function which can create a Reader when given a fileName.


Constructor & Destructor Documentation

Reader::Reader ( const std::string &  description,
ParameterPtr  resultParameter = 0 
) [protected]

If resultParameter is not specified then creates a resultParameter which is a simple Parameter instance. If a derived class provides more concrete constraints on the type of the result it should pass an appropriate resultParameter in its initialiser.

References m_fileNameParameter, IECore::PathParameter::MustExist, and IECore::Parameterised::parameters().


Member Function Documentation

ReaderPtr Reader::create ( const std::string &  fileName  )  [static]

Creates and returns a Reader appropriate to the specified file. Throws an Exception if no suitable reader can be found.

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

IECore::Reader::IE_CORE_DECLARERUNTIMETYPED ( Reader  ,
Op   
)

ObjectPtr Reader::read (  ) 

Reads the file specified by fileName() and returns it in the form of an Object. This function actually just calls Op::operate() - it's provided for backwards compatibility and prettier syntax.

Todo:
Perhaps we should append the fileName() to any exceptions thrown by operate() before re-raising them? Use of boost.exception might make this easier.

References IECore::Op::operate().

Referenced by IECore::NParticleReader::readAttribute().

CompoundObjectPtr Reader::readHeader (  )  [virtual]

Returns the file header in the file specified by fileName(). This is intended to give fast access to some information about the contents of the file, without having to load the entire thing. Classes implementing this method should call the base class method first, and append any additional data to the CompoundObject it returns.

Reimplemented in IECore::EXRImageReader, IECore::ImageReader, and IECore::ObjectReader.

void Reader::registerReader ( const std::string &  extensions,
CanReadFn  canRead,
CreatorFn  creator,
TypeId  typeId 
) [static]

Registers a Reader type which is capable of reading files ending with the space separated extensions specified (e.g. "tif tiff"). Before creating a reader the canRead function will be called as a final check that the Reader is appropriate - if this returns true then the creator function will then be called. If a file has no extension then all registered canRead functions are called in a last ditch attempt to find a suitable reader. Typically you will not call this function directly to register a reader type - you will instead use the ReaderDescription registration utility class below.

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

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

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

References IECoreMaya::ParameterClipboardUI::copy(), and IECore::RunTimeTyped::derivedTypeIds().

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

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

References IECoreMaya::ParameterClipboardUI::copy().


Member Data Documentation

FileNameParameterPtr IECore::Reader::m_fileNameParameter [protected]


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

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