+++ /dev/null
-/*\r
-* Copyright (c) 2007-2010 SlimDX Group\r
-* \r
-* Permission is hereby granted, free of charge, to any person obtaining a copy\r
-* of this software and associated documentation files (the "Software"), to deal\r
-* in the Software without restriction, including without limitation the rights\r
-* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
-* copies of the Software, and to permit persons to whom the Software is\r
-* furnished to do so, subject to the following conditions:\r
-* \r
-* The above copyright notice and this permission notice shall be included in\r
-* all copies or substantial portions of the Software.\r
-* \r
-* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
-* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
-* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
-* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
-* THE SOFTWARE.\r
-*/\r
-#pragma once\r
-\r
-#include "ObjectTable.h"\r
-#include "Configuration.h"\r
-#include "Result.h"\r
-#include "Utilities.h"\r
-#include "InternalHelpers.h"\r
-\r
-#ifdef XMLDOCS\r
-using System::IntPtr;\r
-using System::Diagnostics::StackTrace;\r
-#endif\r
-\r
-#include "ComObjectMacros.h"\r
-\r
-namespace SlimDX\r
-{ \r
- [System::Flags]\r
- enum class ComObjectFlags\r
- {\r
- None = 0,\r
- IsAncillary = 1,\r
- IsExternal = 2\r
- };\r
- \r
- public interface struct IComObject : System::IDisposable\r
- {\r
- public:\r
- property System::IntPtr ComPointer\r
- {\r
- virtual System::IntPtr get() = 0;\r
- }\r
- };\r
-\r
- /// <summary>\r
- /// The base class for all SlimDX types which represent COM interfaces.\r
- /// </summary>\r
- /// <unmanaged>IUnknown</unmanaged>\r
- public ref class ComObject abstract : IComObject\r
- {\r
- private:\r
- IUnknown* m_Unknown;\r
- ComObject^ m_Owner;\r
- ComObjectFlags m_Flags;\r
- System::Diagnostics::StackTrace^ m_Source;\r
- int m_CreationTime;\r
-\r
- private protected:\r
- ComObject();\r
- \r
- void Construct( IUnknown* pointer );\r
- void Construct( IUnknown* pointer, ComObject^ owner );\r
- void Construct( System::IntPtr pointer, System::Guid guid );\r
- void Destruct();\r
- \r
- template< typename M, typename N >\r
- static M^ ConstructFromPointer( N* pointer, ComObject^ owner, ComObjectFlags flags ) \r
- {\r
- // Since this method is called internally by SlimDX to essentially translate the results of native\r
- // API calls to their managed counterparts via the object table, we expect that a null pointer\r
- // might be passed, and that's okay. This differs from ConstructFromUserPointer.\r
- if( pointer == 0 )\r
- return nullptr;\r
- \r
- M^ tableEntry = safe_cast<M^>( SlimDX::ObjectTable::Find( static_cast<System::IntPtr>( pointer ) ) );\r
- if( tableEntry != nullptr )\r
- {\r
- if( static_cast<int>( flags & ComObjectFlags::IsAncillary ) == 0 ) \r
- pointer->Release();\r
- return tableEntry;\r
- }\r
-\r
- M^ result = gcnew M( pointer, owner );\r
- result->SetFlags( flags );\r
- return result;\r
- }\r
- \r
- template< typename M >\r
- static M^ ConstructFromUserPointer( System::IntPtr pointer ) \r
- {\r
- // This method gets called as a result of the user invoking the IntPtr overload of FromPointer\r
- // to create a SlimDX object from an externally-tracked native object. In this scenario, a\r
- // null pointer is a failure, so we throw.\r
- if( pointer == System::IntPtr::Zero )\r
- throw gcnew System::ArgumentNullException( "pointer" );\r
-\r
- M^ tableEntry = safe_cast<M^>( SlimDX::ObjectTable::Find( static_cast<System::IntPtr>( pointer ) ) );\r
- if( tableEntry != nullptr )\r
- {\r
- return tableEntry;\r
- }\r
-\r
- M^ result = gcnew M( pointer );\r
- result->SetFlags( ComObjectFlags::IsExternal );\r
- return result;\r
- }\r
- \r
- internal:\r
- property IUnknown* UnknownPointer\r
- {\r
- IUnknown* get();\r
- }\r
-\r
- property IUnknown* InternalPointer\r
- {\r
- IUnknown* get();\r
- }\r
-\r
- property ComObject^ Owner \r
- {\r
- ComObject^ get();\r
- void set( ComObject^ value );\r
- }\r
- \r
- void SetFlags( ComObjectFlags flags );\r
- void SetSource( System::Diagnostics::StackTrace^ stack );\r
- void SetCreationTime( int time );\r
- \r
- public:\r
- /// <summary>\r
- /// Gets a value that indicates whether the object has been disposed.\r
- /// </summary>\r
- property bool Disposed\r
- {\r
- bool get();\r
- }\r
- \r
- /// <summary>\r
- /// Gets an <see cref="IntPtr">IntPtr</see> to the underlying native COM interface.\r
- /// </summary>\r
- property System::IntPtr ComPointer\r
- {\r
- virtual System::IntPtr get();\r
- }\r
- \r
- /// <summary>\r
- /// Gets a <see cref="StackTrace"/> to the location where the object was created.\r
- /// </summary>\r
- property System::Diagnostics::StackTrace^ CreationSource\r
- {\r
- System::Diagnostics::StackTrace^ get();\r
- }\r
- \r
- /// <summary>\r
- /// Gets the timestamp, in milliseconds, of the object'ss creation.\r
- /// </summary>\r
- property int CreationTime\r
- {\r
- int get();\r
- }\r
- \r
- /// <summary>\r
- /// Gets or sets a value indicating whether or not the object is in the default allocation pool.\r
- /// </summary>\r
- property bool IsDefaultPool;\r
- \r
- /// <summary>\r
- /// Extra tag data stored along with the object. This member is intended for use by users of SlimDX\r
- /// and has no internal meaning to the library.\r
- /// </summary>\r
- property Object^ Tag;\r
-\r
- /// <summary>\r
- /// Releases all resources used by the <see cref="SlimDX::ComObject"/>.\r
- /// </summary>\r
- virtual ~ComObject();\r
- };\r
-}
\ No newline at end of file