Asylo
Protected Member Functions | List of all members
asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT > Class Template Reference

An intermediate template class that to help define an ErrorSpace subclass. More...

#include <error_space.h>

Inheritance diagram for asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >:
Inheritance graph
[legend]
Collaboration diagram for asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >:
Collaboration graph
[legend]

Protected Member Functions

 ErrorSpaceImplementationHelper (const std::string &space_name, const std::string &default_error_string="Unrecognized Code")
 Constructs an ErrorSpaceImplementationHelper and registers it as space_name. More...
 
void AddTranslationMapEntry (int code, const std::string &error_string, GoogleError google_error_code)
 Adds an interpretation of an error code as both a string and GoogleError. More...
 
std::string SpaceName () const override
 Gets a name that uniquely identifies the error space. More...
 
std::string String (int code) const override
 Gets a string that describes the error code within the space. More...
 
GoogleError GoogleErrorCode (int code) const override
 Converts code to an appropriate value in the GoogleError enum. More...
 

Additional Inherited Members

- Public Member Functions inherited from asylo::error::ErrorSpace
 ErrorSpace ()=default
 
 ErrorSpace (const ErrorSpace &other)=delete
 
virtual ~ErrorSpace ()=default
 
ErrorSpaceoperator= (const ErrorSpace &other)=delete
 
- Static Public Member Functions inherited from asylo::error::ErrorSpace
static ErrorSpace const * Find (const std::string &name)
 Finds and returns an ErrorSpace singleton pointer whose SpaceName() equals name. More...
 

Detailed Description

template<typename ErrorSpaceT>
class asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >

An intermediate template class that to help define an ErrorSpace subclass.

ErrorSpaceImplementationHelper automatically creates and inserts a singleton instance of ErrorSpaceT into the global error-space singleton map. It is customary to derive the class ErrorSpaceT from ErrorSpaceImplementationHelper<ErrorSpaceT> to ensure correct management of the map.

Constructor & Destructor Documentation

◆ ErrorSpaceImplementationHelper()

template<typename ErrorSpaceT>
asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >::ErrorSpaceImplementationHelper ( const std::string &  space_name,
const std::string &  default_error_string = "Unrecognized Code" 
)
inlineexplicitprotected

Constructs an ErrorSpaceImplementationHelper and registers it as space_name.

Parameters
space_nameThe name that ErrorSpace::Find() will use to fetch the singleton instance of this ErrorSpace.
default_error_stringThe result for String() for an unrecognized error code.

Member Function Documentation

◆ AddTranslationMapEntry()

template<typename ErrorSpaceT>
void asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >::AddTranslationMapEntry ( int  code,
const std::string &  error_string,
GoogleError  google_error_code 
)
inlineprotected

Adds an interpretation of an error code as both a string and GoogleError.

Parameters
codeThe error code to interpret.
error_stringThe interpretation String() will return for code.
google_error_codeThe most apt GoogleError to assign to code.

◆ GoogleErrorCode()

template<typename ErrorSpaceT>
GoogleError asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >::GoogleErrorCode ( int  code) const
inlineoverrideprotectedvirtual

Converts code to an appropriate value in the GoogleError enum.

Parameters
codeThe error code in this error space to convert to GoogleError.
Returns
The GoogleError interpretation of code.

Implements asylo::error::ErrorSpace.

◆ SpaceName()

template<typename ErrorSpaceT>
std::string asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >::SpaceName ( ) const
inlineoverrideprotectedvirtual

Gets a name that uniquely identifies the error space.

Returns
A uniquely identifying name for the ErrorSpace.

Implements asylo::error::ErrorSpace.

◆ String()

template<typename ErrorSpaceT>
std::string asylo::error::ErrorSpaceImplementationHelper< ErrorSpaceT >::String ( int  code) const
inlineoverrideprotectedvirtual

Gets a string that describes the error code within the space.

Parameters
codeThe error code to interpret within the error space.
Returns
A description for the input code.

Implements asylo::error::ErrorSpace.


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