Added the trunk/branches/tags directories at repository root, and moved previous root into trunk/
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1002 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
commit
2f524481c1
974 changed files with 295448 additions and 0 deletions
93
dotnet/src/Window/ObjectBase.cs
Normal file
93
dotnet/src/Window/ObjectBase.cs
Normal file
|
@ -0,0 +1,93 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace SFML
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// The ObjectBase class is an abstract base for every
|
||||
/// SFML object. It's meant for internal use only
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public abstract class ObjectBase : IDisposable
|
||||
{
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Construct the object from a pointer to the C library object
|
||||
/// </summary>
|
||||
/// <param name="thisPtr">Internal pointer to the object in the C libraries</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
public ObjectBase(IntPtr thisPtr)
|
||||
{
|
||||
myThis = thisPtr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Dispose the object
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
~ObjectBase()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Access to the internal pointer of the object.
|
||||
/// For internal use only
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public IntPtr This
|
||||
{
|
||||
get {return myThis;}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Explicitely dispose the object
|
||||
/// </summary>
|
||||
////////////////////////////////////////////////////////////
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Destroy the object
|
||||
/// </summary>
|
||||
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
private void Dispose(bool disposing)
|
||||
{
|
||||
if (myThis != IntPtr.Zero)
|
||||
{
|
||||
Destroy(disposing);
|
||||
myThis = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Destroy the object (implementation is left to each derived class)
|
||||
/// </summary>
|
||||
/// <param name="disposing">Is the GC disposing the object, or is it an explicit call ?</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
protected abstract void Destroy(bool disposing);
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
/// <summary>
|
||||
/// Set the pointer to the internal object. For internal use only
|
||||
/// </summary>
|
||||
/// <param name="thisPtr">Pointer to the internal object in C library</param>
|
||||
////////////////////////////////////////////////////////////
|
||||
protected void SetThis(IntPtr thisPtr)
|
||||
{
|
||||
myThis = thisPtr;
|
||||
}
|
||||
|
||||
private IntPtr myThis = IntPtr.Zero;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue