MGIS
Loading...
Searching...
No Matches
mgis Namespace Reference

the namespace mgis encloses all the MGIS project. More...

Classes

struct  AbstractErrorHandler
 base class for error handlers This class shall be used as arguments to checkPreconditions methods More...
 
struct  Context
 a class used to pass an execution context to most methods of MGIS and gather information (error, logs). More...
 
struct  ContextInitializer
 class that can be used to initialize a context, in particular in a constexpr function. More...
 
struct  ContractViolationHandler
 a class used to report a contract violation More...
 
struct  Cste
 
struct  ErrorBacktrace
 a structure to keep trace of error messages. More...
 
struct  InvalidResult
 a class convertible to many values used as invalid result. More...
 
struct  LibrariesManager
 structure in charge of handling libraries and querying MGIS' meta-data More...
 
struct  PreconditionsCheck
 
struct  PreconditionsChecker
 
struct  ThreadedTaskResult
 a class standing for the result of a taks More...
 
struct  ThreadedTaskResult< void >
 Partial specialisation for non-returning tasks. More...
 
struct  ThreadedTaskResultBase
 non-template base class of the ThreadedTaskResult class More...
 
struct  ThreadPool
 structure handling a fixed-size pool of threads More...
 

Typedefs

using size_type = mgis_size_type
 a simple alias to the the default indexing type used by mgis
 
using real = mgis_real
 alias to the numeric type used
 
using ExceptionHandler = void(*)(void)
 a simple alias
 

Enumerations

enum struct  StorageMode { LOCAL_STORAGE , EXTERNAL_STORAGE }
 storage option for a non uniform material property or non uniform external state variable. More...
 
enum  VerbosityLevel {
  verboseQuiet = -1 , verboseLevel0 = 0 , verboseLevel1 = 1 , verboseLevel2 = 2 ,
  verboseLevel3 = 3 , verboseDebug = 4 , verboseFull = 5
}
 list the possible values for the logging facilities provided by the Context class
 

Functions

template<typename Type , typename... Args>
requires ( is_check_preconditions_callable<Type, Args...>)
constexpr void check_preconditions (Args &&...args)
 
MGIS_VISIBILITY_EXPORT mfront::MFrontDatabase & getDatabase () noexcept
 
MGIS_EXPORT InvalidResult registerExceptionInErrorBacktrace (ErrorBacktrace &) noexcept
 a custom Lippincott-like function that extract error messages from an exception an
 
MGIS_EXPORT InvalidResult registerExceptionInErrorBacktraceWithoutSourceLocation (ErrorBacktrace &) noexcept
 a custom Lippincott-like function that extract error messages from an exception an
 
constexpr bool isInvalid (const bool) noexcept
 
template<typename T >
constexpr bool isInvalid (const std::optional< T > &) noexcept
 
template<typename T >
constexpr bool isInvalid (T *const) noexcept
 
template<typename T >
constexpr bool isInvalid (const std::unique_ptr< T > &) noexcept
 
template<typename T >
constexpr bool isInvalid (const std::shared_ptr< T > &) noexcept
 
constexpr bool areInvalid (const auto &...) noexcept
 
constexpr bool isValid (const auto &) noexcept
 
constexpr bool areValid (const auto &...) noexcept
 
constexpr bool areInvalid (const auto &...o) noexcept
 
constexpr bool areValid (const auto &...o) noexcept
 
MGIS_EXPORT void setExceptionHandler (ExceptionHandler)
 set an exception handler
 
MGIS_EXPORT ExceptionHandler getExceptionHandler ()
 return a registred exception handler, nullptr if none were registred.
 
template<typename Exception = std::runtime_error>
MGIS_VISIBILITY_LOCAL void raise ()
 a small wrapper used to build the exception outside the throw statement. As most exception's classes constructors may throw, this avoids undefined behaviour as reported by the cert-err60-cpp warning of clang-tidy (thrown exception type is not nothrow copy constructible).
 
template<typename Exception = std::runtime_error, typename... Args>
MGIS_VISIBILITY_LOCAL void raise (Args &&...)
 a small wrapper used to build the exception outside the throw statement. As most exception's classes constructors may throw, this avoids undefined behaviour as reported by the cert-err60-cpp warning of clang-tidy (thrown exception type is not nothrow copy constructible).
 
template<typename Exception = std::runtime_error>
MGIS_VISIBILITY_LOCAL void raise_if (const bool)
 raise an exception if the first argument is true.
 
template<typename Exception = std::runtime_error, typename... Args>
MGIS_VISIBILITY_LOCAL void raise_if (const bool, Args &&...)
 raise an exception if the first argument is true.
 
