Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

260 lines
9.7 KiB

  1. // DMLoader.d : Additional autodoc stuff
  2. //
  3. // @doc EXTERNAL
  4. /*
  5. @interface IDirectMusicLoader |
  6. <i IDirectMusicLoader> manages loading objects by reference.
  7. If an object references another object, it needs
  8. to connect to (and possibly load) the referenced object at
  9. load time. <i IDirectMusicLoader> provides a standard
  10. interface for accessing objects via references embedded within
  11. objects.
  12. <i IDirectMusicLoader> accomplishes this by providing its
  13. own implementation of <i IStream> for loading. This delivers
  14. a clean mechanism for accessing a central loader, since all DirectMusic
  15. objects implement <i IPersistStream>.
  16. When an object is loading
  17. via an <i IStream> and it comes across a reference to another
  18. object, it calls <om IStream::QueryInterface> for the
  19. <i IDirectMusicLoader> interface. It then calls the
  20. <om IDirectMusicLoader::GetObject> method to retrieve the
  21. desired object. It tells <i IDirectMusicLoader> everything it
  22. can about the desired object with the <t DMOBJECTDESC> structure,
  23. which includes reference by object name,
  24. GUID, file name, or URL. <om IDirectMusicLoader::GetObject>
  25. returns a pointer to the requested object.
  26. In addition to <om IDirectMusicLoader::GetObject>, <i IDirectMusicLoader>
  27. provides a set of convenience functions that help manage
  28. the set of objects that it can access. The
  29. <om IDirectMusicLoader::SetSearchDirectory> and
  30. <om IDirectMusicLoader::EnumObjects> commands provide
  31. a way to specify a specific file path or URL for loading
  32. files from and a mechanism for listing them.
  33. The <om IDirectMusicLoader::CacheObject>,
  34. <om IDirectMusicLoader::ReleaseObject>,
  35. <om IDirectMusicLoader::ClearCache>, and
  36. <om IDirectMusicLoader::EnableCache> commands manage
  37. internal caching of loaded objects.
  38. If you use <i IDirectMusicLoader> to manage loading by reference
  39. of embedded links, you must also use it to load the initial file, since
  40. it creates its own <i IStream> which can be
  41. <om IStream::QueryInterface>'d for <i IDirectMusicLoader>. Loading
  42. files with <om IDirectMusicLoader::GetObject> is more convenient
  43. anyway, since it does all the file and stream creation and
  44. management for you.
  45. There are circumstances where an application may need
  46. to manage file io itself, for example
  47. because all objects are stored in special compressed resource file.
  48. The application can create
  49. its own loader by creating an
  50. object with both <i IStream> and <i IDirectMusicLoader>
  51. interfaces. The only method
  52. that it is required to support
  53. is <om IDirectMusicLoader::GetObject>.
  54. @base public | IUnknown
  55. @meth HRESULT | GetObject | Finds the requested object.
  56. @meth HRESULT | SetSearchDirectory | Sets a search path for finding object files.
  57. @meth HRESULT | ScanDirectory | Searches a directory on disk for all files of a requested
  58. class type and file extension.
  59. @meth HRESULT | EnumObjects | Enumerate through all instances of a particular type of object.
  60. @meth HRESULT | CacheObject | Keep an object referenced
  61. internally so it is readily available for future access.
  62. @meth HRESULT | ReleaseObject | Release any internal reference to the object.
  63. @meth HRESULT | ClearCache | Clear all references to a particular type of object.
  64. @meth HRESULT | EnableCache | Enable automatic internal referencing of a particular type of object.
  65. @xref <t DMOBJECTDESC>, <i IDirectMusicObject>
  66. */
  67. /*
  68. @struct DMOBJECTDESC | The <t DMOBJECTDESC> structure is used to
  69. communicate everything that could possibly be used to describe a
  70. DirectMusic object.
  71. In particular, <t DMOBJECTDESC> is passed to
  72. <om IDirectMusicLoader::GetObject> to describe the object that the loader should
  73. retrieve from storage.
  74. @comm
  75. Although <t DMOBJECTDESC> has many data fields, the
  76. fields that matter for finding and returning an object are <e DMOBJECTDESC.wzName>,
  77. <e DMOBJECTDESC.idGuid>, and <e DMOBJECTDESC.szPath>. So, at minimum, one of these
  78. must be filled with valid data for <om IDirectMusicLoader::GetObject>
  79. to work at all.
  80. All other fields represent data
  81. about the object that can be accessed via calls to <om IDirectMusicLoader::EnumObjects>
  82. or <om IDirectMusicObject::GetDescriptor>.
  83. Note that Name and Category strings use sixteen bit characters
  84. in the WCHAR format, not 8 bit ANSI chars. Be sure to convert as
  85. appropriate. For example, if you are using multibyte characters,
  86. convert with the <f WideCharToMultiByte> and <f MultiByteToWideChar>
  87. system calls
  88. <e DMOBJECTDESC.dwValidData> stores a set of bits which are used
  89. to identify which data fields are
  90. valid. For example, if the name of the object is known, it is stored
  91. in <e DMOBJECTDESC.wzName> and <e DMOBJECTDESC.dwValidData>
  92. has its DMOBJ_NAME bit set.
  93. @flag DMOBJ_GUID | Object GUID is valid.
  94. @flag DMOBJ_CLASS | Class GUID and type are valid.
  95. @flag DMOBJ_NAME | Name is valid.
  96. @flag DMOBJ_CATEGORY | Category is valid.
  97. @flag DMOBJ_PATH | File path is valid.
  98. @flag DMOBJ_FULLPATH | Path is full path.
  99. @flag DMOBJ_URL | Path is URL.
  100. @flag DMOBJ_VERSION | Version is valid.
  101. @flag DMOBJ_DATE | Date is valid.
  102. @flag DMOBJ_LOADED | Object is currently loaded in memory.
  103. @xref <i IDirectMusicObject>, <i IDirectMusicLoader>
  104. */
  105. typedef struct _DMOBJECTDESC
  106. {
  107. DWORD dwValidData; // @field Flags indicating which fields below are valid.
  108. GUID idGuid; // @field Unique ID for this object.
  109. GUID idClass; // @field GUID for the class of object.
  110. DWORD dwType; // @field Subtype of class.
  111. FILETIME ftDate; // @field Last edited date of object.
  112. DMVERSION vVersion; // @field Version.
  113. WCHAR wzName[MAX_DMNAME]; // @field Name of object, in wide chars.
  114. WCHAR wzCategory[MAX_DMCATEGORY]; // @field Category for object, also wide chars.
  115. CHAR szPath[MAX_DMPATH]; // @field File path. If DMOBJ_FULLPATH is set, this is the full path, otherwise just the file name.
  116. } DMOBJECTDESC;
  117. /*
  118. @interface IDirectMusicObject |
  119. All DirectMusic objects support the <i IDirectMusicObject>
  120. interface in order to
  121. work with the DirectMusic loader. In addition to
  122. providing a standard generic interface that the loader can
  123. communicate with, this provides a generic mechanism that
  124. allows an application to query an object for information
  125. about it, including Name, Guid, file path, version info,
  126. and more.
  127. If you are writing a DirectMusic compatible object, you
  128. must support <i IDirectMusicObject>, along with <i IPersistStream>,
  129. which is used in
  130. tandem with <i IDirectMusicObject> to load the object.
  131. @base public | IUnknown
  132. @meth HRESULT | GetDescriptor | Get the object's internal description, in <t DMOBJECTDESC> format.
  133. @meth HRESULT | SetDescriptor | Get the object's internal description, in <t DMOBJECTDESC> format.
  134. @meth HRESULT | ParseDescriptor | Parse into the supplied stream and find information about the file to store in <t DMOBJECTDESC> format.
  135. @xref <t DMOBJECTDESC>, <i IDirectMusicLoader>
  136. */
  137. /*
  138. @method:(EXTERNAL) HRESULT | IDirectMusicObject | GetDescriptor |
  139. Get the object's internal description.
  140. This method takes a <t DMOBJECTDESC> structure and fills in everything
  141. it knows about itself. Depending on the implementation of the object and
  142. how it was loaded from a file, some or all of the standard
  143. parameters will be filled by <om IDirectMusicObject::GetDescriptor>.
  144. Be sure to check the flags in <e DMOBJECTDESC.dwValidData> to understand
  145. which fields are valid.
  146. @rdesc Returns one of the following
  147. @flag S_OK | Success
  148. @flag E_FAIL | Should never happen.
  149. @ex The following example uses <om IDirectMusicObject::GetDescriptor> to
  150. read the name from a DirectMusic style: |
  151. IDirectMusicStyle *pStyle; // Style that was previously loaded.
  152. if (pStyle)
  153. {
  154. IDirectMusicObject *pIObject;
  155. DMOBJECTDESC Desc; // Descriptor.
  156. if (SUCCEEDED(QueryInterface(IID_IDirectMusicObject,(void **) &pIObject);
  157. {
  158. if (SUCCEEDED(pIObject->GetDescriptor(&Desc))
  159. {
  160. if (Desc.dwValidData & DMOBJ_NAME)
  161. {
  162. TRACE("Style name is %S\n",Desc.wzName);
  163. }
  164. }
  165. pIObject->Release();
  166. }
  167. }
  168. @xref <i IDirectMusicObject>, <om IDirectMusicObject::SetDescriptor>,
  169. <om IDirectMusicObject::ParseDescriptor>,<t DMOBJECTDESC>, <i IDirectMusicLoader>
  170. */
  171. HRESULT CDMStyle::GetDescriptor(
  172. LPDMOBJECTDESC pDesc) // @parm Descriptor to be filled with data about object.
  173. {
  174. return S_OK;
  175. }
  176. /*
  177. @method:(EXTERNAL) HRESULT | IDirectMusicObject | SetDescriptor |
  178. Set some or all fields of the object's internal description.
  179. This method takes a <t DMOBJECTDESC> structure and copies the
  180. fields that are enabled with a DMOBJ flag in
  181. <e DMOBJECTDESC.dwValidData>.
  182. This is primarily used by the loader when creating an object.
  183. @rdesc Returns one of the following
  184. @flag S_OK | Success
  185. @flag E_FAIL | Unable to set a parameter
  186. @xref <i IDirectMusicObject>, <om IDirectMusicObject::GetDescriptor>,
  187. <om IDirectMusicObject::ParseDescriptor>,<t DMOBJECTDESC>, <i IDirectMusicLoader>
  188. */
  189. HRESULT CDMStyle::SetDescriptor(
  190. LPDMOBJECTDESC pDesc) // @parm Descriptor with data about object.
  191. {
  192. return S_OK;
  193. }
  194. /*
  195. @method:(EXTERNAL) HRESULT | IDirectMusicObject | ParseDescriptor |
  196. Given a file stream, <om IDirectMusicObject::ParseDescriptor> scans the
  197. file for data which it can store in the <t DMOBJECTDESC> structure.
  198. These include object name, GUID, version info, etc. All fields that
  199. are supplied are marked with the appropriate bit flags in
  200. <e DMOBJECTDESC.dwValidData>.
  201. This is primarily used by the loader when scanning a directory for
  202. objects, and should not be of use to an application. However, if you
  203. implement an object type in DirectMusic, you should support this.
  204. @rdesc Returns one of the following
  205. @flag S_OK | Success
  206. @flag E_FAIL | Not a valid file
  207. @xref <i IDirectMusicObject>, <om IDirectMusicObject::SetDescriptor>,
  208. <om IDirectMusicObject::GetDescriptor>,<t DMOBJECTDESC>, <i IDirectMusicLoader>
  209. */
  210. HRESULT CDMStyle::ParseDescriptor(
  211. LPSTREAM pStream, // @parm Stream source for file.
  212. LPDMOBJECTDESC pDesc) // @parm Descriptor to fill with data about file.
  213. {
  214. return S_OK;
  215. }