Commit d4280f1b authored by Martin Marinov's avatar Martin Marinov

Initial submissions of the Base sources from ReForm.

parents
Pipeline #300 skipped
// (C) Copyright 2015 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef QUALITY_HH_INCLUDED
#define QUALITY_HH_INCLUDED
// This file contains various definitions related to enforcing certain code
// quality rules, e.g., applying W4
// only test this in MSVC
#if defined(_MSC_VER)
// Some warnings are disabled permanently since the cannot be controlled on
// section basis.
//function 'function' marked as __forceinline not inlined
#pragma warning (disable: 4714)
#define LOW_CODE_QUALITY_SECTION_BEGIN __pragma(warning(push, 1))
#define LOW_CODE_QUALITY_SECTION_END __pragma(warning(pop))
#else
#define LOW_CODE_QUALITY_SECTION_BEGIN
#define LOW_CODE_QUALITY_SECTION_END
#endif // ifdef _MSC_VER
#endif // QUALITY_HH_INCLUDED
// (C) Copyright 2015 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_DEBERROR_HH_INCLUDED
#define BASE_DEBERROR_HH_INCLUDED
#ifdef DEB_ON
#include <Base/Utils/BaseError.hh>
#include <Base/Debug/DebOut.hh>
namespace Debug {
inline Stream& operator<<(Stream& _ds, const Base::Error& _err)
{
_ds << "\"" << _err.message() << "\"";
return _ds;
}
}//namespace Debug
#endif//DEB_ON
#endif//BASE_DEBERROR_HH_INCLUDED
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_DEBOUT_HH_INCLUDED
#define BASE_DEBOUT_HH_INCLUDED
// DEB_ON is defined, or not, in CMakeLists.txt for primary project
#ifndef DEB_ON
#define DEB_module(SS)
#define DEB_enter_func
#define DEB_only(CC)
#define DEB_exec(LL, AA) {}
#define DEB_exec_if(CC, LL, AA) {}
#define DEB_out(LL, AA) {}
#define DEB_out_if(CC, LL, AA) {}
#define DEB_line(LL, AA) {}
#define DEB_line_if(CC, LL, AA) {}
#define DEB_warning(LL, AA) {}
#define DEB_warning_if(CC, LL, AA) {}
#define DEB_mesh_if(CC, LL, FF, MM) {}
#define DEB_error(AA) {}
#define DEB_error_if(CC, AA) {}
#else // DEB_ON
#include <string>
#include <vector>
#include <array>
namespace Debug {
const int INVALID_LEVEL = -1;
class Stream;
class Command
{
public:
enum CommandType
{
END = 0x01,
END_LF = 0x03,
END_ERR = 0x07
};
CommandType com_;
CommandType com() const
{
return com_;
}
Command(CommandType _com) : com_(_com) {}
};
// Class used to maintain Stream's CallStack
// This does not currently contain a pointer to the file streamer used
// but might do in future.
class Enter
{
public:
const char* flnm_; //!< File name for this DEB_enter
int nmbr_; //!< deb_nmbr for this function.
int lvl_; //!< deb_level for this function.
int id_; /*!< Unique identifier for this Enter (used in ANCHORS) */
int outs_; /*!< Number of DEB_outs encountered within this function
determining whether a given DEB_out should include or omit
a call stack or exit trace. */
int lns_; /*!< Number of call stack indents including this call. */
Enter(const char* const _flnm, const char* const _fnct, int& _nmbr, int& _lvl);
~Enter();
//! pass the output on the level or not?
bool pass(const int _lvl) const { return _lvl <= lvl_; }
Stream& stream(const int _warn = 0, const bool _print = true);
Command end() const { return Command(Command::CommandType::END); }
Command end_lf() const { return Command(Command::CommandType::END_LF); }
Command end_err() const { return Command(Command::CommandType::END_ERR); }
};
class File;
class Stream
{
public:
enum StreamType
{
APPEND = 0x01,
HTML = 0x02,
RETAIN = 0x04,
KEEP_OPEN = 0x08
};
private:
File* dfile_;
public:
File* dfile() const
{
return dfile_;
}
//! Constructor.
Stream(
const char* _file_name = nullptr, //!< [in] File name if file based.
const StreamType _type = APPEND //!< [in] bitsfield enum type identifier
) ;
~Stream();
const char* string_out() const;
Stream& print(const int);
Stream& print(const double);
Stream& print(const char* const, bool fork = true);
Stream& print(const char);
Stream& print(const Command&);
//! Get the currently active Stream
static Stream& get_global(int _warn = 0);
private:
// inhibit copy
Stream(const Stream&);
Stream& operator=(const Stream&);
};
Stream& operator<<(Stream& _ds, const int i);
Stream& operator<<(Stream& _ds, const double d);
Stream& operator<<(Stream& _ds, const size_t i);
Stream& operator<<(Stream& _ds, const unsigned int i);
Stream& operator<<(Stream& _ds, const float d);
Stream& operator<<(Stream& _ds, const char c);
Stream& operator<<(Stream& _ds, const char* const s);
Stream& operator<<(Stream& _ds, const std::string& s);
Stream& operator<<(Stream& _ds, const Command& co);
// Stream operator for std::vector<>
template< typename ElementT>
Stream& operator<<(Stream& _ds, const std::vector<ElementT>& _vec)
{
_ds << "[ ";
for (const auto el : _vec)
_ds << el << " ";
_ds << "]";
return _ds;
}
// Stream operator for std::array<>
template< typename ElementT, size_t _el_nmbr>
Stream& operator<<(Stream& _ds, const std::array<ElementT, _el_nmbr>& _vec)
{
_ds << "[ ";
for (const auto el : _vec)
_ds << el << " ";
_ds << "]";
return _ds;
}
// Stream operator for fixed size arrays
template <typename ElementT, size_t _el_nmbr>
Stream& operator<<(Stream& _ds, const ElementT(&_arr)[_el_nmbr])
{
_ds << "[ ";
for (const auto el : _arr)
_ds << el << " ";
_ds << "]";
return _ds;
}
// Stream std::pair<>
template <typename T0, typename T1>
Stream& operator<<(Stream& _ds, const std::pair<T0, T1>& _pair)
{
_ds << "(" << _pair.first << ", " << _pair.second << ")";
return _ds;
}
#define DEB_module(MODULE)
//TODO: This should use an atomic thread-safe static int(s)
#define DEB_enter_func static int deb_nmbr = 0; \
static int deb_lvl = Debug::INVALID_LEVEL; \
Debug::Enter deb(__FILE__, __FUNCTION__, deb_nmbr, deb_lvl);
#define DEB_only(CC) CC
#define DEB_exec(LL, AA) DEB_exec_if(true, LL, AA)
#define DEB_exec_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) { AA; } }
#define DEB_out(LL, AA) DEB_out_if(true, LL, AA)
#define DEB_out_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{ deb.stream() << AA << deb.end(); } }
#define DEB_line(LL, AA) DEB_line_if(true, LL, AA)
#define DEB_line_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{ deb.stream() << AA << deb.end_lf(); } }
#define DEB_warning(LL, AA) DEB_warning_if(true, LL, AA)
#define DEB_warning_if(CC, LL, AA) { if (deb.pass(LL) && (CC)) \
{ deb.stream(1) << "WARNING: " << AA << deb.end_lf(); } }
#define DEB_error(AA) { deb.stream(2) << "ERROR: " << AA << deb.end_err(); }
#define DEB_error_if(CC, AA) { if (CC) DEB_error(AA); }
// Stream does not fulfill ostream. If you want to exploit an existing
// ostream streamer to DEB_out a class as text without exploiting any
// numeric processing or custom Stream streamers then use this macro thus
// DEB_out(1, "my_class is " << DEB_os_str(my_c) )
#define DEB_os_str(AA) \
dynamic_cast<std::ostringstream &&>((std::ostringstream() << AA )).str()
}//namespace Debug
#endif // DEB_ON
#endif // BASE_DEBOUT_HH_INCLUDED
This diff is collapsed.
// (C) Copyright 2015 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_DEBTIME_HH_INCLUDED
#define BASE_DEBTIME_HH_INCLUDED
#include <Base/Utils/StopWatch.hh>
#include <Base/Debug/DebOut.hh>
namespace Debug {
class StopWatchSession
{
public:
StopWatchSession(Enter& _deb, const char* _sssn_name = nullptr,
const int _deb_lvl = 2)
: deb(_deb), sssn_name_(_sssn_name), deb_lvl_(_deb_lvl)
{
sw_.start();
}
~StopWatchSession()
{
// TODO: implement "prettier" DEB out if seconds turn into minutes/hours/etc
DEB_line(deb_lvl_, sssn_name_ << " took " << sw_.stop()/1000.0 << " s.");
}
private:
Enter& deb; // intentional variable name match with the DEB_marcos!
const char* sssn_name_;
const int deb_lvl_;
Base::StopWatch sw_;
private:
// disable copy and assignment
StopWatchSession(const StopWatchSession&);
StopWatchSession& operator=(const StopWatchSession&);
};
} //namespace Debug
#define DEB_time_session(SSSN, LL) \
Debug::StopWatchSession __sw_sssn(deb, SSSN, LL);
#define DEB_time_session_def(SSSN) \
Debug::StopWatchSession __sw_sssn(deb, SSSN, 2);
#define DEB_time_func(LL) DEB_enter_func \
Debug::StopWatchSession __sw_func(deb, __FUNCTION__, LL);
#define DEB_time_func_def DEB_time_func(2)
#endif//BASE_DEBTIME_HH_INCLUDED
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_DEBUTILS_HH_INCLUDED
#define BASE_DEBUTILS_HH_INCLUDED
#include <Base/Debug/DebOut.hh>
#ifdef DEB_ON
namespace Debug {
/*! A currently empty control interface class onto the DebFile class(es)
exploited by DebStream. */
class Controller
{
public:
//! Set printf style format string used for double (and float) numeric print
static void set_double_format(const char* _fmt);
static const char* double_format();
};
class DoubleFormatSession
{
public:
DoubleFormatSession(const char* _fmt)
: fmt_bck_(Controller::double_format())
{
Controller::set_double_format(_fmt);
}
~DoubleFormatSession()
{
Controller::set_double_format(fmt_bck_.data());
}
private:
std::string fmt_bck_;
};
}// namespace Debug
//#define DEB_set_module_level(MM, LL) { Controller::set_module_level(MM, LL); }
//#define DEB_set_double_format(FF) { Controller::set_double_format(FF); }
#define DEB_double_format(FF) Debug::DoubleFormatSession double_format(FF);
#else
//#define DEB_set_module_level(MM, LL) {}
//#define DEB_set_double_format(FF) {}
#define DEB_double_format(FF)
#endif
#endif // BASE_DEBUTILS_HH_INCLUDED
// (C) Copyright 2014 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef MANDATORY_HH_INCLUDED
#define MANDATORY_HH_INCLUDED
// only test this in MSVC and in builds where _SECURE is defined
#if defined(_MSC_VER) && defined(_SECURE)
#include <cstdio>
#include <cstring>
#include <cwchar>
#include <iosfwd>
#include <malloc.h>
#include <ostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <typeinfo>
#include <wchar.h>
#include <xlocale>
#include <xlocbuf>
#include <xlocmon>
#include <xlocnum>
#include <xutility>
#define _SDL_BANNED_RECOMMENDED 1
#include "banned.h"
#pragma warning(error:4995) // set this as an error from here on
#define INSECURE_INCLUDE_SECTION_BEGIN __pragma(warning(push)) \
__pragma(warning(disable:4995))
#define INSECURE_INCLUDE_SECTION_END __pragma(warning(pop))
#else
#define INSECURE_INCLUDE_SECTION_BEGIN
#define INSECURE_INCLUDE_SECTION_END
#endif // ifdef _MSC_VER
#endif // MANDATORY_HH_INCLUDED
/***
* banned.h - list of Microsoft Security Development Lifecycle (SDL) banned APIs
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Purpose:
* This include file contains a list of banned APIs which should not be used in new code and
* removed from legacy code over time.
*
* History
* 01-Jan-2006 - mikehow - Initial Version
* 22-Apr-2008 - mikehow - Updated to SDL 4.1, commented out recommendations and added memcpy
* 26-Jan-2009 - mikehow - Updated to SDL 5.0, made the list sane, added SDL compliance levels
* 10-Feb-2009 - mikehow - Updated based on feedback from MS Office
* 12-May-2009 - jpardue - Added wmemcpy
* 08-Jul-2009 - mikehow - Fixed header #ifndef/#endif logic, made the SDL recommended compliance level name more obvious
* 05-Nov-2009 - mikehow - Added vsnprintf (ANSI version of _vsnprintf)
* 01-Jan-2010 - mikehow - Added better strsafe integration, now the following works:
* #include "strsafe.h"
* #include "banned.h"
* 04-Jun-2010 - mikehow - Small "#if" bug fix
* 16-Jun-2011 - mikehow - Added the two _CRT_SECURE_xxxxx macros
* 07-Jul-2011 - mikehow - Bugfix when using recommended banned functions and StrSafe. Locally surpressed C4005 warnings
* 01-Feb-2013 - martinwo - Added license to header.
***/
#ifndef _INC_BANNED
# define _INC_BANNED
# if defined(_MSC_VER)
# pragma once
// Flip the 'auto-migrate' functionality in VC++
// Some functions, such as strcpy() are changed to safer functions by the compiler
// More info: http://blogs.msdn.com/b/sdl/archive/2010/02/16/vc-2010-and-memcpy.aspx
#ifndef _SDL_DONT_AUTO_FIX
# pragma warning(push)
# pragma warning(disable: 4005)
// strcpy etc
# define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES (1)
// memcpy etc
# define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_MEMORY (1)
# pragma warning(pop)
#endif
// SDL 5.0 and later Requirements
# if defined(_STRSAFE_H_INCLUDED_) && !defined(STRSAFE_NO_DEPRECATE)
// Only deprecate what's not already deprecated by StrSafe
# pragma deprecated (_mbscpy, _mbccpy)
# pragma deprecated (strcatA, strcatW, _mbscat, StrCatBuff, StrCatBuffA, StrCatBuffW, StrCatChainW, _tccat, _mbccat)
# pragma deprecated (strncpy, wcsncpy, _tcsncpy, _mbsncpy, _mbsnbcpy, StrCpyN, StrCpyNA, StrCpyNW, StrNCpy, strcpynA, StrNCpyA, StrNCpyW, lstrcpyn, lstrcpynA, lstrcpynW)
# pragma deprecated (strncat, wcsncat, _tcsncat, _mbsncat, _mbsnbcat, lstrncat, lstrcatnA, lstrcatnW, lstrcatn)
# pragma deprecated (IsBadWritePtr, IsBadHugeWritePtr, IsBadReadPtr, IsBadHugeReadPtr, IsBadCodePtr, IsBadStringPtr)
# pragma deprecated (memcpy, RtlCopyMemory, CopyMemory, wmemcpy)
# else
// StrSafe not loaded, so deprecate everything!
# pragma deprecated (strcpy, strcpyA, strcpyW, wcscpy, _tcscpy, _mbscpy, StrCpy, StrCpyA, StrCpyW, lstrcpy, lstrcpyA, lstrcpyW, _tccpy, _mbccpy, _ftcscpy)
# pragma deprecated (strcat, strcatA, strcatW, wcscat, _tcscat, _mbscat, StrCat, StrCatA, StrCatW, lstrcat, lstrcatA, lstrcatW, StrCatBuff, StrCatBuffA, StrCatBuffW, StrCatChainW, _tccat, _mbccat, _ftcscat)
# pragma deprecated (sprintfW, sprintfA, wsprintf, wsprintfW, wsprintfA, sprintf, swprintf, _stprintf)
# pragma deprecated (wvsprintf, wvsprintfA, wvsprintfW, vsprintf, _vstprintf, vswprintf)
# pragma deprecated (strncpy, wcsncpy, _tcsncpy, _mbsncpy, _mbsnbcpy, StrCpyN, StrCpyNA, StrCpyNW, StrNCpy, strcpynA, StrNCpyA, StrNCpyW, lstrcpyn, lstrcpynA, lstrcpynW)
# pragma deprecated (strncat, wcsncat, _tcsncat, _mbsncat, _mbsnbcat, StrCatN, StrCatNA, StrCatNW, StrNCat, StrNCatA, StrNCatW, lstrncat, lstrcatnA, lstrcatnW, lstrcatn)
# pragma deprecated (gets, _getts, _gettws)
# pragma deprecated (IsBadWritePtr, IsBadHugeWritePtr, IsBadReadPtr, IsBadHugeReadPtr, IsBadCodePtr, IsBadStringPtr)
# pragma deprecated (memcpy, RtlCopyMemory, CopyMemory, wmemcpy)
# endif //defined(_STRSAFE_H_INCLUDED_) && !defined(STRSAFE_NO_DEPRECATE)
// SDL 5.0 and later Recommendations
# if defined(_SDL_BANNED_RECOMMENDED)
# if defined(_STRSAFE_H_INCLUDED_) && !defined(STRSAFE_NO_DEPRECATE)
// Only deprecate what's not already deprecated by StrSafe
# pragma deprecated (wnsprintf, wnsprintfA, wnsprintfW)
# pragma deprecated (vsnprintf, wvnsprintf, wvnsprintfA, wvnsprintfW)
# pragma deprecated (strtok, _tcstok, wcstok, _mbstok)
# pragma deprecated (makepath, _tmakepath, _makepath, _wmakepath)
# pragma deprecated (_splitpath, _tsplitpath, _wsplitpath)
# pragma deprecated (scanf, wscanf, _tscanf, sscanf, swscanf, _stscanf, snscanf, snwscanf, _sntscanf)
# pragma deprecated (_itoa, _itow, _i64toa, _i64tow, _ui64toa, _ui64tot, _ui64tow, _ultoa, _ultot, _ultow)
# pragma deprecated (CharToOem, CharToOemA, CharToOemW, OemToChar, OemToCharA, OemToCharW, CharToOemBuffA, CharToOemBuffW)
# pragma deprecated (alloca, _alloca)
# pragma deprecated (strlen, wcslen, _mbslen, _mbstrlen, StrLen, lstrlen)
# pragma deprecated (ChangeWindowMessageFilter)
# else
// StrSafe not loaded, so deprecate everything!
# pragma deprecated (wnsprintf, wnsprintfA, wnsprintfW, _snwprintf, _snprintf, _sntprintf)
# pragma deprecated (_vsnprintf, vsnprintf, _vsnwprintf, _vsntprintf, wvnsprintf, wvnsprintfA, wvnsprintfW)
# pragma deprecated (strtok, _tcstok, wcstok, _mbstok)
# pragma deprecated (makepath, _tmakepath, _makepath, _wmakepath)
# pragma deprecated (_splitpath, _tsplitpath, _wsplitpath)
# pragma deprecated (scanf, wscanf, _tscanf, sscanf, swscanf, _stscanf, snscanf, snwscanf, _sntscanf)
# pragma deprecated (_itoa, _itow, _i64toa, _i64tow, _ui64toa, _ui64tot, _ui64tow, _ultoa, _ultot, _ultow)
# pragma deprecated (CharToOem, CharToOemA, CharToOemW, OemToChar, OemToCharA, OemToCharW, CharToOemBuffA, CharToOemBuffW)
# pragma deprecated (alloca, _alloca)
# pragma deprecated (strlen, wcslen, _mbslen, _mbstrlen, StrLen, lstrlen)
# pragma deprecated (ChangeWindowMessageFilter)
# endif // StrSafe
# endif // SDL recommended
# endif // _MSC_VER_
#endif // _INC_BANNED
// (C) Copyright 2015 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#include "BaseError.hh"
namespace Base {
static const char* ERROR_MESSAGE[] =
{
#define DEFINE_ERROR(CODE, MSG) MSG,
#include "BaseErrorInc.hh"
#undef DEFINE_ERROR
};
const char* Error::message() const { return ERROR_MESSAGE[idx_]; }
}//namespace Base
// (C) Copyright 2015 by Autodesk, Inc.
//
// The information contained herein is confidential, proprietary
// to Autodesk, Inc., and considered a trade secret as defined
// in section 499C of the penal code of the State of California.
// Use of this information by anyone other than authorized
// employees of Autodesk, Inc. is granted only under a written
// non-disclosure agreement, expressly prescribing the scope
// and manner of such use.
#ifndef BASE_ERROR_HH_INCLUDED
#define BASE_ERROR_HH_INCLUDED
#include <Base/Utils/ThrowError.hh>
namespace Base {
class Error
{
public:
enum Index
{
#define DEFINE_ERROR(CODE, MSG) CODE,
#include <Base/Utils/BaseErrorInc.hh>
#undef DEFINE_ERROR
};
public:
//! Constructor.
Error(const Index _idx) : idx_((int)_idx) {}
// ! Get the outcome error index
int index() const { return (int)idx_; }
//! Return the error message
virtual const char* message() const;