#include <datatypebase.h>
Classes | |
class | Instantiated |
class | Primary |
Public Member Functions | |
template<typename T , typename C > | |
DataTypeImpl (const Id &type, const DataTypeImpl *underlying, const DataTypeImpl *element, const T *nullValue, const C *dummy, VALUEKIND flags=VALUEKIND::NONE, const NonvirtualInterfaceImplementation *impl=nullptr, VALUEKIND kind=ValueKindHelper< T, GetDirectlyReferencedType< T >::value >::KIND, const ParametricTypeInterface *pt=nullptr, const DataTypeImpl *extra=nullptr) | |
template<typename C > | |
DataTypeImpl (const Id &type, const DataTypeImpl *underlying, const DataTypeImpl *element, const void *nullValue, Int size, Int alignment, const C *dummy, VALUEKIND kind, const ParametricTypeInterface *pt=nullptr, const DataTypeImpl *extra=nullptr) | |
DataTypeImpl () | |
DataTypeImpl (const DataTypeImpl &src, const Id &typeId, VALUEKIND qualification, const ParametricTypeInterface *pt, VALUEKIND remove=VALUEKIND::NONE, Bool copyTypeArgs=true, const DataTypeImpl *element=nullptr) | |
const Id & | GetId () const |
String | ToString (const FormatStatement *formatStatement=nullptr) const |
Int | GetSize () const |
Int | GetAlignment () const |
VALUEKIND | GetValueKind () const |
Bool | CheckValueKind (VALUEKIND test) const |
const DataTypeImpl * | GetUnqualifiedType () const |
const DataType & | GetUnderlyingType () const |
const DataType & | GetElementType () const |
const DataTypeImpl * | GetDecayedType () const |
Bool | HasTypeArguments () const |
const TypeArguments & | GetTypeArguments () const |
const ParametricTypeInterface * | GetParametricType () const |
const SimdInfo & | GetSimdInfo () const |
const NonvirtualInterfaceImplementation * | GetImplementation () const |
const InterfaceDefinition *const * | GetInterfaces () const |
const Generic * | GetNullValue () const |
Result< void * > | Create () const |
void | Construct (void *dest) const |
void | Construct (void *dest, Int dstride, Int count) const |
void | Destruct (const void *dest) const |
void | Destruct (const void *dest, Int dstride, Int count) const |
void | MoveConstruct (void *dest, void *src) const |
void | MoveConstruct (void *dest, Int dstride, void *src, Int sstride, Int count) const |
void | MoveFrom (void *dest, void *src) const |
void | MoveFrom (void *dest, Int dstride, void *src, Int sstride, Int count) const |
Result< void > | CopyFrom (void *dest, const void *src) const |
Result< void > | CopyFrom (void *dest, Int dstride, const void *src, Int sstride, Int count) const |
void | AddReference (const void *obj) const |
void | RemoveReference (const void *obj) const |
String | ToString (const void *s, const FormatStatement *formatStatement) const |
Bool | IsEqual (const void *s1, const void *s2, EQUALITY equality) const |
COMPARERESULT | Compare (const void *s1, const void *s2) const |
HashInt | GetHashCode (const void *s1) const |
UniqueHash | GetUniqueHashCode (const void *s1) const |
Result< void > | DescribeIO (const DataSerializeInterface &stream) const |
Result< void > | PrivateRegister () const |
void | PrivateSetStructType (const TupleDataType &tupleType, const Int *offsets) |
void | PrivateSetTypeArgs (StrongRef< const TypeArguments > &&args) |
const StrongRef< const DataTypeImpl > & | PrivateGetExtraType () const |
Result< void > | InitializeNullValue () |
Protected Types | |
enum class | FLAGS { NONE , GLOBALLY_REFERENCED , OWNS_NULL_VALUE } |
Protected Member Functions | |
enum maxon::DataTypeImpl::FLAGS | MAXON_ENUM_FLAGS_CLASS (FLAGS) |
~DataTypeImpl () | |
void | ResetRefs () |
void | ResetNullValue () |
MAXON_DISALLOW_COPY_AND_ASSIGN (DataTypeImpl) | |
void | AddReference () const |
void | RemoveReference () const |
Protected Attributes | |
const Id | _id |
const Int | _size |
const Int | _alignment |
VALUEKIND | _valueKind |
FLAGS | _flags |
StrongRef< const DataTypeImpl > | _underlying |
StrongRef< const DataTypeImpl > | _elementType |
StrongRef< const DataTypeImpl > | _extraType |
const ParametricTypeInterface * | _parametricType |
union { | |
const NonvirtualInterfaceImplementation * _implementation | |
const InterfaceDefinition *const * _interfaces | |
const TypeArguments * _typeArgs | |
} | MAXON_ENUM_FLAGS_CLASS |
const void * | _conversions [3] |
const Generic * | _nullValue |
void(*const | _construct )(const DataTypeImpl *type, void *dest, Int dstride, Int count) |
void(*const | _destruct )(const DataTypeImpl *type, const void *dest, Int dstride, Int count) |
void(*const | _moveConstruct )(const DataTypeImpl *type, void *dest, Int dstride, void *src, Int sstride, Int count) |
void(*const | _moveFrom )(const DataTypeImpl *type, void *dest, Int dstride, void *src, Int sstride, Int count) |
Result< void >(*const | _copyFrom )(const DataTypeImpl *type, void *dest, Int dstride, const void *src, Int sstride, Int count) |
void(*const | _addReference )(const DataTypeImpl *type, const void *obj) |
void(*const | _removeReference )(const DataTypeImpl *type, const void *obj) |
String(*const | _toString )(const DataTypeImpl *type, const void *s, const FormatStatement *formatStatement) |
Bool(*const | _isEqual )(const DataTypeImpl *type, const void *s1, const void *s2, EQUALITY equality) |
COMPARERESULT(*const | _compare )(const DataTypeImpl *type, const void *s1, const void *s2) |
HashInt(*const | _getHashCode )(const DataTypeImpl *type, const void *s1) |
UniqueHash(*const | _getUniqueHashCode )(const DataTypeImpl *type, const void *s1) |
Result< void >(* | _describeIO )(const DataTypeImpl *type, const DataSerializeInterface &stream) |
Result< void * >(*const | _newInstance )(const DataTypeImpl *type) |
Result< void >(*const | _initData )(const DataTypeImpl *type, DataMemBlock *mem) |
void(*const | _freeData )(const DataTypeImpl *type, DataMemBlock *mem) |
Result< void >(*const | _copyData )(const DataTypeImpl *type, DataMemBlock *d, const DataMemBlock *s) |
Result< void >(*const | _initCopyData )(const DataTypeImpl *type, DataMemBlock *d, const DataMemBlock *s) |
void(*const | _moveData )(const DataTypeImpl *type, DataMemBlock *d, DataMemBlock *s) |
void(*const | _initMoveData )(const DataTypeImpl *type, DataMemBlock *d, DataMemBlock *s) |
const void *(*const | _getPtr )(const DataTypeImpl *type, const DataMemBlock *s) |
Bool(*const | _isEqualData )(const DataTypeImpl *type, const DataMemBlock *s1, const DataMemBlock *s2, EQUALITY equality) |
Private Member Functions | |
Result< void > | InitData (DataMemBlock *mem) const |
void | FreeData (DataMemBlock *mem) const |
Result< void > | CopyData (DataMemBlock *d, const DataMemBlock *s) const |
Result< void > | InitCopyData (DataMemBlock *d, const DataMemBlock *s) const |
void | MoveData (DataMemBlock *d, DataMemBlock *s) const |
void | InitMoveData (DataMemBlock *d, DataMemBlock *s) const |
Bool | IsEqualData (const DataMemBlock *s1, const DataMemBlock *s2, EQUALITY equality) const |
const void * | GetPtr (const DataMemBlock *s) const |
void | PrivateAddReference () const |
void | PrivateRemoveReference () const |
Friends | |
class | Data |
class | DataType |
class | DataTypeCache |
class | DataTypeLibImpl |
class | ObjectModel |
class | StrongRefHandler |
class | NonvirtualInterfaceReference |
|
strongprotected |
Enumerator | |
---|---|
NONE | |
GLOBALLY_REFERENCED | The data type is globally referenced and AddReference() and RemoveReference() should not access its reference counter. |
OWNS_NULL_VALUE |
DataTypeImpl | ( | const Id & | type, |
const DataTypeImpl * | underlying, | ||
const DataTypeImpl * | element, | ||
const T * | nullValue, | ||
const C * | dummy, | ||
VALUEKIND | flags = VALUEKIND::NONE , |
||
const NonvirtualInterfaceImplementation * | impl = nullptr , |
||
VALUEKIND | kind = ValueKindHelper<T, GetDirectlyReferencedType<T>::value>::KIND , |
||
const ParametricTypeInterface * | pt = nullptr , |
||
const DataTypeImpl * | extra = nullptr |
||
) |
Constructs a DataTypeImpl for T and sets the functions pointers to the implementations found in C.
T | Type which this DataType shall represent. |
C | Class which implements the DataType functions as static functions. |
[in] | type | Unique id of the data type. |
[in] | underlying | The underlying, layout-compatible type, may be nullptr. |
[in] | element | The element type (used e.g. for arrays or pointers), may be nullptr. |
[in] | nullValue | Pointer to a default-constructed object of type T. The lifetime needs to be longer than the lifetime of the constructed DataTypeImpl object. |
[in] | dummy | Dummy variable to determine C. |
[in] | flags | Extra flags for the VALUEKIND of the datatype. |
[in] | impl | Pointer to the implementation if the datatype stands for a non-virtual interface, otherwise nullptr. |
[in] | kind | The VALUEKIND of the datatype, by default set to the value determined by ValueKindHelper. |
DataTypeImpl | ( | const Id & | type, |
const DataTypeImpl * | underlying, | ||
const DataTypeImpl * | element, | ||
const void * | nullValue, | ||
Int | size, | ||
Int | alignment, | ||
const C * | dummy, | ||
VALUEKIND | kind, | ||
const ParametricTypeInterface * | pt = nullptr , |
||
const DataTypeImpl * | extra = nullptr |
||
) |
Constructs a DataTypeImpl and sets the functions pointers to the implementations found in C.
[in] | type | Unique id of the data type. |
[in] | underlying | The underlying, layout-compatible type, may be nullptr. |
[in] | element | The element type (used e.g. for arrays or pointers), may be nullptr. |
[in] | nullValue | Pointer to a default-constructed object of the type. The lifetime needs to be longer than the lifetime of the constructed DataTypeImpl object. |
[in] | size | The size of the type. |
[in] | alignment | The alignment of the type. |
[in] | dummy | Dummy variable to determine C. |
[in] | kind | The complete VALUEKIND of the datatype. |
[in] | pt | The parametric type which instantiates the DataType, may be nullptr. |
DataTypeImpl | ( | ) |
DataTypeImpl | ( | const DataTypeImpl & | src, |
const Id & | typeId, | ||
VALUEKIND | qualification, | ||
const ParametricTypeInterface * | pt, | ||
VALUEKIND | remove = VALUEKIND::NONE , |
||
Bool | copyTypeArgs = true , |
||
const DataTypeImpl * | element = nullptr |
||
) |
|
protected |
const Id& GetId | ( | ) | const |
Returns the identifier of this data type. Data type identifiers of primary types look like int32
, pointer types are identified by a * suffix as in {float64*}, tuple types by a parenthesized list of its member types as in
{(int32,float64*)}.
String ToString | ( | const FormatStatement * | formatStatement = nullptr | ) | const |
Int GetSize | ( | ) | const |
Returns the size of values of this data type.
Int GetAlignment | ( | ) | const |
Returns the alignment of values of this data type. This might by an extended alignment.
VALUEKIND GetValueKind | ( | ) | const |
Returns the kind of values of this data type. This is a coarse classification to distinguish between e.g. value types, pointers, references, arrays and tuples.
Tests the value kind of this data type for the given flags (by using the bitwise and).
[in] | test | The flags to test. |
const DataTypeImpl* GetUnqualifiedType | ( | ) | const |
Returns the unqualified type of this data type. Currently the only possible qualification is a const qualification. So when this data type represents const T, the returned data type represents T. If the type is already an unqualified type, this functions returns the type itself.
const DataType& GetUnderlyingType | ( | ) | const |
Returns the underlying type of this data type. The underlying data type is a layout-compatible more fundamental type, such as the unqualified version T for const T, or the tuple type Tuple<T, T, T> for Vec3<T>.
const DataType& GetElementType | ( | ) | const |
Returns the element type of this data type. The element type is used for some parametric types such as pointers or references, so for example the element type of {T*} or
{StrongRef<T>} is
T
.
const DataTypeImpl* GetDecayedType | ( | ) | const |
Returns the decayed type of this data type (in the sense of std::decay). I.e., at first this removes any l- or r-value-reference-qualification, and then it returns the unqualified type of the result.
Bool HasTypeArguments | ( | ) | const |
Returns true if this data type has valid type arguments, so that it is legal to call GetTypeArguments(). Even with HasTypeArguments() returning true, GetTypeArguments().count can be 0 for types like ArrayContainer<>. Hence one often has to perform this kind of double validation.
const TypeArguments& GetTypeArguments | ( | ) | const |
Returns the type arguments of this data type. Type arguments are set for some instantiations of parametric types. For example, the 3-dimensional Vector is an instantiation of the parametric type Vec with the arguments (Float, 3).
const ParametricTypeInterface* GetParametricType | ( | ) | const |
Returns the parametric type which instantiated this type. For example if this type is Vector, the function returns the parametric type Vec.
const SimdInfo& GetSimdInfo | ( | ) | const |
const NonvirtualInterfaceImplementation* GetImplementation | ( | ) | const |
Returns the interface implementation of this type as nullptr-terminated array. This function may only be invoked if this type is an interface type.
const InterfaceDefinition* const* GetInterfaces | ( | ) | const |
Returns the interfaces of this object type as nullptr-terminated array. This function may only be invoked if this type is an object type.
const Generic* GetNullValue | ( | ) | const |
Returns a pointer to a default-constructed object of this type.
Result<void*> Create | ( | ) | const |
Creates a new instance of this type.
void Construct | ( | void * | dest | ) | const |
Construct a value of this type starting at dest
. Each value will be constructed using its default constructor.
[in,out] | dest | Pointer to the value. |
Constructs count
values of this type starting at dest
. Each value will be constructed using its default constructor.
[in,out] | dest | Pointer to the destination array. |
[in] | dstride | Stride in bytes between consecutive elements. |
[in] | count | Number of values to construct in the destination array. |
void Destruct | ( | const void * | dest | ) | const |
Destructs a value of this type starting at dest
.
[in,out] | dest | Pointer to the value. |
Destructs count
values of this type starting at dest
.
[in,out] | dest | Pointer to the destination array. |
[in] | dstride | Stride in bytes between consecutive elements. |
[in] | count | Number of values to destruct in the destination array. |
void MoveConstruct | ( | void * | dest, |
void * | src | ||
) | const |
Move-constructs a value of this type at dest
using the source value at src
. This will be done by the move constructor of the underlying type which might modify src
.
[in,out] | dest | Pointer to the destination value. |
[in,out] | src | Pointer to the source value. |
Move-constructs count
values of this type starting at dest
using source values starting at src
. This will be done by the move constructor of the underlying type which might modify src
.
[in,out] | dest | Pointer to the destination array. |
[in] | dstride | Stride in bytes between consecutive destination elements. |
[in,out] | src | Pointer to the source array. |
[in] | sstride | Stride in bytes between consecutive source elements. |
[in] | count | Number of values to move-construct in the destination array. |
void MoveFrom | ( | void * | dest, |
void * | src | ||
) | const |
Moves a value of this type at dest
from the source value at src
. This will be done by the move assignment operator of the underlying type which might modify src
. The objects must not overlap.
[in,out] | dest | Pointer to the destination value. |
[in,out] | src | Pointer to the source value. |
Moves count
values of this type starting at dest
from source values starting at src
. This will be done by the move assignment operator of the underlying type which might modify src
. The blocks must not overlap.
[in,out] | dest | Pointer to the destination array. |
[in] | dstride | Stride in bytes between consecutive destination elements. |
[in,out] | src | Pointer to the source array. |
[in] | sstride | Stride in bytes between consecutive source elements. |
[in] | count | Number of values to move to the destination array. |
Result<void> CopyFrom | ( | void * | dest, |
const void * | src | ||
) | const |
Copies a value of this type to dest
using the source value at src
. This will be done by the CopyFrom function of the underlying type if available, otherwise by the assignment operator.
[in,out] | dest | Pointer to the destination value. |
[in,out] | src | Pointer to the source value. |
Copies count
values of this type starting at dest
using source values starting at src
. This will be done by the CopyFrom function of the underlying type if available, otherwise by the assignment operator.
[in,out] | dest | Pointer to the destination array. |
[in] | dstride | Stride in bytes between consecutive destination elements. |
[in] | src | Pointer to the source array. |
[in] | sstride | Stride in bytes between consecutive source elements. |
[in] | count | Number of values to copy to the destination array. |
void AddReference | ( | const void * | obj | ) | const |
Adds a reference to the given object. This increments the reference counter by one.
[in] | obj | Pointer to an object of this data type. |
void RemoveReference | ( | const void * | obj | ) | const |
Removes a reference from the given object and frees the object if necessary. This decrements the reference counter by one. If the counter reaches zero, the object is freed.
[in] | obj | Pointer to an object of this data type. |
String ToString | ( | const void * | s, |
const FormatStatement * | formatStatement | ||
) | const |
Returns a readable string from a value of this data type.
[in] | s | Pointer to the native data. |
[in] | formatStatement | The formatting instruction. |
Compares two values of this data type for equality.
[in] | s1 | Pointer to the native data of argument 1. |
[in] | s2 | Pointer to the native data of argument 2. |
[in] | equality | Mode of comparison. |
COMPARERESULT Compare | ( | const void * | s1, |
const void * | s2 | ||
) | const |
Compares two values of this data type.
[in] | s1 | Pointer to the native data of argument 1. |
[in] | s2 | Pointer to the native data of argument 2. |
HashInt GetHashCode | ( | const void * | s1 | ) | const |
Get the HashCode of the value of this data type.
[in] | s1 | Pointer to the native data of argument. |
UniqueHash GetUniqueHashCode | ( | const void * | s1 | ) | const |
Result<void> DescribeIO | ( | const DataSerializeInterface & | stream | ) | const |
Describe all elements of this datatype for I/O operations.
[in] | stream | The stream that is used to register the class members. |
Result<void> PrivateRegister | ( | ) | const |
void PrivateSetStructType | ( | const TupleDataType & | tupleType, |
const Int * | offsets | ||
) |
void PrivateSetTypeArgs | ( | StrongRef< const TypeArguments > && | args | ) |
const StrongRef<const DataTypeImpl>& PrivateGetExtraType | ( | ) | const |
Result<void> InitializeNullValue | ( | ) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
private |
Constructs a memory block. If the value fits in a DataMemBlock, you can use the DataMemBlock memory directly with a placement new. Otherwise you need to allocate your own memory and store its pointer in the DataMemBlock.
[out] | mem | Pointer to the memory block. |
|
private |
Destructs and frees a memory block. If the value fits in a DataMemBlock, you can use the DataMemBlock memory directly with a placement delete. Otherwise you need to delete your own memory which has been allocated previously by one of the Init functions.
[in,out] | mem | Pointer to the memory block. |
|
private |
Copies a Data memory block to another (existing and initialized) memory block.
[in] | s | Source pointer to the memory block. |
[in,out] | d | Destination pointer to the memory block. |
|
private |
Copies a Data memory block into a new memory block.
[in] | s | Source pointer to the memory block. |
[in,out] | d | Destination pointer to the memory block. |
|
private |
Moves a Data memory block to another (existing and initialized) memory block.
[in] | s | Source pointer to the memory block. The value will be moved into the destination, the source will be reset to empty data. |
[in,out] | d | Destination pointer to the memory block. |
|
private |
Move constructs a Data memory block from another block.
[in] | s | Source pointer to the memory block. The value will be moved into the destination, the source will be reset to empty data. |
[in,out] | d | Destination pointer to the memory block. |
|
private |
Compares two values of this data type for equality.
[in] | s1 | Pointer to the native data of argument 1. |
[in] | s2 | Pointer to the native data of argument 2. |
|
private |
Extracts the pointer to the native data from a memory block.
[in] | s | Pointer to the memory block. |
|
private |
|
private |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
Name of the data type.
|
protected |
Size of the data type.
|
protected |
Alignment of the data type.
|
protected |
Value kind.
|
protected |
|
protected |
underlying data type (a layout-compatible more fundamental type, such as the unqualified version or an underlying tuple type)
|
protected |
|
protected |
An additional type-specific base type.
|
protected |
Used for instantiations of parametric types.
const NonvirtualInterfaceImplementation* _implementation |
The interface implementation. Only valid for kind NONVIRTUAL_INTERFACE.
const InterfaceDefinition* const* _interfaces |
nullptr-terminated array of virtual interfaces (excluding ObjectInterface), owned by this DataType. Only valid for kind VIRTUAL_INTERFACE.
const TypeArguments* _typeArgs |
Pointer to the type arguments, uses a strong reference.
union { ... } MAXON_ENUM_FLAGS_CLASS |
|
protected |
This storage is used for a BaseArray<Tuple<DataType, Conversion>> which contains the registered conversion functions.
|
protected |
Pointer to the null value of the type.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |