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

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$Handle" STATIC CLASS — SIMPLE OPERATIONS:
//
//==================================================================================================
class $Handle
{
$STATIC_CLASS( $Handle )
public:
   static bool IsValid(HANDLE value,bool isOfInvalidHandleValueCategory);
public:
   static HANDLE Exchange(HANDLE& location,HANDLE value) $ret_previous;
   static HANDLE CompareExchange(HANDLE& location,HANDLE exchange,HANDLE comparand);
   static HANDLE SetNull(HANDLE& target) $ret_target;
   static HANDLE SetInvalidValue(HANDLE& target) $ret_target;
   static HANDLE NullExchange(HANDLE& location) $ret_previous;
   static HANDLE InvalidValueExchange(HANDLE& location) $ret_previous;
public:
   static HANDLE Read($A, HANDLE volatile* pSource );
   static HANDLE Write($A, HANDLE volatile* pTarget, HANDLE value ) $ret_target;
   static HANDLE Exchange($A, HANDLE volatile* pLocation, HANDLE value ) $ret_previous;
   static HANDLE CompareExchange($A, HANDLE volatile* pLocation,
                                     HANDLE exchange, HANDLE comparand );
   static HANDLE SetNull($A, HANDLE volatile* pTarget ) $ret_target;
   static HANDLE SetInvalidValue($A, HANDLE volatile* pTarget ) $ret_target;
   static HANDLE NullExchange($A, HANDLE volatile* pLocation ) $ret_previous;
   static HANDLE InvalidValueExchange($A, HANDLE volatile* pLocation ) $ret_previous;
public:
   static bool Close( HANDLE& handle ) $last_error;
   static bool Close( HANDLE& handle, bool isOfInvalidHandleValueCategory ) $last_error;
   static bool Close($A, HANDLE volatile* pHandle ) $last_error;
   static bool Close($A, HANDLE volatile* pHandle,
                         bool isOfInvalidHandleValueCategory ) $last_error;
private:
#include "..\private\Handle.private.h"
}; // $Handle
//==================================================================================================


//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$Handles" STATIC CLASS — SIMPLE OPERATIONS:
//
//==================================================================================================
class $Handles
{
public:
   static bool Close($A, const std::initializer_list<HANDLE volatile*>& handlePointers ) $last_error;
   static bool Close($A, const std::initializer_list<HANDLE volatile*>& handlePointers,
                         bool isOfInvalidHandleValueCategory ) $last_error;
}; // $Handles
//==================================================================================================

} // RuntimeForStatic
