OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / SlimDXc_Jun2010(VC++2008) / source / ObjectTable.h
1 /*\r
2 * Copyright (c) 2007-2010 SlimDX Group\r
3\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
10\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
13\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
20 * THE SOFTWARE.\r
21 */\r
22 #pragma once\r
23 \r
24 #include <unknwn.h>\r
25 \r
26 namespace SlimDX\r
27 {\r
28         ref class ComObject;\r
29 \r
30 #ifdef XMLDOCS\r
31         ref class Configuration;\r
32 #endif\r
33 \r
34         public ref class ObjectTableEventArgs : System::EventArgs\r
35         {\r
36         public:\r
37                 /// <summary>\r
38                 /// The <see cref="ComObject">COM object</see> that this notification refers to.\r
39                 /// </summary>\r
40                 property ComObject^ ComObject;\r
41 \r
42                 ObjectTableEventArgs( SlimDX::ComObject^ comObject )\r
43                 {\r
44                         ComObject = comObject;\r
45                 }\r
46         };\r
47 \r
48         /// <summary>\r
49         /// Maintains a list of all the <see cref="ComObject">COM objects</see> managed by SlimDX.\r
50         /// </summary>\r
51         public ref class ObjectTable sealed\r
52         {\r
53         private:\r
54                 static ObjectTable();\r
55                 ObjectTable();\r
56 \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
60 \r
61                 static void OnExit( System::Object^ sender, System::EventArgs^ e );\r
62 \r
63         internal:\r
64                 static ComObject^ Find( System::IntPtr nativeObject );\r
65                 static bool Contains( ComObject^ object );\r
66 \r
67         public:\r
68                 /// <summary>\r
69                 /// Gets a list of all the <see cref="ComObject">COM objects</see> tracked by SlimDX.\r
70                 /// </summary>\r
71                 /// <remarks>\r
72                 /// Access through this member is NOT thread-safe. Use <see cref="SyncObject" />\r
73                 /// to protect multithreaded access if necessary.\r
74                 /// </remarks>\r
75                 static property System::Collections::ObjectModel::ReadOnlyCollection<ComObject^>^ Objects\r
76                 {\r
77                         System::Collections::ObjectModel::ReadOnlyCollection<ComObject^>^ get();\r
78                 }\r
79 \r
80                 /// <summary>\r
81                 /// Occurs after a new object has been added to the object table.\r
82                 /// </summary>\r
83                 static event System::EventHandler<ObjectTableEventArgs^>^ ObjectAdded;\r
84 \r
85                 /// <summary>\r
86                 /// Occurs after an object has been removed from the object table.\r
87                 /// </summary>\r
88                 static event System::EventHandler<ObjectTableEventArgs^>^ ObjectRemoved;\r
89 \r
90                 /// <summary>\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
93                 /// </summary>\r
94                 /// <remarks>\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
98                 /// </remarks>\r
99                 static property Object^ SyncObject\r
100                 {\r
101                         Object^ get();\r
102                 }\r
103                 \r
104                 /// <summary>\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
107                 /// </summary>\r
108                 /// <param name="comObject">The object to add.</param>\r
109                 static void Add( ComObject^ comObject, ComObject^ owner );\r
110                 \r
111                 /// <summary>\r
112                 /// Removes a <see cref="SlimDX::ComObject">COM object</see> from the table.\r
113                 /// </summary>\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
117                 \r
118                 /// <summary>\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
121                 /// </summary>\r
122                 /// <returns>A string containing the leak report.</returns>\r
123                 static System::String^ ReportLeaks();\r
124         };\r
125 }