Cortex 6.0.0
Public Types | Public Member Functions

IECore::InterpolatedCache Class Reference

#include <InterpolatedCache.h>

Inheritance diagram for IECore::InterpolatedCache:

List of all members.

Public Types

enum  Interpolation { None = 0, Linear, Cubic }
typedef
IECore::AttributeCache::ObjectHandle 
ObjectHandle
typedef
IECore::AttributeCache::HeaderHandle 
HeaderHandle
typedef
IECore::AttributeCache::AttributeHandle 
AttributeHandle

Public Member Functions

 IE_CORE_DECLAREMEMBERPTR (InterpolatedCache)
 InterpolatedCache (const std::string &pathTemplate="", Interpolation interpolation=None, const OversamplesCalculator &o=OversamplesCalculator(), size_t maxOpenFiles=10)
void setPathTemplate (const std::string &pathTemplate)
const std::string & getPathTemplate () const
void setMaxOpenFiles (size_t maxOpenFiles)
size_t getMaxOpenFiles () const
void setInterpolation (Interpolation interpolation)
Interpolation getInterpolation () const
void setOversamplesCalculator (const OversamplesCalculator &)
const OversamplesCalculatorgetOversamplesCalculator () const
ObjectPtr read (float frame, const ObjectHandle &obj, const AttributeHandle &attr) const
CompoundObjectPtr read (float frame, const ObjectHandle &obj) const
ObjectPtr readHeader (float frame, const HeaderHandle &hdr) const
CompoundObjectPtr readHeader (float frame) const
void objects (float frame, std::vector< ObjectHandle > &objs) const
void headers (float frame, std::vector< HeaderHandle > &hds) const
void attributes (float frame, const ObjectHandle &obj, std::vector< AttributeHandle > &attrs) const
void attributes (float frame, const ObjectHandle &obj, const std::string regex, std::vector< AttributeHandle > &attrs) const
bool contains (float frame, const ObjectHandle &obj) const
bool contains (float frame, const ObjectHandle &obj, const AttributeHandle &attr) const

Detailed Description

Provides higher level access to cache files by automatically interpolating data from multiple files. Or returns the data from the nearest frame if the data cannot be interpolated. The interface looks like AttributeCache reader functions.

Threading:
This class provides limited thread safety. The methods which specify the caches to be read are not safe to call while other threads are operating on the object. However, once the caches have been specified it is safe to call the read methods from multiple concurrent threads and with multiple different frame arguments. See the documentation of the individual methods for more details.
Todo:
It might be great to pass interpolation and oversamples calculator to each read method rather than have them store as state. This would allow different interpolation and oversampling per call and per thread. If we did this I think we should look at replacing the OversamplesCalculator class with some more sensible Time or TimeSampler class, and passing everything in one argument.

Constructor & Destructor Documentation

IECore::InterpolatedCache::InterpolatedCache ( const std::string &  pathTemplate = "",
Interpolation  interpolation = None,
const OversamplesCalculator o = OversamplesCalculator(),
size_t  maxOpenFiles = 10 
)

Constructor pathTemplate must be a valid FileSequence filename specifier, e.g. "myCacheFile.####.cob"


Member Function Documentation

void IECore::InterpolatedCache::attributes ( float  frame,
const ObjectHandle &  obj,
std::vector< AttributeHandle > &  attrs 
) const

Retrieve the list of attribute handles from the specified objects. Throws an exception if the object is not within the cache or the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
void IECore::InterpolatedCache::attributes ( float  frame,
const ObjectHandle &  obj,
const std::string  regex,
std::vector< AttributeHandle > &  attrs 
) const

Retrieve the list of attribute handles that match the given regex from the specified objects. Throws an exception if the object is not within the cache or the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
bool IECore::InterpolatedCache::contains ( float  frame,
const ObjectHandle &  obj 
) const

Determines whether or not the cache contains the specified object Throws an exception if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
bool IECore::InterpolatedCache::contains ( float  frame,
const ObjectHandle &  obj,
const AttributeHandle &  attr 
) const

Determines whether or not the cache contains the specified object and attribute Throws an exception if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
Interpolation IECore::InterpolatedCache::getInterpolation ( ) const

Returns the current interpolation method.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
size_t IECore::InterpolatedCache::getMaxOpenFiles ( ) const

Returns the maximum number of caches this class will keep open at one time.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
const OversamplesCalculator& IECore::InterpolatedCache::getOversamplesCalculator ( ) const

Returns the current OversamplesCalculator.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
const std::string& IECore::InterpolatedCache::getPathTemplate ( ) const

Returns the current path template used to open cache files.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
void IECore::InterpolatedCache::headers ( float  frame,
std::vector< HeaderHandle > &  hds 
) const

Retrieve the list of header handles from the cache (from the nearest frame). Throws an exception if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
void IECore::InterpolatedCache::objects ( float  frame,
std::vector< ObjectHandle > &  objs 
) const

Retrieve the list of object handles from the cache Throws an exception if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
ObjectPtr IECore::InterpolatedCache::read ( float  frame,
const ObjectHandle &  obj,
const AttributeHandle &  attr 
) const

Read a piece of data associated with the specified object and attribute from the cache. Throws an exception if the requested data is not present in the cache or if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
CompoundObjectPtr IECore::InterpolatedCache::read ( float  frame,
const ObjectHandle &  obj 
) const

Read a piece of data associated with the specified object from the cache. Returns a CompoundObject with attribute as keys. Throws an exception if the requested data is not present in the cache or if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
CompoundObjectPtr IECore::InterpolatedCache::readHeader ( float  frame) const

Creates a CompoundObject with the header names as keys. Read all header data present in the open cache files. The result will be interpolated whenever possible. Objects not existent in every opened file will not be interpolated and will be returned if they come from the nearest frame. Throws an exception if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
ObjectPtr IECore::InterpolatedCache::readHeader ( float  frame,
const HeaderHandle &  hdr 
) const

Read data associated with the specified header from the open cache files. The result will be interpolated whenever possible. Objects not existent in every opened file will not be interpolated and will be returned if they come from the nearest frame. Throws an exception if the requested header is not present in the cache or if the cache file is not found.

Threading:
It is safe to call this method while other threads are calling const methods of this class.
void IECore::InterpolatedCache::setInterpolation ( Interpolation  interpolation)

Sets the interpolation method.

Threading:
It is not safe to call this method while other threads are accessing this object.
void IECore::InterpolatedCache::setMaxOpenFiles ( size_t  maxOpenFiles)

Sets the maximum number of caches this class will keep open at one time.

Threading:
It is not safe to call this method while other threads are accessing this object.
void IECore::InterpolatedCache::setOversamplesCalculator ( const OversamplesCalculator )

Sets the OversamplesCalculator.

Threading:
It is not safe to call this method while other threads are accessing this object.
void IECore::InterpolatedCache::setPathTemplate ( const std::string &  pathTemplate)

Changes the path template for cache files.

Threading:
It is not safe to call this method while other threads are accessing this object.

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