template<typename Exception >
void raise ()
 a small wrapper used to build the exception outside the throw statement. As most exception's classes constructors may throw, this avoids undefined behaviour as reported by the cert-err60-cpp warning of clang-tidy (thrown exception type is not nothrow copy constructible).
 
template<typename Exception , typename... Args>
void raise (Args &&... a)
 
template<typename Exception >
void raise_if (const bool c)
 raise an exception if the first argument is true.
 
template<typename Exception , typename... Args>
void raise_if (const bool c, Args &&... a)
 
MGIS_EXPORT VerbosityLevelgetDefaultVerbosityLevel () noexcept
 
MGIS_EXPORT void setDefaultVerbosityLevel (const VerbosityLevel) noexcept
 change the default level of verbosity
 
MGIS_EXPORT bool setDefaultVerbosityLevel (Context &, std::string_view) noexcept
 change the default level of verbosity
 
MGIS_EXPORT std::optional< VerbosityLevelconvertToVerbosityLevel (Context &, std::string_view) noexcept
 

Variables

constexpr auto unsafe = attributes::UnsafeAttribute{}
 
constexpr auto throwing = attributes::ThrowingAttribute<true>{}
 
constexpr auto not_throwing = attributes::ThrowingAttribute<false>{}
 
constexpr size_type dynamic_extent
 a constant whose role is similar to std::dynamic_extent
 
template<typename Type , typename... Args>
constexpr auto is_check_preconditions_callable
 
constexpr auto no_precondition_check = PreconditionsCheck<false>{}
 
constexpr auto preconditions_check = PreconditionsCheck<true>{}
 

Detailed Description

the namespace mgis encloses all the MGIS project.

Enumeration Type Documentation

◆ StorageMode

enum struct mgis::StorageMode
strong

storage option for a non uniform material property or non uniform external state variable.

Enumerator
LOCAL_STORAGE 

use std::vector to store the data

EXTERNAL_STORAGE 

use std::span to store the data

Function Documentation

◆ areInvalid()

constexpr bool mgis::areInvalid ( const auto &  ...)
constexprnoexcept
Returns
if one of the given objects is invalid
Parameters
[in]oobjects tested

◆ areValid()

constexpr bool mgis::areValid ( const auto &  ...)
constexprnoexcept
Returns
if all the given objects are valid
Parameters
[in]oobjects tested

◆ convertToVerbosityLevel()

MGIS_EXPORT std::optional< VerbosityLevel > mgis::convertToVerbosityLevel ( Context ,
std::string_view   
)
noexcept
Returns
the level of verbosity associated with the given string
Parameters
[in]ctxexecution context
[in]lstring representation of the verbose level

◆ getDatabase()

MGIS_VISIBILITY_EXPORT mfront::MFrontDatabase & mgis::getDatabase ( )
noexcept
Returns
a global instance of a MFrontDatabase

◆ getDefaultVerbosityLevel()

MGIS_EXPORT VerbosityLevel & mgis::getDefaultVerbosityLevel ( )
noexcept
Returns
the current default value of the verbosity level

◆ isInvalid() [1/5]

constexpr bool mgis::isInvalid ( const bool  b)
constexprnoexcept
Returns
if the given boolean is true
Parameters
[in]bvalue

◆ isInvalid() [2/5]

template<typename T >
constexpr bool mgis::isInvalid ( const std::optional< T > &  o)
constexprnoexcept
Returns
if the given optional is invalid (does not contain an object)
Parameters
[in]ooptional value

◆ isInvalid() [3/5]

template<typename T >
constexpr bool mgis::isInvalid ( const std::shared_ptr< T > &  p)
constexprnoexcept
Returns
if the given std::shared_ptr is invalid (i.e. is empty)
Parameters
[in]ppointer

◆ isInvalid() [4/5]

template<typename T >
constexpr bool mgis::isInvalid ( const std::unique_ptr< T > &  p)
constexprnoexcept
Returns
if the given std::unique_ptr is invalid (i.e. is empty)
Parameters
[in]ppointer

◆ isInvalid() [5/5]

template<typename T >
constexpr bool mgis::isInvalid ( T * const  ptr)
constexprnoexcept
Returns
if the given pointer is null (i.e. is empty)
Parameters
[in]ppointer

◆ isValid()

constexpr bool mgis::isValid ( const auto &  o)
constexprnoexcept
Returns
if the given object is valid
Parameters
[in]oobject tested

◆ raise() [1/3]

template<typename Exception = std::runtime_error>
MGIS_VISIBILITY_LOCAL void mgis::raise ( )
inline

