ADTF  3.18.2
ResultDescription< DescriptionIntf >

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

Public Types

typedef ResultDescription< DescriptionIntf > SelfType
 Self type.
 

Public Member Functions

 ResultDescription ()
 CTOR.
 
 ResultDescription (const ResultDescription &other)
 Copy constructor. More...
 
ResultDescriptionoperator= (const ResultDescription &other)
 Copy assignment operator. More...
 
 ResultDescription (ResultDescription &&other)
 Move CTOR. More...
 
ResultDescriptionoperator= (ResultDescription &&other)
 Move assignment operator. More...
 
 ~ResultDescription ()
 DTOR.
 
DescriptionIntf const * getDetailedDescription () const
 Get the detailed description if any was allocated. More...
 
std::int32_t getErrorCode () const
 Get the error code if only the error code was set. More...
 

Static Public Member Functions

template<typename DescriptionImpl , typename... Args>
static SelfType makeResultDescription (std::int32_t error_code, Args &&... args)
 Allocate an object being able to store detailed error information. More...
 
template<typename T >
static SelfType makeResultDescription (const ::a_util::result::ResultInfo< T > &result_info) noexcept
 Creates a static error object referencing error code and error label information of type T. More...
 
static SelfType makeResultDescription (std::int32_t error_code)
 Make the result description object only with an error code. More...
 

Private Types

typedef ResultDescriptionTraits< DescriptionIntf > TraitsType
 Traits type abbreviation.
 

Private Member Functions

constexpr ResultDescription (std::int32_t error_code) noexcept
 Construct with simple error code, no memory is allocated. More...
 
constexpr ResultDescription (const ReferenceCountedObjectInterface< DescriptionIntf > &error_object) noexcept
 Construct with detailed error description. More...
 

Private Attributes

std::uint64_t _pointer_to_result_or_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

Definition at line 111 of file result_description_decl.h.

Constructor & Destructor Documentation

◆ ResultDescription() [1/4]

ResultDescription ( const ResultDescription< DescriptionIntf > &  other)
inline

Copy constructor.

Parameters
[in]otherOther object to copy from

Definition at line 124 of file result_description_impl.h.

◆ ResultDescription() [2/4]

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

Definition at line 148 of file result_description_impl.h.

References std::swap().

◆ ResultDescription() [3/4]

constexpr ResultDescription ( std::int32_t  error_code)
inlineconstexprprivatenoexcept

Construct with simple error code, no memory is allocated.

Parameters
[in]error_codeThe error code

Definition at line 257 of file result_description_impl.h.

◆ ResultDescription() [4/4]

constexpr ResultDescription ( const ReferenceCountedObjectInterface< DescriptionIntf > &  error_object)
inlineconstexprprivatenoexcept

Construct with detailed error description.

Parameters
[in]error_objectReference to error object getting cast to internal error variable
Postcondition
error_object reference counter is incremented

Definition at line 264 of file result_description_impl.h.

Member Function Documentation

◆ getDetailedDescription()

DescriptionIntf const * getDetailedDescription
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

Definition at line 237 of file result_description_impl.h.

Referenced by Result::getDescription(), Result::getErrorCode(), Result::getErrorLabel(), Result::getFile(), Result::getFunction(), Result::getLine(), and a_util::result::detail::operator==().

◆ getErrorCode()

std::int32_t getErrorCode
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

Definition at line 247 of file result_description_impl.h.

Referenced by Result::getDescription(), Result::getErrorCode(), and a_util::result::detail::operator==().

◆ makeResultDescription() [1/3]

ResultDescription< DescriptionIntf >::SelfType 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.

Definition at line 213 of file result_description_impl.h.

◆ makeResultDescription() [2/3]

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

Definition at line 228 of file result_description_impl.h.

◆ makeResultDescription() [3/3]

ResultDescription< DescriptionIntf >::SelfType 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.

Definition at line 183 of file result_description_impl.h.

◆ operator=() [1/2]

ResultDescription< DescriptionIntf > & operator= ( const ResultDescription< DescriptionIntf > &  other)
inline

Copy assignment operator.

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

Definition at line 131 of file result_description_impl.h.

◆ operator=() [2/2]

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

Definition at line 155 of file result_description_impl.h.

References std::swap().