Visual Computing Library
Loading...
Searching...
No Matches
VCLib Types Module

The Types module defines all the utility definitions, types, classes and type traits that are common in the library. More...

Collaboration diagram for VCLib Types Module:

Classes

class  vcl::FakePointerWithValue< T >
 A simple utility class to represent a pointer with a value. More...
 
struct  vcl::MakeConstPointer< T >
 Utility type that makes possible to treat const pointers in a templated class that can treat a both const and non-const pointer type. More...
 
struct  vcl::MakeConstPointer< T * >
 Utility type that makes possible to treat const pointers in a templated class that can treat a both const and non-const pointer type. More...
 
struct  vcl::FilterTypesByCondition< typename,... >
 Removes all types that do not satisfy a condition, and get them as a tuple. More...
 
struct  vcl::FilterTypesByCondition< Pred, Head, Tail... >
 Removes all types that do not satisfy a condition, and get them as a tuple. More...
 
struct  vcl::FilterTypesByCondition< Pred, TypeWrapper< Tail... > >
 Removes all types that do not satisfy a condition, and get them as a tuple. More...
 
struct  vcl::TypesSatisfyCondition< Pred, Args >
 Its value is set to true if there is at least one type in the given pack Args... that satisfies the given condition. More...
 
struct  vcl::TypesSatisfyCondition< Pred, TypeWrapper< Args... > >
 Its value is set to true if there is at least one type in the given pack Args... that satisfies the given condition. More...
 
struct  vcl::GetTypeByCondition< Pred, Args >
 The the first type of a pack that satisfies the given condition. More...
 
struct  vcl::GetTypeByCondition< Pred, TypeWrapper< Args... > >
 The the first type of a pack that satisfies the given condition. More...
 
struct  vcl::CompId
 The CompId struct enumerates the components that can compose a element or a mesh. More...
 
struct  vcl::ComponentString< COMP_ID >
 The ComponentString class is used to retrieve the string associated to a COMP_ID value, trough its member 'str'. More...
 
struct  vcl::ElemId
 The ElemId struct enumerates the elements that can compose a mesh. More...
 
struct  vcl::ElementString< ELEM_ID >
 The ElementString class is used to retrieve the string associated to a ELEM_ID value, trough its member 'str'. More...
 
struct  vcl::TypeWrapper< Args >
 A simple structure that wraps a list of variadic templates, without instantiating anything. Useful when you need to wrap a list of types, and consider them as a single type. More...
 
struct  vcl::FirstType< TypeWrapper< Args... > >
 Get the first type of a pack of types (variadic templates) or a TypeWrapper. More...
 
struct  vcl::FirstType< Args >
 Get the first type of a pack of types (variadic templates) or a TypeWrapper. More...
 
struct  vcl::ForEachType< T >
 Allows to apply a function to each type in a variadic template pack. More...
 
class  vcl::View< It >
 The View class is a simple class that stores and exposes two iterators begin and end. More...
 

Typedefs

template<typename T >
using vcl::MakeConstPointerT = typename MakeConstPointer< T >::type
 Utility alias for the MakeConstPointer type.
 
template<typename derived , template< typename... > class base>
using vcl::IsDerivedFromTemplateSpecialization = std::invoke_result< detail::IsDerivedFromImplementation< base >, typename std::remove_cv< derived >::type * >::type
 Utility class that allows to check if given class 'Derived' is derived from a specialization of a templated class.
 
template<typename T >
using vcl::RemovePtr = std::remove_pointer_t< T >
 Utility alias to get a type without the pointer. e.g. If T is int*, the resulting type is int.
 
template<typename T >
using vcl::RemoveRef = std::remove_reference_t< T >
 Utility alias to get a type type without the reference. e.g. If T is int&, the resulting type is int.
 
template<typename T >
using vcl::RemoveCVRefAndPointer = std::remove_cvref_t< RemovePtr< T > >
 Utility alias to get clean type from an input type that could have a reference or a pointer.
 
template<typename T >
using vcl::RemoveConstFromPointer = std::conditional_t< std::is_pointer_v< T >, std::add_pointer_t< std::remove_cv_t< RemovePtr< T > > >, T >
 Utility alias to get a pointer type without the constness. e.g. If T is const int*, the resulting type is int* If the type is not a pointer, it is left as it was.
 
template<typename... Args>
using vcl::FirstTypeT = typename FirstType< Args... >::type
 Alias for the type of the first type in a pack of types.
 

Enumerations

enum class  vcl::PrimitiveType {
  CHAR , UCHAR , SHORT , USHORT ,
  INT , UINT , FLOAT , DOUBLE ,
  NONE
}
 A simple type that enumerates the main primitive types. More...
 
enum class  vcl::MatrixStorageType { ROW_MAJOR , COLUMN_MAJOR }
 A simple type that enumerates the main storage types for matrices (row or column major).
 

Functions

template<typename T >
constexpr T & vcl::asConst (const T &value) noexcept
 Utility function that converts a const pointer/reference to a non-const pointer/reference.
 
