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

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$TLS" STATIC CLASS:
//
//==================================================================================================
class $TLS
{
$STATIC_CLASS( $TLS )
public:
   static void Allocate($A,DWORD volatile* pIndex $out) $fatal_error_on_failure;
   static bool AllocateNS($A,DWORD volatile* pIndex $out) $last_error;
   static void Free($A, DWORD volatile* pIndex $out $optional_through(TLS_OUT_OF_INDEXES) )
                        $fatal_error_on_failure;
public:
   static PVOID GetPointer($A,DWORD volatile* pIndex);
   static PVOID StrictGetPointer($A,DWORD volatile* pIndex) $not_null;
   static PVOID SetPointer($A,DWORD volatile* pIndex,PVOID pointer $optional) $ret_target;
   static inline PVOID ResetPointer($A,DWORD volatile* pIndex) $ret_target
   #include "..\inline\TLS\ResetPointer.impl.h"
   static int GetInt32($A,DWORD volatile* pIndex);
   static int SetInt32($A,DWORD volatile* pIndex,int value) $ret_target;
   static inline int ResetInt32($A,DWORD volatile* pIndex) $ret_target
   #include "..\inline\TLS\ResetInt32.impl.h"
   static unsigned int GetUInt32($A,DWORD volatile* pIndex);
   static unsigned int SetUInt32($A,DWORD volatile* pIndex,unsigned int value) $ret_target;
   static inline unsigned int ResetUInt32($A,DWORD volatile* pIndex) $ret_target
   #include "..\inline\TLS\ResetUInt32.impl.h"
   static bool GetAsBool($A,DWORD volatile* pIndex);
   static inline bool SetAsBool($A,DWORD volatile* pIndex) $ret_target
   #include "..\inline\TLS\SetAsBool.impl.h"
   static bool SetAsBool($A,DWORD volatile* pIndex,bool value) $ret_target;
   static inline bool ResetAsBool($A,DWORD volatile* pIndex) $ret_target
   #include "..\inline\TLS\ResetAsBool.impl.h"
   static bool IsInitialized($A,DWORD volatile* pIndex);
   static PVOID GetPointerIfInitialized($A,DWORD volatile* pIndex) $or_null;
   static int GetInt32IfInitialized($A,DWORD volatile* pIndex) $or_zero;
   static unsigned int GetUInt32IfInitialized($A,DWORD volatile* pIndex) $or_zero;
   static bool GetAsBoolIfInitialized($A,DWORD volatile* pIndex) $or_false;
public:
   static DWORD VerifyIndexArgument($A,PCWSTR argumentVarName,DWORD volatile* pIndex);
   static DWORD VerifyIndexValue($A,PCWSTR argumentVarName,DWORD slotIndex);
}; // $TLS
//==================================================================================================

} // RuntimeForStatic
