2 * Copyright (c) 2007-2010 SlimDX Group
\r
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
5 * of this software and associated documentation files (the "Software"), to deal
\r
6 * in the Software without restriction, including without limitation the rights
\r
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
8 * copies of the Software, and to permit persons to whom the Software is
\r
9 * furnished to do so, subject to the following conditions:
\r
11 * The above copyright notice and this permission notice shall be included in
\r
12 * all copies or substantial portions of the Software.
\r
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
28 ref class ComObject;
\r
31 ref class Configuration;
\r
34 public ref class ObjectTableEventArgs : System::EventArgs
\r
38 /// The <see cref="ComObject">COM object</see> that this notification refers to.
\r
40 property ComObject^ ComObject;
\r
42 ObjectTableEventArgs( SlimDX::ComObject^ comObject )
\r
44 ComObject = comObject;
\r
49 /// Maintains a list of all the <see cref="ComObject">COM objects</see> managed by SlimDX.
\r
51 public ref class ObjectTable sealed
\r
54 static ObjectTable();
\r
57 static System::Collections::Generic::Dictionary<System::IntPtr, ComObject^>^ m_Table;
\r
58 static System::Collections::Generic::Dictionary<System::IntPtr, System::Collections::Generic::List<ComObject^>^>^ m_Ancillary;
\r
59 static Object^ m_SyncObject;
\r
61 static void OnExit( System::Object^ sender, System::EventArgs^ e );
\r
64 static ComObject^ Find( System::IntPtr nativeObject );
\r
65 static bool Contains( ComObject^ object );
\r
69 /// Gets a list of all the <see cref="ComObject">COM objects</see> tracked by SlimDX.
\r
72 /// Access through this member is NOT thread-safe. Use <see cref="SyncObject" />
\r
73 /// to protect multithreaded access if necessary.
\r
75 static property System::Collections::ObjectModel::ReadOnlyCollection<ComObject^>^ Objects
\r
77 System::Collections::ObjectModel::ReadOnlyCollection<ComObject^>^ get();
\r
81 /// Occurs after a new object has been added to the object table.
\r
83 static event System::EventHandler<ObjectTableEventArgs^>^ ObjectAdded;
\r
86 /// Occurs after an object has been removed from the object table.
\r
88 static event System::EventHandler<ObjectTableEventArgs^>^ ObjectRemoved;
\r
91 /// Gets the synchronization object used by the ObjectTable. This object can be used to safely
\r
92 /// access the internal object list.
\r
95 /// This member should only be used if it is necesssary to access the <see cref="Objects" /> property
\r
96 /// in a thread-safe manner, and should not be used as anything other than a parameter for
\r
97 /// functions in <see cref="System::Threading::Monitor" />.
\r
99 static property Object^ SyncObject
\r
105 /// Adds a <see cref="ComObject">COM object</see> to the table. This will set the object's <see cref="SlimDX::ComObject"/><c>::CreationSource</c> property if
\r
106 /// <see cref="SlimDX::Configuration"/><c>::EnableObjectTracking</c>object tracking is on.
\r
108 /// <param name="comObject">The object to add.</param>
\r
109 static void Add( ComObject^ comObject, ComObject^ owner );
\r
112 /// Removes a <see cref="SlimDX::ComObject">COM object</see> from the table.
\r
114 /// <param name="comObject">The object to remove.</param>
\r
115 /// <returns><c>true</c> if the object was in the table and was removed; otherwise, <c>false</c>.</returns>
\r
116 static bool Remove( ComObject^ comObject );
\r
119 /// Generates a report of all outstanding COM objects (objects that have not been disposed)
\r
120 /// tracked by SlimDX. The report includes the object's type and a stack trace to its creation point.
\r
122 /// <returns>A string containing the leak report.</returns>
\r
123 static System::String^ ReportLeaks();
\r