2012-12-28 20:21:05 +00:00
|
|
|
/*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2020-08-07 09:50:34 +02:00
|
|
|
#pragma once
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup freestyle
|
|
|
|
|
* \brief Singleton to manage exceptions
|
2012-12-28 20:21:05 +00:00
|
|
|
*/
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2013-05-13 22:58:27 +00:00
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
2019-04-17 06:17:24 +02:00
|
|
|
# include "MEM_guardedalloc.h"
|
2013-05-13 22:58:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
class Exception {
|
|
|
|
|
public:
|
|
|
|
|
typedef enum {
|
|
|
|
|
NO_EXCEPTION,
|
|
|
|
|
UNDEFINED,
|
|
|
|
|
} exception_type;
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static int getException()
|
|
|
|
|
{
|
|
|
|
|
exception_type e = _exception;
|
|
|
|
|
_exception = NO_EXCEPTION;
|
|
|
|
|
return e;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static int raiseException(exception_type exception = UNDEFINED)
|
|
|
|
|
{
|
|
|
|
|
_exception = exception;
|
|
|
|
|
return _exception;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void reset()
|
|
|
|
|
{
|
|
|
|
|
_exception = NO_EXCEPTION;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
private:
|
|
|
|
|
static exception_type _exception;
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
2019-04-17 06:17:24 +02:00
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Exception")
|
2013-05-13 22:58:27 +00:00
|
|
|
#endif
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|