ADTF
Loading...
Searching...
No Matches
a_util::result::detail::ResultDescription< DescriptionIntf > Class Template Reference

Wrapper for either a pointer to a detailed description object or simply a numeric error code. More...

#include <result_description_decl.h>

Public Types

typedef ResultDescription< DescriptionIntf > SelfType
 Self type.
 

Public Member Functions

 ResultDescription ()
 CTOR.
 
 ResultDescription (const ResultDescription &other)
 
ResultDescriptionoperator= (const ResultDescription &other)
 
 ResultDescription (ResultDescription &&other)
 
ResultDescriptionoperator= (ResultDescription &&other)
 
 ~ResultDescription ()
 DTOR.
 
DescriptionIntf const * getDetailedDescription () const
 
std::int32_t getErrorCode () const
 

Static Public Member Functions

template<typename DescriptionImpl, typename... Args>
static SelfType makeResultDescription (std::int32_t error_code, Args &&... args)
 
template<typename T>
static SelfType makeResultDescription (const ::a_util::result::ResultInfo< T > &result_info) noexcept
 
static SelfType makeResultDescription (std::int32_t error_code)
 

Detailed Description

template<typename DescriptionIntf>
class a_util::result::detail::ResultDescription< DescriptionIntf >

Wrapper for either a pointer to a detailed description object or simply a numeric error code.

64 Bit error type has max 63 Bit large pointer type member variable

[1|...|______________________up_to_63_____________________________]
[a| b |                          c                                ]

Regions:

  • a: Error code Bit - Indicates whether only the error code in region b was set (1 == yes, 0 == no)
  • b: padding data with unused pointer bits
  • c: up to 63 Bits - Either only the error code value or the pointer to the allocated error description (might be nil)
Template Parameters
DescriptionIntfThe interface used to retrieve the error information

Constructor & Destructor Documentation

◆ ResultDescription() [1/2]

template<typename DescriptionIntf>
a_util::result::detail::ResultDescription< DescriptionIntf >::ResultDescription ( const ResultDescription< DescriptionIntf > & other)
inline

Copy constructor

Parameters
[in]otherOther object to copy from

◆ ResultDescription() [2/2]

template<typename DescriptionIntf>
a_util::result::detail::ResultDescription< DescriptionIntf >::ResultDescription ( ResultDescription< DescriptionIntf > && other)
inline

Move CTOR

Parameters
[in,out]otherMove-from object *this is created from
Precondition
other is left in default-initialized state

Member Function Documentation

◆ getDetailedDescription()

template<typename DescriptionIntf>
DescriptionIntf const * a_util::result::detail::ResultDescription< DescriptionIntf >::getDetailedDescription ( ) const
inline

Get the detailed description if any was allocated

Returns
Pointer to the detailed error description - nullptr if none was allocated
Note
If getErrorCode() and getDetailedDescription() return with indication of no error code, no error code was set

◆ getErrorCode()

template<typename DescriptionIntf>
std::int32_t a_util::result::detail::ResultDescription< DescriptionIntf >::getErrorCode ( ) const
inline

Get the error code if only the error code was set

Returns
The error code
Note
If getErrorCode() and getDetailedDescription() return with indication of no error code, no error code was set

◆ makeResultDescription() [1/3]

template<typename DescriptionIntf>
template<typename T>
ResultDescription< DescriptionIntf >::SelfType a_util::result::detail::ResultDescription< DescriptionIntf >::makeResultDescription ( const ::a_util::result::ResultInfo< T > & result_info)
staticnoexcept

Creates a static error object referencing error code and error label information of type T

Template Parameters
TType for template parameter of a_util::result::ResultInfo<T>
Parameters
[in]result_infoUnused, provided only for type deduction.
Returns
Object of type ResultDescription containing static error code and error label information.

◆ makeResultDescription() [2/3]

template<typename DescriptionIntf>
ResultDescription< DescriptionIntf > a_util::result::detail::ResultDescription< DescriptionIntf >::makeResultDescription ( std::int32_t error_code)
inlinestatic

Make the result description object only with an error code

Parameters
[in]error_codeThe error code to set
Returns
New object of type ResultDescription

◆ makeResultDescription() [3/3]

template<typename DescriptionIntf>
template<typename DescriptionImpl, typename... Args>
ResultDescription< DescriptionIntf >::SelfType a_util::result::detail::ResultDescription< DescriptionIntf >::makeResultDescription ( std::int32_t error_code,
Args &&... args )
static

Allocate an object being able to store detailed error information

On common operating systems not the entire 64Bits of a pointer are used to address virtual memory - so there are some spare bits free to be used as user space. However, to safely mask out the appropriate bits, it is checked whether the pointer to the allocated detailed description object indeed does not use the user space bits. If so, the detailed description will not be available and only the error code is set.

Template Parameters
DescriptionImplThe concrete implementation type to contain the detailed error description. The first constructor argument must be of type std::int32_t.
ArgsConstructor arguments for the allocation of type Implementation
Parameters
[in]error_codeThe concrete error code either being used as first constructor argument for type Implementation or if allocation fails as the error code.
[in]argsThe constructor arguments for the error description object. These usually include information like where did the error occur (line, file, ...) or the error string.
Returns
Object of type ResultDescription containing heap allocated error information.

◆ operator=() [1/2]

template<typename DescriptionIntf>
ResultDescription< DescriptionIntf > & a_util::result::detail::ResultDescription< DescriptionIntf >::operator= ( const ResultDescription< DescriptionIntf > & other)
inline

Copy assignment operator

Parameters
[in]otherOther object to copy from
Returns
*this

◆ operator=() [2/2]

template<typename DescriptionIntf>
ResultDescription< DescriptionIntf > & a_util::result::detail::ResultDescription< DescriptionIntf >::operator= ( ResultDescription< DescriptionIntf > && other)
inline

Move assignment operator

Parameters
[in,out]otherMove-from object *this is assigned from
Precondition
other is left in default-initialized state

The documentation for this class was generated from the following files: