neuray API Programmer's Manual

mi::Type_traits< typename I> Template Struct Reference

[Types]

template< typename I>

mi::Type_traits< typename I>

Description

Type traits relating interfaces, corresponding primitive types, and their type names. These type traits are defined for two types of template arguments, interfaces and primitive types.

If the template parameter is an interface derived from mi::IData:

  • The static member function get_type_name() returns the type name corresponding to the template parameter, e.g., "Sint32" for the template parameter mi::ISint32.

  • The member typedef Primitive_type is defined to the corresponding primitive type, e.g., mi::Sint32 for the template parameter mi::ISint32.

  • Not supported are mi::IEnum, mi::IPointer, mi::IConst_pointer, interfaces derived from mi::IData_collection with the exception of compounds, and all non-leaf interfaces, e.g., mi::INumber.

Note the following special case for the mapping between primitive types:

Example:

‎ template<> struct Type_traits<mi::ISint32>
 {
     static const char* get_type_name() { return "Sint32"; }
     typedef mi::Sint32 Primitive_type;
 };

If the template parameter is a primitive type:

  • The static member function get_type_name() returns the type name corresponding to the template parameter, e.g., "Sint32" for the template parameter mi::Sint32.

  • The member typedef Interface_type is defined to the corresponding interface type, e.g., mi::ISint32 for the template parameter mi::Sint32.

Since the set of primitive types is smaller than the set of interfaces the following interfaces do not appear as typedef Interface_type: mi::IColor3, mi::IRef, mi::ISize, and mi::IDifference (plus all interfaces which are not supported as template parameter, see above). In particular, a string value does not provide enough to context to decide whether it represents just a string (mi::IString) or references a DB element (mi::IRef).

Example:

‎ template<> struct Type_traits<mi::Sint32>
 {
     static const char* get_type_name() { return "Sint32"; };
     typedef mi::ISint32 Interface_type;
 };

Note:

Note that const char* is the only primitive type that does not have value semantics, but pointer semantics.