//**************************************************************************************************
//
// SIMPLE CLASS FOR AUTOMATIC DEALLOCATION OF RAW MEMORY (WITHOUT DESTRUCTOR):
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// RuntimeForStatic base library | C+- (SysRoutine) | Author: Sergei Y.Kitáev
#pragma once
#include "include_restrictions.h"
namespace RuntimeForStatic {

//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//
// "$AutoFreePtr"-CLASS:
//
//==================================================================================================
class $AutoFreePtr: public $Disposable
{
public:
   $AutoFreePtr();
   $AutoFreePtr($A, PVOID pointer );
   $AutoFreePtr($A, PVOID pointer,
                    $MemFreeRoutine specialFreeRoutine $optional );
public:
   $AutoFreePtr& operator = ($AutoFreePtr& predecessor) $owner_transfer;
public:
   __declspec(property(get = GetHasPointer)) bool HasPointer;
public:
   PVOID P($O) const $alias("Pointer") $strict_result;
   bool GetHasPointer() const;
public:
   void VerifyHasPointer($O) const $fatal_error_on_failure;

   PVOID AttachPointer($OA, PVOID pointer )
                            $imaginary_param("freePrevious",true)
                            $ret_target;
   PVOID AttachPointer($OA, PVOID pointer, $MemFreeRoutine specialFreeRoutine $optional )
                            $imaginary_param("freePrevious",true)
                            $ret_target;
   PVOID AttachPointer($OA, bool freePrevious, PVOID pointer ) $ret_target;
   PVOID AttachPointer($OA, bool freePrevious, PVOID pointer,
                            $MemFreeRoutine specialFreeRoutine $optional ) $ret_target;

   PVOID DetachPointer() $or_null $ret_previous;
   PVOID TakePointerOwnership($O) $not_null $ret_previous $needs_free;
   void Free();
protected:
   virtual void DoDispose($CI_REF) override;
   void ResetSuperstructure();
private:
#include "..\private\AutoFreePtr.private.h"
}; // $AutoFreePtr
typedef $AutoFreePtr*       $PAutoFreePtr;
typedef const $AutoFreePtr* $PCAutoFreePtr;
//==================================================================================================

} // RuntimeForStatic