template<typename T >
constexpr T * vcl::asConst (const T *value) noexcept
 Utility function that converts a const pointer/reference to a non-const pointer/reference.
 
template<typename T >
constexpr T * vcl::asConst (T *value) noexcept
 Utility function that converts a const pointer/reference to a non-const pointer/reference.
 
template<uint COMP_ID>
constexpr const charvcl::componentEnumString ()
 Returns the string associated to the COMP_ID value.
 
template<uint ELEM_ID>
constexpr const charvcl::elementEnumCString ()
 Returns the string associated to the ELEM_ID value.
 
template<uint ELEM_ID>
const std::string & vcl::elementEnumString ()
 Returns the string associated to the ELEM_ID value.
 
template<typename T >
autovcl::dereferencePtr (T &&obj)
 Utility function that applies the unary operator '*' to the argument only if the object is a pointer, and returns a reference to the object itself.
 
template<typename T >
auto vcl::addressOfObj (T &obj)
 Utility function that applies the unary operator '&' to the argument only if it is not a pointer.
 
template<typename T , typename U , typename... Us>
constexpr uint vcl::indexInTypePack ()
 Function that returns the index of a Type T in a pack of types (variadic templates). The pack is composed of U and Us...
 
template<typename U , typename... Us>
uint vcl::indexInTypePack (std::type_index ti)
 Function that returns the index of the type having the given type_index in a pack of types (variadic templates). The pack is composed of U and Us...
 

Variables

constexpr uint vcl::UINT_NULL = std::numeric_limits<uint>::max()
 The UINT_NULL value represent a null value of uint that is the maximum value that can be represented with unsigned int.
 
constexpr const charvcl::COMPONENT_ENUM_STRINGS [CompId::COMPONENTS_NUMBER]
 The COMPONENT_ENUM_STRINGS array contains the string representation of the CompId::Enum values.
 
constexpr const charvcl::ELEMENT_ENUM_STRINGS [ElemId::ELEMENTS_NUMBER]
 The ELEMENT_ENUM_STRINGS array contains the string representation of the elements that can compose a mesh.
 

Detailed Description

The Types module defines all the utility definitions, types, classes and type traits that are common in the library.

This module does not depend on any other module of the library, and it is used by all the other modules to define the types that are used in the library.

You can access all the types of VCLib by including #include <vclib/types.h>

Typedef Documentation

◆ FirstTypeT

template<typename... Args>
using vcl::FirstTypeT = typedef typename FirstType<Args...>::type

Alias for the type of the first type in a pack of types.

Usage:

static_assert(std::is_same<ResType, int>::value, "");
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43

◆ IsDerivedFromTemplateSpecialization

template<typename derived , template< typename... > class base>
using vcl::IsDerivedFromTemplateSpecialization = typedef std::invoke_result< detail::IsDerivedFromImplementation<base>, typename std::remove_cv<derived>::type*>::type

Utility class that allows to check if given class 'Derived' is derived from a specialization of a templated class.

Given a class X and a templated class C<template T>, it can be used in the following way:

if constexpr (myCheck::value) { ... }
std::invoke_result< detail::IsDerivedFromImplementation< base >, typename std::remove_cv< derived >::type * >::type IsDerivedFromTemplateSpecialization
Utility class that allows to check if given class 'Derived' is derived from a specialization of a tem...
Definition inheritance.h:69

and will return true if X derives from any specialization of C.

Template Parameters
derivedThe class to be checked.
baseThe templated class to be checked.

◆ MakeConstPointerT

Utility alias for the MakeConstPointer type.

Template Parameters
TThe type to be converted to a const pointer.

◆ RemoveConstFromPointer

template<typename T >
using vcl::RemoveConstFromPointer = typedef std::conditional_t< std::is_pointer_v<T>, std::add_pointer_t<std::remove_cv_t<RemovePtr<T> >>, T>

Utility alias to get a pointer type without the constness. e.g. If T is const int*, the resulting type is int* If the type is not a pointer, it is left as it was.

Template Parameters
TThe input type.

◆ RemoveCVRefAndPointer

template<typename T >
using vcl::RemoveCVRefAndPointer = typedef std::remove_cvref_t<RemovePtr<T> >

Utility alias to get clean type from an input type that could have a reference or a pointer.

Template Parameters
TThe input type.

◆ RemovePtr

template<typename T >
using vcl::RemovePtr = typedef std::remove_pointer_t<T>

Utility alias to get a type without the pointer. e.g. If T is int*, the resulting type is int.

It corresponds to std::remove_pointer_t.

Template Parameters
TThe input type.

◆ RemoveRef

template<typename T >
using vcl::RemoveRef = typedef std::remove_reference_t<T>

Utility alias to get a type type without the reference. e.g. If T is int&, the resulting type is int.

It corresponds to std::remove_reference_t.

Template Parameters
TThe input type.

Enumeration Type Documentation

◆ PrimitiveType

