IECore::Object Class Reference

A base class defining copying and streaming. More...

#include <Object.h>

Inheritance diagram for IECore::Object:

IECore::RunTimeTyped IECore::RefCounted IECore::BlindDataHolder IECore::CompoundObject IECore::Data IECore::NullObject IECore::ObjectVector IECore::Renderable IECore::SmoothSkinningData IECore::TypedData< T > IECore::TypedData< CompoundDataMap > IECore::TypedData< int > IECore::TypedData< int > > IECore::PreWorldRenderable IECore::StateRenderable IECore::VisibleRenderable IECore::CompoundData IECore::LongDataAlias IECore::LongVectorDataAlias IECore::Camera IECore::Display IECore::AttributeState IECore::CoordinateSystem IECore::Light IECore::Shader IECore::Transform IECore::Group IECore::MotionPrimitive IECore::ParameterisedProcedural IECore::Primitive

List of all members.

Classes

class  AbstractTypeDescription
class  CopyContext
class  LoadContext
 The class provided to the load() method implemented by subclasses. More...
class  MemoryAccumulator
class  SaveContext
 The class provided to the save() method implemented by subclasses. More...
class  TypeDescription
struct  TypeInformation

Public Types

typedef ObjectPtr(* CreatorFn )(void *data)

Public Member Functions

 Object ()
virtual ~Object ()
 IE_CORE_DECLARERUNTIMETYPED (Object, RunTimeTyped)
Object interface
The following functions define the interface to which all Object subclasses must adhere. Note that the IE_CORE_DECLAREOBJECT macro is provided to simplify the declaration of these functions for your own derived classes. Note also that there is additional protected interface which you must implement - this too is declared (but not implemented) by the IE_CORE_DECLAREOBJECT macro.

ObjectPtr copy () const
void copyFrom (const Object *other)
void save (IndexedIOInterfacePtr ioInterface, const IndexedIO::EntryID &name) const
virtual bool isEqualTo (const Object *other) const =0
virtual bool isNotEqualTo (const Object *other) const
bool operator== (const Object &other) const
 Calls isEqualTo() for people who prefer to use the operator syntax.
bool operator!= (const Object &other) const
 Calls isNotEqualTo() for people who prefer to use the operator syntax.
size_t memoryUsage () const
 Returns the number of bytes this instance occupies in memory.

Static Public Member Functions

static void registerType (TypeId typeId, const std::string &typeName, CreatorFn creator, void *data=0)
 Register a new Object-derived type with the system. The specified void* data is passed into the creator function.
Object factory
The following static functions provide the ability to create an Object of a given type or typeId, as well as providing conversions between type names and TypeIds.

static bool isType (TypeId typeId)
 Returns true if typeId is a valid registered Object type.
static bool isType (const std::string &typeName)
 Returns true if typeName is a valid registered Object type.
static bool isAbstractType (TypeId typeId)
static bool isAbstractType (const std::string &typeName)
 As above but taking a type name.
static ObjectPtr create (TypeId typeId)
static ObjectPtr create (const std::string &typeName)
static ObjectPtr load (IndexedIOInterfacePtr ioInterface, const IndexedIO::EntryID &name)

Protected Member Functions

virtual void copyFrom (const Object *other, CopyContext *context)=0
 IE_CORE_DECLAREPTR (LoadContext)
virtual void save (SaveContext *context) const =0
virtual void load (LoadContextPtr context)=0
virtual void memoryUsage (MemoryAccumulator &accumulator) const =0


Detailed Description

A base class defining copying and streaming.

Member Typedef Documentation

typedef ObjectPtr(* IECore::Object::CreatorFn)(void *data)


Constructor & Destructor Documentation

Object::Object (  ) 

Object::~Object (  )  [virtual]


Member Function Documentation

ObjectPtr Object::copy (  )  const

Returns a deep copy of this object. In subclasses an identical function is provided which returns a pointer to the subclass rather than to this base class.

Reimplemented in IECore::TypedData< T >, IECore::TypedData< CompoundDataMap >, IECore::TypedData< int >, IECore::TypedData< std::vector< T > >, IECore::TypedData< int > >, and IECore::TypedData< std::vector< Imath::Vec3< PointBaseType > > >.

Referenced by IECore::DataCastOp::doOperation(), and IECore::TriangulateOp::TriangulateOp::TriangulateFn::operator()().

void Object::copyFrom ( const Object other,
CopyContext context 
) [protected, pure virtual]

Must be implemented in all subclasses to make a deep copy of all member data, after calling BaseClass::copyFrom() to allow the base class to do the same. When making copies of held member data derived from Object, you /must/ use the context object provided, rather than calling copy() or copyFrom() yourself.

Implemented in IECore::TypedData< T >, IECore::TypedData< CompoundDataMap >, IECore::TypedData< int >, IECore::TypedData< std::vector< T > >, IECore::TypedData< int > >, and IECore::TypedData< std::vector< Imath::Vec3< PointBaseType > > >.

void Object::copyFrom ( const Object other  ) 

Copies from another object. Throws an IECore::InvalidArgumentException if other is not an instance of this object.

References IECore::RunTimeTyped::isInstanceOf(), IECore::RunTimeTyped::typeId(), and IECore::RunTimeTyped::typeName().

ObjectPtr Object::create ( const std::string &  typeName  )  [static]

Creates an instance of an object of the specified type. Throws an Exception if typeName is not a valid type.

References IECore::Object::Object::TypeInformation::typeNamesToCreators.

ObjectPtr Object::create ( TypeId  typeId  )  [static]

Creates an instance of an object of the specified type. Throws an Exception if typeId is not a valid type.

References IECore::Object::Object::TypeInformation::typeIdsToCreators.

