ParametricTypeInterface Class Reference

#include <parametric_type.h>

Detailed Description

A ParametricType instantiates a new DataType from a number of more elementary data types. For example, ParametricTypes::Vec instantiates a vector type from its element type and the number of dimensions, ParametricTypes::Tuple instantiates a tuple type from member types, and ParametricTypes::Const instantiates the const-qualified version of a given type. Possible parameters of a ParametricType are not only types, but also Members (type/id pairs) and integers.

Public Member Functions

MAXON_METHOD const IdGetId () const
 
MAXON_METHOD Result< DataTypeInstantiate (const Block< const Member > &args, const Block< const Int64 > &iargs=GetZeroRef< Block< const Int64 >>()) const
 
MAXON_FUNCTION Result< DataTypeInstantiate (const DataType &type, const Block< const Int64 > &iargs=GetZeroRef< Block< const Int64 >>()) const
 
MAXON_FUNCTION Result< DataTypeInstantiate (Result< DataType > &&type, const Block< const Int64 > &iargs=GetZeroRef< Block< const Int64 >>()) const
 
MAXON_FUNCTION Result< DataTypeInstantiate (const Block< const DataType > &types, const Block< const Int64 > &iargs=GetZeroRef< Block< const Int64 >>()) const
 
MAXON_FUNCTION Result< DataTypePrivateInstantiate (Block< Result< DataType >> &&types) const
 
MAXON_METHOD Bool IsBaseOfOrSame (const DataType &type, const DataType &other) const
 
MAXON_METHOD Result< void > Convert (const DataPtr &dest, const ConstDataPtr &src, CONVERSION_FLAGS ignore) const
 
MAXON_METHOD Result< Tuple< DataType, const Char * > > Parse (const Char *params) const
 
MAXON_METHOD void ResetInstantiated (DataTypeImpl *type) const
 
MAXON_METHOD DataTypeImpl *& GetLeakingLink (DataTypeImpl *type) const
 

Private Member Functions

 MAXON_INTERFACE_SIMPLE_VIRTUAL (ParametricTypeInterface, MAXON_REFERENCE_CONST_POINTER)
 

Member Function Documentation

◆ MAXON_INTERFACE_SIMPLE_VIRTUAL()

MAXON_INTERFACE_SIMPLE_VIRTUAL ( ParametricTypeInterface  ,
MAXON_REFERENCE_CONST_POINTER   
)
private

◆ GetId()

MAXON_METHOD const Id& GetId ( ) const

Returns the identifier of the parametric type. Usually this is also used as prefix for the identifiers of instantiates types, but there are exceptions for basic parametric types such as for const, tuples or arrays.

Returns
Identifier of parametric type.

◆ Instantiate() [1/4]

MAXON_METHOD Result<DataType> Instantiate ( const Block< const Member > &  args,
const Block< const Int64 > &  iargs = GetZeroRef< Block< const Int64 >>() 
) const

Instantiates this parametric type for the given arguments. This is the general method which supports members and integers as arguments, you can use one of the simpler overloads for common cases like type-only arguments.

Parameters
[in]argsThe arguments for Member parameters of this parametric type. The identifier part of a Member has to be left empty if the parametric type needs a DataType only.
[in]iargsThe arguments for Int64 parameters of this parametric type (for example the dimension of a vector).
Returns
The instantiated DataType for the given arguments.

◆ Instantiate() [2/4]

MAXON_FUNCTION Result<DataType> Instantiate ( const DataType type,
const Block< const Int64 > &  iargs = GetZeroRef< Block< const Int64 >>() 
) const

Instantiates this parametric type for the given arguments. This overload can be used for parametric types with a single DataType parameter (plus optionally some integer parameters).

Parameters
[in]typeThe argument for the single DataType parameter of this parametric type.
[in]iargsThe optional arguments for Int64 parameters of this parametric type.
Returns
The instantiated DataType for the given arguments.

◆ Instantiate() [3/4]

MAXON_FUNCTION Result<DataType> Instantiate ( Result< DataType > &&  type,
const Block< const Int64 > &  iargs = GetZeroRef< Block< const Int64 >>() 
) const

Instantiates this parametric type for the given arguments. This overload can be used for parametric types with a single DataType parameter (plus optionally some integer parameters). For convenience the type parameter of this overload supports Result<DataType>, so you can directly pass the result of some other function with Result<DataType> return type to this parameter.

Parameters
[in]typeThe argument for the single DataType parameter of this parametric type.
[in]iargsThe optional arguments for Int64 parameters of this parametric type.
Returns
The instantiated DataType for the given arguments.

◆ Instantiate() [4/4]

MAXON_FUNCTION Result<DataType> Instantiate ( const Block< const DataType > &  types,
const Block< const Int64 > &  iargs = GetZeroRef< Block< const Int64 >>() 
) const

Instantiates this parametric type for the given arguments. This overload can be used for parametric types with a number of DataType parameters (plus optionally some integer parameters).

Parameters
[in]typesThe arguments for the DataType parameters of this parametric type.
[in]iargsThe optional arguments for Int64 parameters of this parametric type.
Returns
The instantiated DataType for the given arguments.

◆ PrivateInstantiate()

MAXON_FUNCTION Result<DataType> PrivateInstantiate ( Block< Result< DataType >> &&  types) const

◆ IsBaseOfOrSame()

MAXON_METHOD Bool IsBaseOfOrSame ( const DataType type,
const DataType other 
) const

Checks if the given type is a base type of the other type (or the same). At least one of the types is an instantiation of this parametric type. This method is invoked from DataType::IsBaseOfOrSame, and when type and other have different parametric types, it will be invoked twice, once for each parametric type. If at least one of these invocations returns true, the result of DataType::IsBaseOfOrSame is true.

Parameters
[in]typeA data type.
[in]otherAnother data type.
Returns
True if type is a base type of other.

◆ Convert()

MAXON_METHOD Result<void> Convert ( const DataPtr dest,
const ConstDataPtr src,
CONVERSION_FLAGS  ignore 
) const

Converts the value src to the value #dest (the type of which has to be an instantiation of this parametric type).

Parameters
[in]destThe destination value, it has to use an instantiation of this parametric type.
[in]srcThe source value.
[in]ignoreOnly those conversions are taken into account whose conversion flags aren't set in #ignore.
Returns
OK on success. If there is no conversion from the source type at all, an UnsupportedArgumentError is returned. For narrowing conversions other errors may occur, such as when the representable range is exceeded.

◆ Parse()

MAXON_METHOD Result<Tuple<DataType, const Char*> > Parse ( const Char params) const

Parses an instantiation of this parametric type from a part of a data type identifier. params points to the first character after the opening angular bracket. The returned character pointer has to point to the closing angular bracket. For example, when the full data type identifier is "net.maxon.parametrictype.vec<3,float32>" the Parse method of ParametricTypes::Vec will be called with params pointing to "3", and it returns the data type of Vector32 plus a character pointer to ">".

Parameters
[in]paramsPointer to a part of a data type identifier.
Returns
Tuple of the parsed data type instantiation and a pointer to the closing angular bracket.

◆ ResetInstantiated()

MAXON_METHOD void ResetInstantiated ( DataTypeImpl type) const

◆ GetLeakingLink()

MAXON_METHOD DataTypeImpl*& GetLeakingLink ( DataTypeImpl type) const