ImFusion SDK 4.3
ErrorInheritanceHelper< T, Base > Class Template Reference

#include <RoboticsPlugin/Include/ImFusion/Robotics/Error.h>

Auxiliary type intended to implement a user defined specialization of ErrorInterface. More...

+ Inheritance diagram for ErrorInheritanceHelper< T, Base >:

Detailed Description

template<typename T, typename Base = ErrorInterface>
class ImFusion::Robotics::ErrorInheritanceHelper< T, Base >

Auxiliary type intended to implement a user defined specialization of ErrorInterface.

It includes a generic clone() method necessary for error composition.

Usage example:

struct MyError: Robotics::ErrorInheritanceHelper<Error> { /* ... *&zwj;/ }
Expected<int> myFunction()
{
if (success)
return 0;
else
return MyError();
}
Expected<int> myRes = myFunction();
if (!myRes)
{
LOG_ERROR(myRes.error().message());
return myRes;
}
int myVar = myRes.value() - 3;
Auxiliary type intended to implement a user defined specialization of ErrorInterface.
Definition Error.h:230

Public Member Functions

 ~ErrorInheritanceHelper () override=default
 Override destructor.
 
 ErrorInheritanceHelper (const ErrorInterface &ei)
 
std::unique_ptr< T > clone () const &
 Creates a copy of the current instance.
 
- Public Member Functions inherited from ErrorInterface
virtual void handle ()
 Error handling strategy, allows the user to define a task on the constructor of ErrorFrontEnd.
 
virtual std::string domain () const =0
 Returns the category to which the custom error implementation belongs.
 
virtual int id () const =0
 Retrieves the unique identifier for the error.
 
virtual std::string message () const =0
 Retrieves the error message.
 
template<typename T>
 operator Utils::Expected< T, ErrorFrontEnd > () const &
 Template method for casting to std::expected<T, ErrorFrontEnd>.
 
std::unique_ptr< ErrorInterfaceclone () const &
 Creates a copy of the current instance.
 
bool operator== (const ErrorFrontEnd &other) const
 Compares the id and the domain.
 
bool operator== (const ErrorInterface &other) const
 Compares the id and the domain.
 
virtual ErrorComposition operator| (const ErrorInterface &input) const
 Composition operator.
 

Member Function Documentation

◆ clone()

template<typename T, typename Base = ErrorInterface>
std::unique_ptr< T > clone ( ) const &
inlinenodiscard

Creates a copy of the current instance.

This method performs a deep copy of the current instance and returns a new dynamically allocated instance that is a clone of this object.

Returns
A unique pointer to the newly cloned instance.

The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close