Referenced by IECore::cubicObjectInterpolation(), and IECore::linearObjectInterpolation().

IECore::Object::IE_CORE_DECLAREPTR ( LoadContext   )  [protected]

IECore::Object::IE_CORE_DECLARERUNTIMETYPED ( Object  ,
RunTimeTyped   
)

bool Object::isAbstractType ( const std::string &  typeName  )  [static]

As above but taking a type name.

References IECore::Object::Object::TypeInformation::typeNamesToCreators.

bool Object::isAbstractType ( TypeId  typeId  )  [static]

Returns true if typeId is a valid registered abstract Object type - one which cannot be instantiated with create().

References IECore::Object::Object::TypeInformation::typeIdsToCreators.

bool Object::isEqualTo ( const Object other  )  const [pure virtual]

Returns true if this object is equal to the other. Should be reimplemented appropriately in derived classes, first calling your base class isEqualTo() and returning false straight away if that returns false. The Object level implementation checks that the types are identical, so you can safely perform a staticPointerCast<YourClass>( other ) if your base class isEqualTo() doesn't return false.

Implemented in IECore::TypedData< T >, IECore::TypedData< CompoundDataMap >, IECore::TypedData< int >, IECore::TypedData< std::vector< T > >, IECore::TypedData< int > >, and IECore::TypedData< std::vector< Imath::Vec3< PointBaseType > > >.

References IECore::RunTimeTyped::typeId().

Referenced by isNotEqualTo(), and operator==().

bool Object::isNotEqualTo ( const Object other  )  const [virtual]

Returns true if this object is not equal to the other. A default implementation for this returns the negation of isEqualTo(), but you may wish to override it if you can provide a faster implementation for a specific subclass.

References isEqualTo().

Referenced by operator!=().

bool Object::isType ( const std::string &  typeName  )  [static]

Returns true if typeName is a valid registered Object type.

References IECore::Object::Object::TypeInformation::typeNamesToCreators.

bool Object::isType ( TypeId  typeId  )  [static]

Returns true if typeId is a valid registered Object type.

References IECore::Object::Object::TypeInformation::typeIdsToCreators.

void Object::load ( LoadContextPtr  context  )  [protected, pure virtual]

Must be implemented in all derived classes. Implementations should first call the parent class load() method, then call context->container() before loading their member data from that container. context is a smart pointer to a reference counted object to allow you to keep the context and perform lazy loading at a later date - although this is not yet used by any of the core types. A call to context->container() will throw an Exception if the corresponding save() method did not create a container.

Implemented in IECore::TypedData< T >, IECore::TypedData< CompoundDataMap >, IECore::TypedData< int >, IECore::TypedData< std::vector< T > >, IECore::TypedData< int > >, IECore::TypedData< std::vector< Imath::Vec3< PointBaseType > > >, IECore::TypedData< T >, IECore::TypedData< T >, IECore::TypedData< T >, and IECore::TypedData< T >.

ObjectPtr Object::load ( IndexedIOInterfacePtr  ioInterface,
const IndexedIO::EntryID name 
) [static]

void Object::memoryUsage ( MemoryAccumulator accumulator  )  const [protected, pure virtual]

Must be implemented in all derived classes to specify the amount of memory they are using. An implementation must add it's memory usage to the accumulator before calling memoryUsage() on its base class.

Implemented in IECore::TypedData< T >, IECore::TypedData< CompoundDataMap >, IECore::TypedData< int >, IECore::TypedData< std::vector< T > >, IECore::TypedData< int > >, and IECore::TypedData< std::vector< Imath::Vec3< PointBaseType > > >.

References IECore::Object::Object::MemoryAccumulator::accumulate().

size_t Object::memoryUsage (  )  const

Returns the number of bytes this instance occupies in memory.

References IECore::Object::Object::MemoryAccumulator::accumulate(), and IECore::Object::Object::MemoryAccumulator::total().

Referenced by IECore::TypedData< T >::memoryUsage().

bool Object::operator!= ( const Object other  )  const

Calls isNotEqualTo() for people who prefer to use the operator syntax.

References isNotEqualTo().

bool Object::operator== ( const Object other  )  const

Calls isEqualTo() for people who prefer to use the operator syntax.

References isEqualTo().

void Object::registerType ( TypeId  typeId,
const std::string &  typeName,
CreatorFn  creator,
void *  data = 0 
) [static]

Register a new Object-derived type with the system. The specified void* data is passed into the creator function.

References IECore::Object::Object::TypeInformation::typeIdsToCreators, and IECore::Object::Object::TypeInformation::typeNamesToCreators.

void Object::save ( SaveContext context  )  const [protected, pure virtual]

Must be implemented in all derived classes. Implementations should first call the parent class save() method, then call context->container() before filling the returned container with their member data. Classes with no member data may omit the call to container(), resulting in smaller file sizes.

Implemented in IECore::TypedData< T >, IECore::TypedData< CompoundDataMap >, IECore::TypedData< int >, IECore::TypedData< std::vector< T > >, IECore::TypedData< int > >, IECore::TypedData< std::vector< Imath::Vec3< PointBaseType > > >, IECore::TypedData< T >, IECore::TypedData< T >, IECore::TypedData< T >, and IECore::TypedData< T >.

void Object::save ( IndexedIOInterfacePtr  ioInterface,
const IndexedIO::EntryID name 
) const

Saves the object in the current directory of ioInterface, in a subdirectory with the specified name.

Referenced by IECore::ObjectWriter::doWrite(), IECore::Object::Object::SaveContext::save(), IECore::TypedData< T >::save(), IECore::AttributeCache::write(), and IECore::AttributeCache::writeHeader().


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

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