Visual Computing Library
devel
|
The Base module defines all the utility definitions, types, classes and type traits that are common in the library. More...
Concepts | |
concept | vcl::LoggerConcept |
The LoggerConcept is satisfied if the type T is a valid Logger type. | |
Classes | |
class | vcl::AbstractLogger |
The AbstractLogger class is used as common ancestor class for all the logger types in the library. 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::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::ElemId |
The ElemId struct enumerates the elements that can compose a mesh. More... | |
class | vcl::FakePointerWithValue< T > |
A simple utility class to represent a pointer with a value. More... | |
struct | vcl::FilterTypesByCondition< typename,... > |
Removes all types that do not satisfy a condition, and get them as a TypeWrapper. More... | |
struct | vcl::FilterTypesByCondition< Pred, Head, Tail... > |
Removes all types that do not satisfy a condition, and get them as a TypeWrapper. More... | |
struct | vcl::FilterTypesByCondition< Pred, TypeWrapper< Tail... > > |
Removes all types that do not satisfy a condition, and get them as a TypeWrapper. More... | |
struct | vcl::FirstType< Args > |
Get the first type of a pack of types (variadic templates) or a TypeWrapper. More... | |
struct | vcl::FirstType< TypeWrapper< 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... | |
struct | vcl::ForEachType< TypeWrapper< T... > > |
Allows to apply a function to each type in a variadic template pack. More... | |
struct | vcl::GetTypeByCondition< Pred, Args > |
Sets type to the first type of a pack that satisfies the given condition. More... | |
struct | vcl::GetTypeByCondition< Pred, TypeWrapper< Args... > > |
Sets type to the first type of a pack that satisfies the given condition. More... | |
struct | vcl::IndexInTypes< T, Us > |
Get the index of a type T in a pack of types (variadic templates) or a TypeWrapper. More... | |
struct | vcl::IndexInTypes< T, TypeWrapper< Us... > > |
Get the index of a type T in a pack of types (variadic templates) or a TypeWrapper. More... | |
struct | vcl::IsDerivedFromSpecializationOf< T, Template > |
Trait to check if a type is derived from a specialization of a given template. More... | |
struct | vcl::IsSpecializationOf< T, Template > |
Trait to check if a type is a specialization of a given template. 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... | |
class | vcl::NullLogger |
The NullLogger class is used as default type in all the library functions that take as input a logger type. More... | |
struct | vcl::NumberOfTypes< Args > |
Get the number of types in a pack of types (variadic templates) or a TypeWrapper. More... | |
struct | vcl::NumberOfTypes< TypeWrapper< Args... > > |
Get the number of types in a pack of types (variadic templates) or a TypeWrapper. More... | |
struct | vcl::OneTypeAtLeastSatisfiesCondition< Pred, Args > |
Sets its value to true if there is at least one type in the given pack Args... that satisfies the given condition. More... | |
struct | vcl::OneTypeAtLeastSatisfiesCondition< Pred, TypeWrapper< Args... > > |
Sets its value to true if there is at least one type in the given pack Args... that satisfies the given condition. More... | |
struct | vcl::TypeAt< I, T > |
Get the type at a given index in a pack of types (variadic templates) or a TypeWrapper. More... | |
struct | vcl::TypeAt< I, TypeWrapper< T... > > |
Get the type at a given index in a pack of types (variadic templates) or a TypeWrapper. 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... | |
class | vcl::View< It > |
The View class is a simple class that stores and exposes two iterators begin and end. More... | |
class | vcl::WrongSizeException |
Exception thrown when the size (generally of a container) is not the expected one. More... | |
Typedefs | |
template<uint COMP_ID, typename... Components> | |
using | vcl::comp::ComponentOfType = FirstTypeT< typename detail::ComponentOfTypePred< COMP_ID, Components... >::type > |
Given the ID of a Component and a list of Component types (or a TypeWrapper), this alias sets its type to the corresponding Component type found in the list. | |
template<typename... Args> | |
using | vcl::FirstTypeT = typename FirstType< Args... >::type |
Alias for the type of the first type in a pack of types. | |
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::MakeConstPointerT = typename MakeConstPointer< T >::type |
Utility alias for the MakeConstPointer type. | |
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 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::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<uint I, typename... T> | |
using | vcl::TypeAtT = typename TypeAt< I, T... >::type |
Alias for the type at a given index in a pack of types (variadic templates) or a TypeWrapper. | |
Enumerations | |
enum class | vcl::MatrixStorageType { ROW_MAJOR , COLUMN_MAJOR } |
A simple type that enumerates the main storage types for matrices (row or column major). | |
enum class | vcl::PrimitiveType { CHAR , UCHAR , SHORT , USHORT , INT , UINT , FLOAT , DOUBLE , NONE } |
A simple type that enumerates the main primitive types. More... | |
Functions | |
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 > | |
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 char * | vcl::componentEnumString () |
Returns the string associated to the COMP_ID value. | |
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. | |
template<uint ELEM_ID> | |
constexpr const char * | vcl::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 Scalar > | |
bool | vcl::epsilonEquals (Scalar n1, Scalar n2, Scalar epsilon=std::numeric_limits< Scalar >::epsilon()) |
Checks if two floating point numbers are equal within an epsilon value. | |
template<typename T , typename... Rest> | |
void | vcl::hashCombine (std::size_t &seed, const T &v, const Rest &... rest) |
Starting from a seed, computes the hash of a series of objects. | |
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... | |
template<typename... Args> | |
uint | vcl::indexInTypePack (std::type_index ti, TypeWrapper< Args... >) |
Function that returns the index of the type having the given type_index in a TypeWrapper. | |
template<typename Scalar > | |
bool | vcl::isDegenerate (Scalar number) |
Checks if a floating point number is degenerate. | |
double | vcl::lnOfFactorial (int n) |
Computes and caches the result of the natural logarithm of n! | |
template<typename Head , typename... Tail> requires (sizeof...(tail) > 0) | |
constexpr auto | vcl::max (const Head &head0, const Head &head1, const Tail &... tail) |
Returns the maximum between several parameters. | |
template<typename T > | |
constexpr auto | vcl::max (const T &p1, const T &p2) |
Returns the maximum between the two parameters. | |
template<typename Head , typename... Tail> requires (sizeof...(tail) > 0) | |
constexpr auto | vcl::min (const Head &head0, const Head &head1, const Tail &... tail) |
Returns the minimum between several parameters. | |
template<typename T > | |
constexpr auto | vcl::min (const T &p1, const T &p2) |
Returns the minimum between the two parameters. | |
std::mt19937 | vcl::randomGenerator (std::optional< uint > seed=std::nullopt) |
Creates a random number generator with an optional seed. | |
template<Range R> | |
void | vcl::shuffle (R &&range, std::optional< uint > seed=std::nullopt) |
Shuffle the elements of a range. | |
template<typename Scalar > | |
Scalar | vcl::toDeg (const Scalar &rad) |
Converts an angle in radians to degrees. | |
template<typename Scalar > | |
Scalar | vcl::toRad (const Scalar °) |
Converts an angle in degrees to radians. | |
Variables | |
constexpr const char * | vcl::COMPONENT_ENUM_STRINGS [CompId::COMPONENTS_NUMBER] |
The COMPONENT_ENUM_STRINGS array contains the string representation of the CompId::Enum values. | |
constexpr const char * | vcl::ELEMENT_ENUM_STRINGS [ElemId::ELEMENTS_NUMBER] |
The ELEMENT_ENUM_STRINGS array contains the string representation of the elements that can compose a mesh. | |
template<typename T , template< typename... > class Template> | |
constexpr bool | vcl::IsDerivedFromSpecializationOfV |
Alias for IsDerivedFromSpecializationOf trait. | |
template<typename T , template< typename... > class Template> | |
constexpr bool | vcl::IsSpecializationOfV = IsSpecializationOf<T, Template>::value |
Alias for IsSpecializationOf trait. | |
NullLogger | vcl::nullLogger |
The nullLogger object is an object of type NullLogger that is used as default argument in the functions that can take as input a logger. | |
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. | |
The Base 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.
You can access to the module by including #include <vclib/base.h>
using vcl::FirstTypeT = typedef typename FirstType<Args...>::type |
Alias for the type of the first type in a pack of types.
Usage:
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:
and will return true if X derives from any specialization of C.
derived | The class to be checked. |
base | The templated class to be checked. |
using vcl::MakeConstPointerT = typedef typename MakeConstPointer<T>::type |
Utility alias for the MakeConstPointer type.
T | The type to be converted to a const pointer. |
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.
T | The input type. |
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.
T | The input type. |
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.
T | The input type. |
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.
T | The input type. |
using vcl::TypeAtT = typedef typename TypeAt<I, T...>::type |
Alias for the type at a given index in a pack of types (variadic templates) or a TypeWrapper.
Usage:
|
strong |
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.
Utility function that applies the unary operator '&' to the argument only if it is not a pointer.
obj |
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.
T | The type of the pointer/reference. |
[in] | value | The const pointer/reference to be const-casted. |
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.
T | The type of the pointer/reference. |
[in] | value | The const pointer/reference to be const-casted. |
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.
T | The type of the pointer/reference. |
[in] | value | The const pointer/reference to be const-casted. |
Returns the string associated to the COMP_ID value.
COMP_ID | an unsigned integer that identifies the component. |
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.
[in] | obj | The object to dereference. |
Returns the string associated to the ELEM_ID value.
ELEM_ID | an unsigned integer that identifies the element. |
const std::string & vcl::elementEnumString | ( | ) |
Returns the string associated to the ELEM_ID value.
ELEM_ID | an unsigned integer that identifies the element. |
bool vcl::epsilonEquals | ( | Scalar | n1, |
Scalar | n2, | ||
Scalar | epsilon = std::numeric_limits<Scalar>::epsilon() |
||
) |
Checks if two floating point numbers are equal within an epsilon value.
This function returns true if the absolute difference between the two numbers is less than or equal to the epsilon value.
[in] | n1 | the first number to compare |
[in] | n2 | the second number to compare |
[in] | epsilon | the epsilon value to use for the check |
void vcl::hashCombine | ( | std::size_t & | seed, |
const T & | v, | ||
const Rest &... | rest | ||
) |
Starting from a seed, computes the hash of a series of objects.
https://stackoverflow.com/a/57595105/5851101
[in,out] | seed | input seed and output hash |
[in] | v | first argument object |
[in] | rest | rest of the argument objects |
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...
[in] | ti | the type_index of the type to search. |
uint vcl::indexInTypePack | ( | std::type_index | ti, |
TypeWrapper< Args... > | |||
) |
Function that returns the index of the type having the given type_index in a TypeWrapper.
The TypeWrapper must be given as a second argument to the function.
[in] | ti | the type_index of the type to search. |
[in] | tw | the TypeWrapper to search in. |
Checks if a floating point number is degenerate.
A floating point number is degenerate if it is infinite or NaN.
[in] | number | the number to check |
Computes and caches the result of the natural logarithm of n!
If n > 1024, uses the Stirling approximation.
[in] | n | the number for which to compute the natural logarithm of the factorial. |
Returns the maximum between several parameters.
Given a list of parameters, this function returns the maximum between all of them.
Example:
[in] | head0 | The first parameter. |
[in] | head1 | The second parameter. |
[in] | tail | The rest of the parameters. |
Returns the maximum between the two parameters.
[in] | p1 | The first parameter. |
[in] | p2 | The second parameter. |
Returns the minimum between several parameters.
Given a list of parameters, this function returns the minimum between all of them.
Example:
[in] | head0 | The first parameter. |
[in] | head1 | The second parameter. |
[in] | tail | The rest of the parameters. |
Returns the minimum between the two parameters.
[in] | p1 | The first parameter. |
[in] | p2 | The second parameter. |
|
inline |
Creates a random number generator with an optional seed.
If a seed is provided, the generator is seeded with that value, otherwise it uses a random device to generate a random seed.
seed | Optional seed value for the random number generator. |
void vcl::shuffle | ( | R && | range, |
std::optional< uint > | seed = std::nullopt |
||
) |
Shuffle the elements of a range.
R | Type of the range. |
[in] | range | Range to shuffle. |
[in] | seed | optional value of seed, to get deterministic results. If not provided, a random seed is used. |
Converts an angle in radians to degrees.
[in] | rad | the angle in radians |
Converts an angle in degrees to radians.
[in] | deg | the angle in degrees |
The COMPONENT_ENUM_STRINGS array contains the string representation of the CompId::Enum values.
The ELEMENT_ENUM_STRINGS array contains the string representation of the elements that can compose a mesh.
Alias for IsDerivedFromSpecializationOf trait.
|
inline |
The nullLogger object is an object of type NullLogger that is used as default argument in the functions that can take as input a logger.
A typical function that could take a logger is defined as follows:
In this way, when the user does not give a logger argument, the default will be an object of NullLogger.
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.