-
Notifications
You must be signed in to change notification settings - Fork 0
/
ErrorBase.h
46 lines (41 loc) · 1.53 KB
/
ErrorBase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*----------------------------------------------------------------------------*/
/* 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. */
/*----------------------------------------------------------------------------*/
#ifndef _ERROR_BASE_H
#define _ERROR_BASE_H
#include "Base.h"
#include "ChipObject.h"
#include "Error.h"
#include <semLib.h>
#include <vxWorks.h>
/// Use this macro to set the error.
#define wpi_setError(errorBase, code) ((errorBase).SetError((code), __FILE__, __LINE__))
/**
* Base class for most objects.
* ErrorBase is the base class for most objects since it holds the generated error
* for that object. In addition, there is a single instance of a global error object
*/
class ErrorBase
{
//TODO: Consider initializing instance variables and cleanup in destructor
public:
virtual ~ErrorBase();
virtual Error& GetError();
virtual const Error& GetError() const;
virtual void SetError(Error::Code code, const char* filename, UINT32 lineNumber) const;
virtual void ClearError();
virtual bool StatusIsFatal() const;
static Error& GetGlobalError();
protected:
// TODO: Get rid of status when rest of the code does not need it
tRioStatusCode status;
mutable Error error;
static SEM_ID globalErrorMutex;
static Error globalError;
ErrorBase();
private:
DISALLOW_COPY_AND_ASSIGN(ErrorBase);
};
#endif