IECore::AttributeCache Class Reference

#include <AttributeCache.h>

Inheritance diagram for IECore::AttributeCache:

IECore::RefCounted

List of all members.

Public Types

typedef std::string ObjectHandle
typedef std::string HeaderHandle
typedef std::string AttributeHandle

Public Member Functions

 AttributeCache (const std::string &filename, IndexedIO::OpenMode mode)
 Open the cache, using the specified open mode.
void write (const ObjectHandle &obj, const AttributeHandle &attr, const Object *data)
 Write a piece of data associated with the specified object and attribute to the cache.
void writeHeader (const HeaderHandle &hdr, const Object *data)
 Write data associated with the specified header to the cache.
ObjectPtr read (const ObjectHandle &obj, const AttributeHandle &attr)
CompoundObjectPtr read (const ObjectHandle &obj)
ObjectPtr readHeader (const HeaderHandle &hdr)
CompoundObjectPtr readHeader ()
void objects (std::vector< ObjectHandle > &objs)
 Retrieve the list of object handles from the cache.
void headers (std::vector< HeaderHandle > &hds)
 Retrieve the list of header handles from the cache.
void attributes (const ObjectHandle &obj, std::vector< AttributeHandle > &attrs)
void attributes (const ObjectHandle &obj, const std::string regex, std::vector< AttributeHandle > &attrs)
bool contains (const ObjectHandle &obj)
 Determines whether or not the cache contains the specified object.
bool contains (const ObjectHandle &obj, const AttributeHandle &attr)
 Determines whether or not the cache contains the specified object and attribute.
void remove (const ObjectHandle &obj)
 Removes an object from the cache file.
void remove (const ObjectHandle &obj, const AttributeHandle &attr)
 Removes an object's attribute from the cache file.
void removeHeader (const HeaderHandle &hdr)
 Removes a header from the cache file.

Static Protected Member Functions

static void checkName (const std::string &name)

Protected Attributes

IndexedIOInterfacePtr m_io


Detailed Description

A simple means of creating and reading caches of data values which are associated with notional "Objects" and "Attributes". Will throw an exception derived from IECore::Exception if any errors are encountered.
Threading:
It is not safe to use an instance of this class from multiple concurrent threads. See the InterpolatedCache class for a threadsafe means of reading the files with automatic interpolation.

Member Typedef Documentation


Constructor & Destructor Documentation

AttributeCache::AttributeCache ( const std::string &  filename,
IndexedIO::OpenMode  mode 
)


Member Function Documentation

void AttributeCache::attributes ( const ObjectHandle obj,
const std::string  regex,
std::vector< AttributeHandle > &  attrs 
)

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.

References IECore::IndexedIO::Directory, and m_io.

void AttributeCache::attributes ( const ObjectHandle obj,
std::vector< AttributeHandle > &  attrs 
)

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

References IECore::IndexedIO::Directory, and m_io.

void AttributeCache::checkName ( const std::string &  name  )  [static, protected]

Referenced by write(), and writeHeader().

bool AttributeCache::contains ( const ObjectHandle obj,
const AttributeHandle attr 
)

Determines whether or not the cache contains the specified object and attribute.

References m_io.

bool AttributeCache::contains ( const ObjectHandle obj  ) 

Determines whether or not the cache contains the specified object.

References m_io.

void IECore::AttributeCache::headers ( std::vector< HeaderHandle > &  hds  ) 

Retrieve the list of header handles from the cache.

void IECore::AttributeCache::objects ( std::vector< ObjectHandle > &  objs  ) 

Retrieve the list of object handles from the cache.

CompoundObjectPtr AttributeCache::read ( const ObjectHandle obj  ) 

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.

References IECore::IndexedIO::Directory, IECore::Object::load(), and m_io.

ObjectPtr AttributeCache::read ( const ObjectHandle obj,
const AttributeHandle attr 
)

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.

References IECore::Object::load(), and m_io.

CompoundObjectPtr AttributeCache::readHeader (  ) 

Read all header data present in the cache. Creates a CompoundObject with the header names as keys.

References IECore::IndexedIO::Directory, IECore::Object::load(), and m_io.

ObjectPtr AttributeCache::readHeader ( const HeaderHandle hdr  ) 

Read data associated with the specified header from the cache. Throws an exception if the requested header is not present in the cache.

References IECore::Object::load(), and m_io.

void AttributeCache::remove ( const ObjectHandle obj,
const AttributeHandle attr 
)

Removes an object's attribute from the cache file.

References m_io.

void AttributeCache::remove ( const ObjectHandle obj  ) 

Removes an object from the cache file.

References m_io.

void AttributeCache::removeHeader ( const HeaderHandle hdr  ) 

Removes a header from the cache file.

References m_io.

void AttributeCache::write ( const ObjectHandle obj,
const AttributeHandle attr,
const Object data 
)

Write a piece of data associated with the specified object and attribute to the cache.

References checkName(), m_io, and IECore::Object::save().

void AttributeCache::writeHeader ( const HeaderHandle hdr,
const Object data 
)

Write data associated with the specified header to the cache.

References checkName(), m_io, and IECore::Object::save().

Referenced by AttributeCache().


Member Data Documentation

IndexedIOInterfacePtr IECore::AttributeCache::m_io [protected]


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

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