Reinforcement Learning  1.1
api_status.h File Reference

api_status definition. api_status is used to return error information to the caller. (API Error Codes) More...

#include "err_constants.h"
#include <sstream>
#include <string>

Go to the source code of this file.

Classes

class  reinforcement_learning::api_status
 Report status of all API calls. More...
 
struct  reinforcement_learning::status_builder
 Helper class used in report_error template funcstions to return status from API calls. More...
 

Namespaces

 reinforcement_learning
 [Error Generator]
 

Macros

#define RETURN_ERROR(trace, status, code, ...)
 Error reporting macro for just returning an error code. More...
 
#define RETURN_ERROR_ARG(trace, status, code, ...)
 Error reporting macro that takes a list of parameters. More...
 
#define RETURN_ERROR_LS(trace, status, code)
 Error reporting macro used with left shift operator. More...
 
#define RETURN_IF_FAIL(x)
 Error reporting macro to test and return on error. More...
 

Functions

template<typename Last >
void reinforcement_learning::report_error (std::ostringstream &oss, const Last &last)
 Ends recursion of report_error variadic template with the Last argument. More...
 
template<typename First , typename... Rest>
void reinforcement_learning::report_error (std::ostringstream &oss, const First &first, const Rest &... rest)
 Begins recursion of report_error variadic template with ostringstream to serialize error information. More...
 
template<typename... All>
int reinforcement_learning::report_error (api_status *status, int scode, const All &... all)
 The main report_error template used to serialize error into api_status The method most end users will use with a status code and a number of objects to be serialised into an api_status. More...
 
template<typename T >
reinforcement_learning::status_builderreinforcement_learning::operator<< (reinforcement_learning::status_builder &sbuilder, const T &val)
 left shift operator to serialize types into stringstream held in status_builder More...
 
int reinforcement_learning::report_error (status_builder &sbuilder)
 Terminates recursion of report_error. More...
 
template<typename Last >
int reinforcement_learning::report_error (status_builder &sbuilder, const Last &last)
 report_error that takes the final paramter More...
 
template<typename First , typename... Rest>
int reinforcement_learning::report_error (status_builder &sbuilder, const First &first, const Rest &... rest)
 variadic template report_error that takes a list of parameters More...
 

Detailed Description

api_status definition. api_status is used to return error information to the caller. (API Error Codes)

Author
Rajan Chari et al
Date
2018-07-18

Macro Definition Documentation

◆ RETURN_ERROR

#define RETURN_ERROR (   trace,
  status,
  code,
  ... 
)
Value:
do { \
if (status != nullptr) \
{ \
reinforcement_learning::status_builder sbuilder(trace, status, reinforcement_learning::error_code::code); \
sbuilder << reinforcement_learning::error_code::code##_s; \
return report_error(sbuilder); \
} \
return reinforcement_learning::error_code::code; \
} while (0);
int report_error(status_builder &sbuilder, const First &first, const Rest &... rest)
variadic template report_error that takes a list of parameters
Definition: api_status.h:199

Error reporting macro for just returning an error code.

◆ RETURN_ERROR_ARG

#define RETURN_ERROR_ARG (   trace,
  status,
  code,
  ... 
)
Value:
do { \
if (status != nullptr) \
{ \
reinforcement_learning::status_builder sbuilder(trace, status, reinforcement_learning::error_code::code); \
sbuilder << reinforcement_learning::error_code::code##_s; \
return report_error(sbuilder, __VA_ARGS__); \
} \
return reinforcement_learning::error_code::code; \
} while (0);

Error reporting macro that takes a list of parameters.

◆ RETURN_ERROR_LS

#define RETURN_ERROR_LS (   trace,
  status,
  code 
)
Value:
reinforcement_learning::status_builder sbuilder(trace, status, reinforcement_learning::error_code::code); \
return sbuilder << reinforcement_learning::error_code::code##_s
Helper class used in report_error template funcstions to return status from API calls.
Definition: api_status.h:67

Error reporting macro used with left shift operator.

Examples
rl_sim.cc.

◆ RETURN_IF_FAIL

#define RETURN_IF_FAIL (   x)
Value:
do { \
int retval__LINE__ = (x); \
if (retval__LINE__ != 0) { return retval__LINE__; } \
} while (0)

Error reporting macro to test and return on error.

Examples
override_interface.cc, and rl_sim.cc.