mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Major formatting changes (breaks diffs). No code changes.
The changes made in this commit do not affect any actual code,
they are purely aesthetic. I ran clang-format with google style
over all .h/.cpp files in wpilibc that weren't in wpilibC++Sim
or gtest, and the eclipse formatter over all of the Java files
using the Google eclipse formatting configuration.
Change-Id: I9627bca0bc103c398ecc1c5ba17467193291ae63
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved. */
|
||||
/* Copyright (c) FIRST 2008. All Rights Reserved.
|
||||
*/
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
@@ -18,68 +19,56 @@ Error ErrorBase::_globalError;
|
||||
/**
|
||||
* @brief Initialize the instance status to 0 for now.
|
||||
*/
|
||||
ErrorBase::ErrorBase()
|
||||
{}
|
||||
ErrorBase::ErrorBase() {}
|
||||
|
||||
ErrorBase::~ErrorBase()
|
||||
{}
|
||||
ErrorBase::~ErrorBase() {}
|
||||
|
||||
/**
|
||||
* @brief Retrieve the current error.
|
||||
* Get the current error information associated with this sensor.
|
||||
*/
|
||||
Error& ErrorBase::GetError()
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
Error& ErrorBase::GetError() { return m_error; }
|
||||
|
||||
const Error& ErrorBase::GetError() const
|
||||
{
|
||||
return m_error;
|
||||
}
|
||||
const Error& ErrorBase::GetError() const { return m_error; }
|
||||
|
||||
/**
|
||||
* @brief Clear the current error information associated with this sensor.
|
||||
*/
|
||||
void ErrorBase::ClearError() const
|
||||
{
|
||||
m_error.Clear();
|
||||
}
|
||||
void ErrorBase::ClearError() const { m_error.Clear(); }
|
||||
|
||||
/**
|
||||
* @brief Set error information associated with a C library call that set an error to the "errno" global variable.
|
||||
* @brief Set error information associated with a C library call that set an
|
||||
* error to the "errno" global variable.
|
||||
*
|
||||
* @param contextMessage A custom message from the code that set the error.
|
||||
* @param filename Filename of the error source
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
void ErrorBase::SetErrnoError(const char *contextMessage,
|
||||
const char* filename, const char* function, uint32_t lineNumber) const
|
||||
{
|
||||
char err[256];
|
||||
int errNo = errno;
|
||||
if (errNo == 0)
|
||||
{
|
||||
sprintf(err, "OK: %s", contextMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(err, 256, "%s (0x%08X): %s", strerror(errNo), errNo, contextMessage);
|
||||
}
|
||||
void ErrorBase::SetErrnoError(const char* contextMessage, const char* filename,
|
||||
const char* function, uint32_t lineNumber) const {
|
||||
char err[256];
|
||||
int errNo = errno;
|
||||
if (errNo == 0) {
|
||||
sprintf(err, "OK: %s", contextMessage);
|
||||
} else {
|
||||
snprintf(err, 256, "%s (0x%08X): %s", strerror(errNo), errNo,
|
||||
contextMessage);
|
||||
}
|
||||
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(-1, err, filename, function, lineNumber, this);
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(-1, err, filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the current error information associated from the nivision Imaq API.
|
||||
* @brief Set the current error information associated from the nivision Imaq
|
||||
* API.
|
||||
*
|
||||
* @param success The return from the function
|
||||
* @param contextMessage A custom message from the code that set the error.
|
||||
@@ -87,22 +76,23 @@ void ErrorBase::SetErrnoError(const char *contextMessage,
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
void ErrorBase::SetImaqError(int success, const char *contextMessage, const char* filename, const char* function, uint32_t lineNumber) const
|
||||
{
|
||||
// If there was an error
|
||||
if (success <= 0) {
|
||||
char err[256];
|
||||
sprintf(err, "%i: %s", success, contextMessage);
|
||||
void ErrorBase::SetImaqError(int success, const char* contextMessage,
|
||||
const char* filename, const char* function,
|
||||
uint32_t lineNumber) const {
|
||||
// If there was an error
|
||||
if (success <= 0) {
|
||||
char err[256];
|
||||
sprintf(err, "%i: %s", success, contextMessage);
|
||||
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(success, err, filename, function, lineNumber, this);
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(success, err, filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
}
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,20 +104,20 @@ void ErrorBase::SetImaqError(int success, const char *contextMessage, const char
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
void ErrorBase::SetError(Error::Code code, const char *contextMessage,
|
||||
const char* filename, const char* function, uint32_t lineNumber) const
|
||||
{
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(code, contextMessage, filename, function, lineNumber, this);
|
||||
void ErrorBase::SetError(Error::Code code, const char* contextMessage,
|
||||
const char* filename, const char* function,
|
||||
uint32_t lineNumber) const {
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(code, contextMessage, filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
}
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,25 +129,24 @@ void ErrorBase::SetError(Error::Code code, const char *contextMessage,
|
||||
* @param function Function of the error source
|
||||
* @param lineNumber Line number of the error source
|
||||
*/
|
||||
void ErrorBase::SetWPIError(const char *errorMessage, Error::Code code , const char *contextMessage,
|
||||
const char* filename, const char* function, uint32_t lineNumber) const
|
||||
{
|
||||
char err[256];
|
||||
sprintf(err, "%s: %s", errorMessage, contextMessage);
|
||||
void ErrorBase::SetWPIError(const char* errorMessage, Error::Code code,
|
||||
const char* contextMessage, const char* filename,
|
||||
const char* function, uint32_t lineNumber) const {
|
||||
char err[256];
|
||||
sprintf(err, "%s: %s", errorMessage, contextMessage);
|
||||
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(code, err, filename, function, lineNumber, this);
|
||||
// Set the current error information for this object.
|
||||
m_error.Set(code, err, filename, function, lineNumber, this);
|
||||
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
// Update the global error if there is not one already set.
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() == 0) {
|
||||
_globalError.Clone(m_error);
|
||||
}
|
||||
}
|
||||
|
||||
void ErrorBase::CloneError(ErrorBase *rhs) const
|
||||
{
|
||||
m_error.Clone(rhs->GetError());
|
||||
void ErrorBase::CloneError(ErrorBase* rhs) const {
|
||||
m_error.Clone(rhs->GetError());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,41 +154,39 @@ void ErrorBase::CloneError(ErrorBase *rhs) const
|
||||
|
||||
@return true if the current error is fatal.
|
||||
*/
|
||||
bool ErrorBase::StatusIsFatal() const
|
||||
{
|
||||
return m_error.GetCode() < 0;
|
||||
bool ErrorBase::StatusIsFatal() const { return m_error.GetCode() < 0; }
|
||||
|
||||
void ErrorBase::SetGlobalError(Error::Code code, const char* contextMessage,
|
||||
const char* filename, const char* function,
|
||||
uint32_t lineNumber) {
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
|
||||
// Set the current error information for this object.
|
||||
_globalError.Set(code, contextMessage, filename, function, lineNumber,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ErrorBase::SetGlobalError(Error::Code code, const char *contextMessage,
|
||||
const char* filename, const char* function, uint32_t lineNumber)
|
||||
{
|
||||
// If there was an error
|
||||
if (code != 0) {
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
void ErrorBase::SetGlobalWPIError(const char* errorMessage,
|
||||
const char* contextMessage,
|
||||
const char* filename, const char* function,
|
||||
uint32_t lineNumber) {
|
||||
char err[256];
|
||||
sprintf(err, "%s: %s", errorMessage, contextMessage);
|
||||
|
||||
// Set the current error information for this object.
|
||||
_globalError.Set(code, contextMessage, filename, function, lineNumber, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ErrorBase::SetGlobalWPIError(const char *errorMessage, const char *contextMessage,
|
||||
const char* filename, const char* function, uint32_t lineNumber)
|
||||
{
|
||||
char err[256];
|
||||
sprintf(err, "%s: %s", errorMessage, contextMessage);
|
||||
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() != 0) {
|
||||
_globalError.Clear();
|
||||
}
|
||||
_globalError.Set(-1, err, filename, function, lineNumber, NULL);
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
if (_globalError.GetCode() != 0) {
|
||||
_globalError.Clear();
|
||||
}
|
||||
_globalError.Set(-1, err, filename, function, lineNumber, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the current global error.
|
||||
*/
|
||||
Error& ErrorBase::GetGlobalError()
|
||||
{
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
return _globalError;
|
||||
Error& ErrorBase::GetGlobalError() {
|
||||
Synchronized mutex(_globalErrorMutex);
|
||||
return _globalError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user