A simple type that enumerates the main primitive types.

It is used mostly for I/O operations, but can be useful in any context where a type must be described in a variable at runtime.

Function Documentation

◆ addressOfObj()

template<typename T >
auto vcl::addressOfObj ( T &  obj)

Utility function that applies the unary operator '&' to the argument only if it is not a pointer.

Parameters
obj
Returns
the address of 'obj' if obj is not a pointer, or obj if it is a pointer.

◆ asConst() [1/3]

template<typename T >
constexpr T & vcl::asConst ( const T &  value)
constexprnoexcept

Utility function that converts a const pointer/reference to a non-const pointer/reference.

It is useful when you need to re-use the same code for const and non-const member functions.

Warning
The function should be used only in contexts where the constness of the pointer/reference is guaranteed to be removed (see const_cast).
Template Parameters
TThe type of the pointer/reference.
Parameters
[in]valueThe const pointer/reference to be const-casted.
Returns
The non-const pointer/reference.

◆ asConst() [2/3]

template<typename T >
constexpr T * vcl::asConst ( const T *  value)
constexprnoexcept

Utility function that converts a const pointer/reference to a non-const pointer/reference.

It is useful when you need to re-use the same code for const and non-const member functions.

Warning
The function should be used only in contexts where the constness of the pointer/reference is guaranteed to be removed (see const_cast).
Template Parameters
TThe type of the pointer/reference.
Parameters
[in]valueThe const pointer/reference to be const-casted.
Returns
The non-const pointer/reference.

◆ asConst() [3/3]

template<typename T >
constexpr T * vcl::asConst ( T *  value)
constexprnoexcept

Utility function that converts a const pointer/reference to a non-const pointer/reference.

It is useful when you need to re-use the same code for const and non-const member functions.

Warning
The function should be used only in contexts where the constness of the pointer/reference is guaranteed to be removed (see const_cast).
Template Parameters
TThe type of the pointer/reference.
Parameters
[in]valueThe const pointer/reference to be const-casted.
Returns
The non-const pointer/reference.

◆ componentEnumString()

template<uint COMP_ID>
constexpr const char * vcl::componentEnumString ( )
constexpr

Returns the string associated to the COMP_ID value.

Template Parameters
COMP_IDan unsigned integer that identifies the component.
Returns
The string associated to the COMP_ID value.

◆ dereferencePtr()

template<typename T >
auto & vcl::dereferencePtr ( T &&  obj)

Utility function that applies the unary operator '*' to the argument only if the object is a pointer, and returns a reference to the object itself.

Parameters
[in]objThe object to dereference.
Returns
a reference to obj if it is not a pointer, or a reference to *obj if it is a pointer.

◆ elementEnumCString()

template<uint ELEM_ID>
constexpr const char * vcl::elementEnumCString ( )
constexpr

Returns the string associated to the ELEM_ID value.

Template Parameters
ELEM_IDan unsigned integer that identifies the element.
Returns
The string associated to the ELEM_ID value.

◆ elementEnumString()

template<uint ELEM_ID>
const std::string & vcl::elementEnumString ( )

Returns the string associated to the ELEM_ID value.

Template Parameters
ELEM_IDan unsigned integer that identifies the element.
Returns
The string associated to the ELEM_ID value.

◆ indexInTypePack()

template<typename U , typename... Us>
uint vcl::indexInTypePack ( std::type_index  ti)

Function that returns the index of the type having the given type_index in a pack of types (variadic templates). The pack is composed of U and Us...

Parameters
tithe type_index of the type to search.

Variable Documentation

◆ COMPONENT_ENUM_STRINGS

constexpr const char* vcl::COMPONENT_ENUM_STRINGS[CompId::COMPONENTS_NUMBER]
constexpr
Initial value:
= {
"BitFlags",
"Coordinate",
"Normal",
"Color",
"Quality",
"Mark",
"PrincipalCurvature",
"TexCoord",
"VertexPointers",
"AdjacentEdges",
"AdjacentFaces",
"AdjacentVertices",
"WedgeColors",
"WedgeTexCoords",
"BoundingBox",
"Name",
"TextureImages",
"TexturePaths",
"TransformMatrix",
"CustomComponents",
}

The COMPONENT_ENUM_STRINGS array contains the string representation of the CompId::Enum values.

◆ ELEMENT_ENUM_STRINGS

constexpr const char* vcl::ELEMENT_ENUM_STRINGS[ElemId::ELEMENTS_NUMBER]
constexpr
Initial value:
= {
"Vertex",
"Face",
"Edge",
}

The ELEMENT_ENUM_STRINGS array contains the string representation of the elements that can compose a mesh.

◆ UINT_NULL

constexpr uint vcl::UINT_NULL = std::numeric_limits<uint>::max()
constexpr

The UINT_NULL value represent a null value of uint that is the maximum value that can be represented with unsigned int.

Allows to fully use all the possible values (except one) that can be represented in an unsigned int, but with the possibility to flag whether the value is not initialized or is set to null.