Cortex
10.0.0-a4
|
#include <TypedData.h>
Public Types | |
typedef T | ValueType |
typedef TypedDataTraits< T >::BaseType | BaseType |
Base type used in the internal data structure. | |
![]() | |
typedef ObjectPtr(* | CreatorFn) (void *data) |
![]() | |
typedef RefCounted | BaseClass |
A typedef for the class this class derives from. All RunTimeTyped classes define this typedef. | |
![]() | |
typedef size_t | RefCount |
Public Member Functions | |
TypedData () | |
Default constructor. | |
TypedData (const T &data) | |
Constructor based on the stored data type. | |
IECORE_RUNTIMETYPED_DECLARETEMPLATE (TypedData< T >, Data) | |
void | operator= (const T &data) |
Equivalent to writable() = data. | |
void | operator= (const TypedData< T > &typedData) |
Equivalent to writable() = typedData.readable() | |
const T & | readable () const |
T & | writable () |
const BaseType * | baseReadable () const |
BaseType * | baseWritable () |
size_t | baseSize () const |
Object interface | |
TypedData< T >::Ptr | copy () const |
bool | isEqualTo (const Object *other) const override |
void | hash (MurmurHash &h) const override |
![]() | |
IE_CORE_DECLAREABSTRACTOBJECT (Data, Object) | |
![]() | |
IE_CORE_DECLARERUNTIMETYPED (Object, RunTimeTyped) | |
ObjectPtr | copy () const |
void | copyFrom (const Object *other) |
void | save (IndexedIOPtr ioInterface, const IndexedIO::EntryID &name) const |
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. | |
MurmurHash | hash () const |
![]() | |
IE_CORE_DECLAREMEMBERPTR (RunTimeTyped) | |
virtual TypeId | typeId () const |
virtual const char * | typeName () const |
virtual bool | isInstanceOf (TypeId typeId) const |
virtual bool | isInstanceOf (const char *typeName) const |
![]() | |
IE_CORE_DECLAREMEMBERPTR (RefCounted) | |
void | addRef () const |
Add a reference to the current object. | |
void | removeRef () const |
Remove a reference from the current object. | |
RefCount | refCount () const |
Returns the current reference count. | |
Static Public Member Functions | |
static bool | hasBase () |
Defines whether the internal data structure has a single base type. | |
![]() | |
static void | registerType (TypeId typeId, const std::string &typeName, CreatorFn creator, void *data=nullptr) |
Register a new Object-derived type with the system. The specified void* data is passed into the creator function. | |
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 (ConstIndexedIOPtr ioInterface, const IndexedIO::EntryID &name) |
![]() | |
static TypeId | staticTypeId () |
Returns the TypeId for this class, without needing an instance. | |
static const char * | staticTypeName () |
Returns the type name for this class, without needing an instance. | |
static TypeId | baseTypeId () |
static const char * | baseTypeName () |
static bool | inheritsFrom (TypeId typeId) |
Returns true if this class inherits from the specified type. | |
static bool | inheritsFrom (const char *typeName) |
Returns true if this class inherits from the specified type. | |
static bool | inheritsFrom (TypeId type, TypeId baseType) |
Returns true if type inherits from baseType. | |
static bool | inheritsFrom (const char *typeName, const char *baseTypeName) |
Returns true if typeName inherits from baseTypeName. | |
static TypeId | baseTypeId (TypeId typeId) |
Returns the base type of the given type, or InvalidTypeId if no such base exists. | |
static const std::vector< TypeId > & | baseTypeIds (TypeId typeId) |
static const std::set< TypeId > & | derivedTypeIds (TypeId typeId) |
static TypeId | typeIdFromTypeName (const char *typeName) |
static const char * | typeNameFromTypeId (TypeId typeId) |
static void | registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId) |
Allows external modules to register their own type ids. | |
Protected Types | |
typedef TypedDataTraits< T >::DataHolder | DataHolder |
![]() | |
typedef std::map< TypeId, TypeId > | BaseTypeRegistryMap |
typedef std::map< TypeId, std::vector< TypeId > > | BaseTypesRegistryMap |
typedef std::map< TypeId, std::set< TypeId > > | DerivedTypesRegistryMap |
typedef tbb::spin_rw_mutex | Mutex |
typedef std::map< TypeId, std::string > | TypeIdsToTypeNamesMap |
typedef std::map< std::string, TypeId > | TypeNamesToTypeIdsMap |
Protected Member Functions | |
void | copyFrom (const Object *other, CopyContext *context) override |
void | save (SaveContext *context) const override |
void | load (LoadContextPtr context) override |
void | memoryUsage (Object::MemoryAccumulator &accumulator) const override |
![]() | |
IE_CORE_DECLAREPTR (LoadContext) | |
Protected Attributes | |
DataHolder | m_data |
Static Protected Attributes | |
static Object::TypeDescription< TypedData< T > > | m_typeDescription |
![]() | |
static Mutex | g_baseTypeIdsMutex |
static Mutex | g_derivedTypeIdsMutex |
Additional Inherited Members | |
![]() | |
static BaseTypeRegistryMap & | baseTypeRegistry () |
static DerivedTypesRegistryMap & | derivedTypesRegistry () |
static BaseTypesRegistryMap & | completeBaseTypesRegistry () |
static DerivedTypesRegistryMap & | completeDerivedTypesRegistry () |
static void | derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &) |
static TypeIdsToTypeNamesMap & | typeIdsToTypeNames () |
static TypeNamesToTypeIdsMap & | typeNamesToTypeIds () |
A templated class which can be used to wrap useful data types and containers, while implementing all the io, copying and hashing abilities of the Object base class. The internal data may be accessed using the readable() and writable() accessors and in the case of it being composed of one or more contiguous elements of a simple base type it may also be accessed as raw data using the baseReadable() and baseWritable() methods.
Note that to use instantiations of this class you should utilise the appropriate typedefs as provided by headers such as SimpleTypedData.h or VectorTypedData.h, rather than include this header directly.
Also note that you cannot simply instantiate this class with an arbitrary type without performing some specialisation of the functions for implementing IO and hashing. DateTimeData.h and the matching DateTimeData.cpp provide a good example for creating your own TypedData class - see comments in those files for further details.
const BaseType* IECore::TypedData< T >::baseReadable | ( | ) | const |
Get low level read-only access to the internal data structure as a reference to the first element on an array of base type. Throws an Exception if this type has no single base type.
size_t IECore::TypedData< T >::baseSize | ( | ) | const |
Return the size of the internal data structure in terms of base type elements. Throws an Exception if this type has no single base type.
BaseType* IECore::TypedData< T >::baseWritable | ( | ) |
Get low level read-write access to the internal data structure as a reference to the first element on an array of base type. Throws an Exception if this type has no single base type.
|
overrideprotectedvirtual |
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.
Implements IECore::Object.
|
overridevirtual |
Must be implemented by subclasses to append all member data into the given hash. Implementations must first call the base class implementation before appending their own data.
Implements IECore::Object.
|
overridevirtual |
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 boost::static_pointer_cast<YourClass>( other ) if your base class isEqualTo() doesn't return false.
Implements IECore::Object.
|
overrideprotectedvirtual |
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.
Implements IECore::Object.
|
overrideprotectedvirtual |
If the memory usage is anything other than sizeof(T) for a given T then you must provide an accurate specialisation for this function.
Implements IECore::Object.
const T& IECore::TypedData< T >::readable | ( | ) | const |
Gives read-only access to the internal data structure.
|
overrideprotectedvirtual |
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.
Implements IECore::Object.
T& IECore::TypedData< T >::writable | ( | ) |
Gives read-write access to the internal data structure.