memory/ | |
License | Copyright © 2007-2011, FreeBASIC Extended Library Development Group |
Macros | |
FBEXT_DECLARE_SHAREDPTR | Defines the SharedPtr object class for a particular type, and any declarations it needs. |
SharedPtr | A generic reference-counting smart pointer class. |
Functions | |
default constructor | Constructs a fbext_SharedPtr(T_) with the address of a resource. |
constructor | Constructs a fbext_SharedPtr(T_) with the address of a resource. |
copy constructor | Constructs a fbext_SharedPtr(T_) by sharing the resource of another. |
destructor | Destroys a fbext_SharedPtr(T_). |
let | Shares a resource with another fbext_SharedPtr(T_). |
Reset | Forces the fbext_SharedPtr(T_) to reference another resource. |
Reset | Forces the fbext_SharedPtr(T_) to reference another resource. |
Get | Retrieves the wrapped pointer. |
Swap_ | Swaps the value of this fbext_SharedPtr(T_) with another. |
Macros | |
FBEXT_DEFINE_SHAREDPTR | Defines the fbext_SharedPtr(T_) object class implementation. |
Copyright © 2007-2011, FreeBASIC Extended Library Development Group
Distributed under the FreeBASIC Extended Library Group license. See accompanying file LICENSE.txt or copy at http://code.google.com
A generic reference-counting smart pointer class.
SharedPtr objects reference resources, and are responsible for freeing that resource when it’s no longer referenced. Copying a SharedPtr results in another SharedPtr that shares the resource, if any, of the original. When all SharedPtr objects that share a particular resource are destroyed, the resource is also destroyed, using ..DELETE, or a user-defined destruction procedure.
<SharedPtr example>
Functions | |
default constructor | Constructs a fbext_SharedPtr(T_) with the address of a resource. |
constructor | Constructs a fbext_SharedPtr(T_) with the address of a resource. |
copy constructor | Constructs a fbext_SharedPtr(T_) by sharing the resource of another. |
destructor | Destroys a fbext_SharedPtr(T_). |
let | Shares a resource with another fbext_SharedPtr(T_). |
Reset | Forces the fbext_SharedPtr(T_) to reference another resource. |
Reset | Forces the fbext_SharedPtr(T_) to reference another resource. |
Get | Retrieves the wrapped pointer. |
Swap_ | Swaps the value of this fbext_SharedPtr(T_) with another. |
Macros | |
FBEXT_DEFINE_SHAREDPTR | Defines the fbext_SharedPtr(T_) object class implementation. |
Constructs a fbext_SharedPtr(T_) with the address of a resource.
p | The address of the resource to reference. |
p defaults to //null// if not specified, meaning the fbext_SharedPtr(T_) references no resource. When the last fbext_SharedPtr(T_) referencing the resource is destroyed, ..DELETE will be called to free the resource.
declare constructor ( byval p as fbext_TypeName(T_) ptr, byval d as fbext_DestroyProc(T_) )
Constructs a fbext_SharedPtr(T_) with the address of a resource.
p | The address of the resource to reference. |
destroy | The address of a procedure that will be passed the wrapped pointer when no more fbext_SharedPtr(T_) objects reference it. |
p defaults to //null// if not specified, meaning the fbext_SharedPtr(T_) references no resource. When the last fbext_SharedPtr(T_) referencing the resource is destroyed, d will be called to handle freeing the resource. If d is //null//, ..DELETE will be called instead.
declare operator let ( byref x as fbext_SharedPtr(T_) )
Shares a resource with another fbext_SharedPtr(T_).
x | The other fbext_SharedPtr(T_). |
If no other fbext_SharedPtr(T_) references this resource, it is destroyed using ..DELETE, or the user-supplied destruction procedure. The fbext_SharedPtr(T_) will then share the resource, if any, of x.
Behaves like this.Swap_(fbext_SharedPtr(T_)(x)).
declare sub Reset ( byval p as fbext_TypeName(T_) ptr = null )
Forces the fbext_SharedPtr(T_) to reference another resource.
p | The address of the new resource. |
If no other fbext_SharedPtr(T_) references this resource, it is destroyed using ..DELETE, or the user-supplied destruction procedure. The fbext_SharedPtr(T_) will then reference the resource pointed to by p, or no resource if p is //null//.
Behaves like this.Swap_(fbext_SharedPtr(T_)(p)).
declare sub Reset ( byval p as fbext_TypeName(T_) ptr, byval d as fbext_DestroyProc(T_) )
Forces the fbext_SharedPtr(T_) to reference another resource.
p | The address of the new resource. |
destroy | The address of a procedure that will be passed the wrapped pointer when no more fbext_SharedPtr(T_) objects reference it. |
If no other fbext_SharedPtr(T_) references this resource, it is destroyed using ..DELETE, or the user-supplied destruction procedure. The fbext_SharedPtr(T_) will then reference the resource pointed to by p, or no resource if p is //null//.
Behaves like this.Swap_(fbext_SharedPtr(T_)(p, d)).
Constructs a fbext_SharedPtr(T_) with the address of a resource.
declare constructor ( byval p as fbext_TypeName(T_) ptr, byval d as fbext_DestroyProc(T_) )
Destroys a fbext_SharedPtr(T_).
declare destructor ( )
Shares a resource with another fbext_SharedPtr(T_).
declare operator let ( byref x as fbext_SharedPtr(T_) )
Forces the fbext_SharedPtr(T_) to reference another resource.
declare sub Reset ( byval p as fbext_TypeName(T_) ptr = null )
Retrieves the wrapped pointer.
declare function Get ( ) as fbext_TypeName(T_) ptr
Swaps the value of this fbext_SharedPtr(T_) with another.
declare sub Swap_ ( byref x as fbext_SharedPtr(T_) )