2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00: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
|
|
|
|
|
# include "MEM_guardedalloc.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
namespace Freestyle {
|
|
|
|
|
|
2014-04-17 14:19:10 +09:00
|
|
|
class Exception {
|
2008-04-30 15:41:54 +00:00
|
|
|
public:
|
2012-12-28 20:21:05 +00:00
|
|
|
typedef enum {
|
|
|
|
|
NO_EXCEPTION,
|
|
|
|
|
UNDEFINED,
|
|
|
|
|
} exception_type;
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
static int getException()
|
|
|
|
|
{
|
|
|
|
|
exception_type e = _exception;
|
|
|
|
|
_exception = NO_EXCEPTION;
|
|
|
|
|
return e;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
static int raiseException(exception_type exception = UNDEFINED)
|
|
|
|
|
{
|
|
|
|
|
_exception = exception;
|
|
|
|
|
return _exception;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
2012-12-28 20:21:05 +00:00
|
|
|
static void reset()
|
|
|
|
|
{
|
|
|
|
|
_exception = NO_EXCEPTION;
|
|
|
|
|
}
|
2008-04-30 15:41:54 +00:00
|
|
|
|
|
|
|
|
private:
|
2012-12-28 20:21:05 +00:00
|
|
|
static exception_type _exception;
|
2013-05-13 22:58:27 +00:00
|
|
|
|
|
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
|
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Exception")
|
|
|
|
|
#endif
|
2008-04-30 15:41:54 +00:00
|
|
|
};
|
|
|
|
|
|
2013-04-09 00:46:49 +00:00
|
|
|
} /* namespace Freestyle */
|