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

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$tstatic" TEMPLATE CLASS:
//
//==================================================================================================
template<typename T>class $tstatic: public $Disposable $thread_static_object
{
public:
   $tstatic<T>($A, int slotIdx );

   $tstatic<T>& operator = ($tstatic<T>& predecessor) $owner_transfer;
public:
   __declspec(property(get = GetHasReference    )) bool HasReference;
   __declspec(property(get = GetAutoFree        )) bool AutoFree;
   __declspec(property(get = GetIsDeletable     )) bool IsDeletable;
   __declspec(property(get = GetIsDeletableArray)) bool IsDeletableArray;
public:
   void AttachMemory($OA,T* pointer) $imaginary_param("autoFree",true);
   void AttachMemory($OA,T* pointer,bool autoFree);
   void AttachDeletable($OA,T* pointer);
   void AttachDeletable($OA,T* pointer,bool isArray);
   void DetachReference();
   void ReleaseAutoRC();
public:
   T& D($O) const $alias("Data");
   T* P($O) const $alias("Pointer") $strict_result;
   DWORD SlotIdx($O) const;
public:
   bool GetHasReference() const;
   bool GetAutoFree() const;
   bool GetIsDeletable() const;
   bool GetIsDeletableArray() const;
   void VerifyHasReference($O) const;
   void VerifyReferenceNotAttached($O) const;
public:
   static $tstatic<T> CreateAttachMemory($A, int slotIdx, T* pointer )
                                             $imaginary_param("autoFree",true);
   static $tstatic<T> CreateAttachMemory($A,int slotIdx,T* pointer,bool autoFree);
   static $tstatic<T> CreateAttachDeletable($A,int slotIdx,T* pointer);
   static $tstatic<T> CreateAttachDeletable($A,int slotIdx,T* pointer,bool isArray);
protected:
   virtual void DoDispose($CI_REF) override;
   void ResetSuperstructure();
private:
#include "..\..\private\template\tstatic.private.h"
}; // $tstatic<T>
//==================================================================================================

} // RuntimeForStatic
