//**************************************************************************************************
//
// FATAL ERROR SUPPORT (TYPES):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"
namespace RuntimeForStatic {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$EmergencyCallback"-TYPE FOR USER ACTIONS IN FATAL ERROR TERMINATION THREAD (FUNCTION POINTER):
//
//==================================================================================================
typedef void (*$EmergencyCallback)(PCWSTR errorMessage);
//==================================================================================================


//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$FatalError" STATIC CLASS — GRACEFUL TERMINATION OF ENTIRE PROCESS:
//
//==================================================================================================
class $FatalError
{
$STATIC_CLASS( $FatalError )
public:
   static bool IsInRaiseCallerThread();
   static bool IsInTermination();
   static bool IsInTerminationThread();
   static DWORD RaiseCallerThreadId($O) $strict_result;
   static DWORD GetRaiseCallerThreadId() $zero_on_failure;
   static DWORD TerminationThreadId($O) $strict_result;
   static DWORD GetTerminationThreadId() $zero_on_failure;
   static bool UseDesktopInteraction() $or_true;
public:
   static $ActionRoutine      GetRaiseTrigger()          $or_null;
   static $EmergencyCallback  GetEmergencyHandler()      $or_null;
   static $EmergencyCallback  GetEmergencyFinalHandler() $or_null;
public:
   static void Raise( $CI_REF, PCWSTR message ) $not_returns;
   static void RaiseFmt( $CI_REF, PCWSTR messageFmt, ... ) $not_returns;
   static void RaiseVA( $CI_REF, PCWSTR messageFmt, va_list argList ) $not_returns;
public:
   static void RaiseFunctionFailure( $CI_REF, PCWSTR functionName ) $not_returns;

   static void RaiseWin32Error( $CI_REF, DWORD dwError ) $not_returns;
   static void RaiseWin32FuncFailure( $CI_REF, PCWSTR win32FunctionName ) $not_returns;
   static void RaiseLastSystemError( $CI_REF ) $not_returns;

   static void RaiseLastError( $CI_REF ) $not_returns $requires_rt_n_thread_init;
public:
   static void RaiseInvalidOperation( $CI_REF ) $not_returns;
   static void RaiseInvalidOperationWithMessage( $CI_REF, PCWSTR message ) $not_returns;
   static void RaiseInvalidOperationWithMessageFmt( $CI_REF, PCWSTR messageFmt, ... ) $not_returns;
   static void RaiseInvalidOperationWithMessageVA( $CI_REF, PCWSTR messageFmt, va_list argList )
                                                            $not_returns;
   static void RaiseZeroValue( $CI_REF ) $not_returns;
   static void RaiseNegativeValue( $CI_REF ) $not_returns;
   static void RaiseNotPozitiveValue( $CI_REF ) $not_returns;

   static void RaiseNullPointer( $CI_REF ) $not_returns;

   static void RaiseNullTarget( $CI_REF ) $not_returns;
   static void RaiseNullHandle( $CI_REF ) $not_returns;
   static void RaiseInvalidHandleValue( $CI_REF ) $not_returns;

   static void RaiseNotValidDisposable( $CI_REF ) $not_returns;
   static void RaiseDisposableWasAlreadyCreated( $CI_REF ) $not_returns;

   static void RaiseDeadCodeBranch( $CI_REF ) $not_returns;
   static void RaiseNotImplemented( $CI_REF ) $not_returns;
public:
   static void RaiseIncorrectArguments( $CI_REF ) $not_returns;
   static void RaiseIncorrectArgumentsWithMessage( $CI_REF, PCWSTR message ) $not_returns;
   static void RaiseIncorrectArgumentsWithMessageFmt( $CI_REF, PCWSTR messageFmt, ... )
                                                               $not_returns;
   static void RaiseIncorrectArgumentsWithMessageVA( $CI_REF, PCWSTR messageFmt, va_list argList )
                                                              $not_returns;

   static void RaiseIncorrectArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;
   static void RaiseIncorrectArgumentWithMessage( $CI_REF, PCWSTR argumentVarName, PCWSTR message )
                                                           $not_returns;
   static void RaiseIncorrectArgumentWithMessageFmt( $CI_REF, PCWSTR argumentVarName,
                                                              PCWSTR messageFmt, ... ) $not_returns;
   static void RaiseIncorrectArgumentWithMessageVA( $CI_REF, PCWSTR argumentVarName,
                                                             PCWSTR messageFmt, va_list argList )
                                                             $not_returns;
   static void RaiseZeroValueArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;
   static void RaiseNegativeValueArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;
   static void RaiseNotPozitiveValueArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;

   static void RaiseNullPointerArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;
   static void RaiseNullTargetOfArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;
   static void RaiseNullHandleArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;

   static void RaiseInvalidHandleValueArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;
   static void RaiseInvalidDisposableArgument( $CI_REF, PCWSTR argumentVarName ) $not_returns;
public:
   static void RaiseAssertionFailure( $CI_REF ) $not_returns;
   static void RaiseAssertionFailure( $CI_REF, PCWSTR conditionExp $optional ) $not_returns;
public:
   static void RaiseMemoryAllocationFailure() $not_returns;
private:
#include "..\private\FatalError.private.h"
}; // $FatalError
//==================================================================================================

} // RuntimeForStatic