a small wrapper used to build the exception outside the throw statement. As most exception's classes constructors may throw, this avoids undefined behaviour as reported by the cert-err60-cpp warning of clang-tidy (thrown exception type is not nothrow copy constructible).

Template Parameters
Exceptiontype of the exception to be thrown.

◆ raise() [2/3]

template<typename Exception >
void mgis::raise ( )
inline

a small wrapper used to build the exception outside the throw statement. As most exception's classes constructors may throw, this avoids undefined behaviour as reported by the cert-err60-cpp warning of clang-tidy (thrown exception type is not nothrow copy constructible).

Template Parameters
Exceptiontype of the exception to be thrown.

◆ raise() [3/3]

template<typename Exception = std::runtime_error, typename... Args>
MGIS_VISIBILITY_LOCAL void mgis::raise ( Args &&  ...)
inline

a small wrapper used to build the exception outside the throw statement. As most exception's classes constructors may throw, this avoids undefined behaviour as reported by the cert-err60-cpp warning of clang-tidy (thrown exception type is not nothrow copy constructible).

Template Parameters
Exceptiontype of the exception to be thrown.
Argstype of the arguments passed to the exception' constructor.
Parameters
[in]aarguments passed to the exception' constructor.

◆ raise_if() [1/3]

template<typename Exception >
void mgis::raise_if ( const bool  c)
inline

raise an exception if the first argument is true.

Template Parameters
Exceptiontype of the exception to be thrown.
Parameters
[in]bcondition to be checked. If true, an exception is thrown.

◆ raise_if() [2/3]

template<typename Exception = std::runtime_error>
MGIS_VISIBILITY_LOCAL void mgis::raise_if ( const bool  c)
inline

raise an exception if the first argument is true.

Template Parameters
Exceptiontype of the exception to be thrown.
Parameters
[in]bcondition to be checked. If true, an exception is thrown.

◆ raise_if() [3/3]

template<typename Exception = std::runtime_error, typename... Args>
MGIS_VISIBILITY_LOCAL void mgis::raise_if ( const bool  ,
Args &&  ... 
)
inline

raise an exception if the first argument is true.

Template Parameters
Exceptiontype of the exception to be thrown.
Argstype of the arguments passed to the exception' constructor.
Parameters
[in]bcondition to be checked. If true, an exception is thrown.
[in]aarguments passed to the exception' constructor.

◆ registerExceptionInErrorBacktrace()

MGIS_EXPORT InvalidResult mgis::registerExceptionInErrorBacktrace ( ErrorBacktrace )
noexcept

a custom Lippincott-like function that extract error messages from an exception an

Parameters
[out]eerror back trace handler

◆ registerExceptionInErrorBacktraceWithoutSourceLocation()

MGIS_EXPORT InvalidResult mgis::registerExceptionInErrorBacktraceWithoutSourceLocation ( ErrorBacktrace )
noexcept

a custom Lippincott-like function that extract error messages from an exception an

Parameters
[out]eerror back trace handler

◆ setDefaultVerbosityLevel() [1/2]

MGIS_EXPORT void mgis::setDefaultVerbosityLevel ( const VerbosityLevel  )
noexcept

change the default level of verbosity

Parameters
[in]lthe new verbose level

◆ setDefaultVerbosityLevel() [2/2]

MGIS_EXPORT bool mgis::setDefaultVerbosityLevel ( Context ,
std::string_view   
)
noexcept

change the default level of verbosity

Parameters
[in]ctxexecution context
[in]lthe new verbose level

◆ setExceptionHandler()

MGIS_EXPORT void mgis::setExceptionHandler ( ExceptionHandler  )

set an exception handler

Parameters
[in]hexception handler
void handler() {
try {
throw;
} catch (std::exception& e) {
std::cerr << e.what() << '\n';
} catch (...) {
std::cerr << "unknown exception thrown";
}
std::abort();
} // end of handler
mgis::raise<std::logic_error>("something went wrong");
MGIS_EXPORT void setExceptionHandler(ExceptionHandler)
set an exception handler

Variable Documentation

◆ dynamic_extent

constexpr size_type mgis::dynamic_extent
inlineconstexpr
Initial value:
=
std::numeric_limits<size_type>::max()

a constant whose role is similar to std::dynamic_extent

◆ is_check_preconditions_callable

template<typename Type , typename... Args>
constexpr auto mgis::is_check_preconditions_callable
inlineconstexpr
Initial value:
=
requires(ContractViolationHandler &e, Args... rargs) {
{ Type::checkPreconditions(e, rargs...) } -> std::same_as<bool>;
}