ISourceControl.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  1. /*******************************************************************************
  2. The content of this file includes portions of the AUDIOKINETIC Wwise Technology
  3. released in source code form as part of the SDK installer package.
  4. Commercial License Usage
  5. Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
  6. may use this file in accordance with the end user license agreement provided
  7. with the software or, alternatively, in accordance with the terms contained in a
  8. written agreement between you and Audiokinetic Inc.
  9. Apache License Usage
  10. Alternatively, this file may be used under the Apache License, Version 2.0 (the
  11. "Apache License"); you may not use this file except in compliance with the
  12. Apache License. You may obtain a copy of the Apache License at
  13. http://www.apache.org/licenses/LICENSE-2.0.
  14. Unless required by applicable law or agreed to in writing, software distributed
  15. under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
  16. OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
  17. the specific language governing permissions and limitations under the License.
  18. Copyright (c) 2023 Audiokinetic Inc.
  19. *******************************************************************************/
  20. /// \file
  21. /// Wwise source control plug-in interface, used to implement the source control plug-in.
  22. #ifndef _AK_WWISE_ISOURCECONTROL_H
  23. #define _AK_WWISE_ISOURCECONTROL_H
  24. // Include the header file that defines the BSTR type.
  25. #ifdef AK_WIN
  26. #include <wtypes.h>
  27. #endif
  28. #include "ISourceControlUtilities.h"
  29. #include "SourceControlContainers.h"
  30. // Audiokinetic namespace
  31. namespace AK
  32. {
  33. // Audiokinetic Wwise namespace
  34. namespace Wwise
  35. {
  36. /// This class contains static constants that can be useful to the plug-in.
  37. class SourceControlConstant
  38. {
  39. public:
  40. /// Maximum length that a work unit name can be
  41. static const unsigned int s_uiMaxWorkUnitName = 128;
  42. /// Invalid operation ID (MUST NOT BE USED as an operation ID in OperationListItem)
  43. static const DWORD s_dwInvalidOperationID = (DWORD)-1;
  44. };
  45. /// Wwise source control plug-in interface. This is the interface that the plug-in must implement. It contains
  46. /// all the necessary functions to perform source control operations and manage the Wwise source control UI.
  47. /// \akwarning
  48. /// The functions in this interface are not thread-safe, unless stated otherwise.
  49. /// \endakwarning
  50. /// \sa
  51. /// - \ref source_control_dll_creation_object_information
  52. class ISourceControl
  53. {
  54. public:
  55. /// \name Enumeration types
  56. //@{
  57. /// Operation result. Some interface functions need to return the result of the operation. This is used
  58. /// by Wwise to manage various errors.
  59. enum OperationResult
  60. {
  61. OperationResult_Succeed = 0, ///< The operation succeeded
  62. OperationResult_Failed, ///< The operation failed
  63. OperationResult_TimedOut, ///< The operation timed out
  64. OperationResult_Cancelled, ///< The operation was cancelled
  65. OperationResult_NotImplemented ///< The operation is not implemented
  66. };
  67. /// Menu type. The operation list may vary depending on the location where a menu containing operations
  68. /// needs to be displayed.
  69. enum OperationMenuType
  70. {
  71. OperationMenuType_WorkUnits = 0,///< The menu is displayed in the File Manager's 'Work Units' tab
  72. OperationMenuType_Sources, ///< The menu is displayed in the File Manager's 'Sources' tab
  73. OperationMenuType_Generated, ///< The menu is displayed in the File Manager's 'Generated' tab
  74. OperationMenuType_Explorer ///< The menu is displayed in the Project Explorer
  75. };
  76. /// Pre/PostCreateOrModify Operation flags. These flags represent the operation(s) performed on files.
  77. enum CreateOrModifyOperation
  78. {
  79. CreateOrModifyOperation_Create = 1 << 0, ///< Files will be created during the operation
  80. CreateOrModifyOperation_Modify = 1 << 1, ///< Files will be modified during the operation
  81. };
  82. /// The operation's effect on the file(s) involved.
  83. enum OperationEffect
  84. {
  85. OperationEffect_LocalContentModification = 1 << 0, ///< The operation will modify the local content of the file
  86. OperationEffect_ServerContentModification = 1 << 1, ///< The operation will modify the remote content (on the server) of the file
  87. };
  88. //@}
  89. /// The base interface for operations that return information to Wwise
  90. class IOperationResult
  91. {
  92. public:
  93. /// Returns OperationResult_Succeed or OperationResult_Failed
  94. virtual OperationResult GetOperationResult() = 0;
  95. /// Implementations should call "delete this;".
  96. virtual void Destroy() = 0;
  97. };
  98. /// The result returned by DoOperation for a Move, Rename or Delete operation.
  99. /// An instance of this class is allocated by the plugin and freed by Wwise.
  100. /// The operation ID must be identified by :
  101. /// PluginInfo::m_dwMoveCommandID, PluginInfo::m_dwMoveNoUICommandID,
  102. /// PluginInfo::m_dwRenameCommandID or PluginInfo::m_dwRenameNoUICommandID
  103. /// PluginInfo::m_dwDeleteCommandID or PluginInfo::m_dwDeleteNoUICommandID
  104. class IFileOperationResult : public IOperationResult
  105. {
  106. public:
  107. /// Return the move source and destination for the file at index in_uiIndex
  108. virtual void GetMovedFile(
  109. unsigned int in_uiIndex, ///< in: The index of the moved file. Must be >= 0 and < GetFileCount()
  110. LPWSTR out_szFrom, ///< out: String buffer to receive the source path
  111. LPWSTR out_szTo, ///< out: String buffer to receive the destination path
  112. unsigned int in_uiArraySize ///< in: Size of the buffers (out_szFrom and out_szTo)
  113. ) = 0;
  114. /// Return the successful file at index in_uiIndex
  115. virtual void GetFile(
  116. unsigned int in_uiIndex, ///< in: The index of the file. Must be >= 0 and < GetFileCount()
  117. LPWSTR out_szPath, ///< out: String buffer to receive the source path
  118. unsigned int in_uiArraySize ///< in: Size of the buffers (out_szFrom and out_szTo)
  119. ) = 0;
  120. /// Returns how many files were moved during the operation
  121. virtual unsigned int GetFileCount() = 0;
  122. };
  123. /// 'Filename to Status' map item. This is the type used in the AK::Wwise::ISourceControl::FilenameToStatusMap
  124. /// SourceControlContainers::IAkMap template parameter structure.
  125. struct FilenameToStatusMapItem
  126. {
  127. BSTR m_bstrStatus; ///< Text displayed in the File Manager's 'Status' column
  128. BSTR m_bstrOwner; ///< Text displayed in the File Manager's 'Owners' column
  129. };
  130. /// Operation list item. This is the type used in the AK::Wwise::ISourceControl::OperationList SourceControlContainers::IAkList template class.
  131. struct OperationListItem
  132. {
  133. DWORD m_dwOperationID; ///< The operation ID
  134. bool m_bEnabled; ///< True: the operation is enabled in the menu, False: the operation is disabled (grayed out) in the menu
  135. };
  136. /// FilenameToIconMap item. This is the type used to display the file status icon and tool tip text
  137. /// in the Project Explorer.
  138. struct FilenameToIconMapItem
  139. {
  140. HICON m_hIcon; ///< A handle to an icon that will be displayed in the Project Explorer
  141. BSTR m_bstrToolTip; ///< The tool tip text that will be displayed when the user mouses over the icon
  142. };
  143. /// \name List types
  144. //@{
  145. /// String List. When Wwise needs to pass a file name list, it gives this container to the plug-in.
  146. /// \sa
  147. /// - AK::Wwise::SourceControlContainers::IAkList
  148. typedef SourceControlContainers::IAkList<LPCWSTR, LPCWSTR> StringList;
  149. /// Boolean List. When Wwise needs to pass a boolean list, it gives this container to the plug-in.
  150. /// \sa
  151. /// - AK::Wwise::SourceControlContainers::IAkList
  152. typedef SourceControlContainers::IAkList<bool> BooleanList;
  153. /// Plug-in ID list. When Wwise needs to have the list of plug-ins that a DLL contains, it requests
  154. /// the list of plug-in IDs using a function exported by the DLL.
  155. typedef SourceControlContainers::IAkList<GUID> PluginIDList;
  156. /// When Wwise needs to have the list of operations that are available in a certain context, it requests
  157. /// the list of operations using this list type. The contexts are determined by the AK::Wwise::ISourceControl::OperationMenuType
  158. /// enumeration type.
  159. /// \sa
  160. /// - AK::Wwise::ISourceControl::OperationListItem
  161. /// - AK::Wwise::SourceControlContainers::IAkList
  162. typedef SourceControlContainers::IAkList<OperationListItem> OperationList;
  163. //@}
  164. /// \name Map types
  165. //@{
  166. /// The AK:Wwise::ISourceControl interface offers a way to display custom icons in the Project Explorer. This map
  167. /// type must be filled in by the plug-in when Wwise gives it a file name list. CStringW objects are used as keys, and are associated
  168. /// to FilenameToIconMapItem objects. The HICON m_hIcon member will be NULL when there is no icon associated with the file.
  169. /// \sa
  170. /// - AK::Wwise::SourceControlContainers::IAkMap
  171. typedef SourceControlContainers::IAkMap<LPCWSTR, LPCWSTR, FilenameToIconMapItem, const FilenameToIconMapItem&> FilenameToIconMap;
  172. /// When the File Manager needs to fill in the 'Status' and 'Owners' columns of work units or source lists,
  173. /// the plug-in needs to fill in this map with the corresponding text. File names are used as keys, and are associated
  174. /// to the text to be displayed in the 'Status' and 'Owners' columns.
  175. /// \sa
  176. /// - AK::Wwise::ISourceControl::FilenameToStatusMapItem
  177. /// - AK::Wwise::SourceControlContainers::IAkMap
  178. typedef SourceControlContainers::IAkMap<LPCWSTR, LPCWSTR, FilenameToStatusMapItem, const FilenameToStatusMapItem&> FilenameToStatusMap;
  179. //@}
  180. /// Plug-in information structure. This structure gives a simple overview of the plug-in's capabilities.
  181. class PluginInfo
  182. {
  183. public:
  184. BSTR m_bstrName; ///< The name of the plug-in displayed in the Project Settings plug-in list
  185. unsigned int m_uiVersion; ///< The current version of the plug-in
  186. bool m_bShowConfigDlgAvailable; ///< Used to enable/disable the 'Config...' button in the Project Settings
  187. DWORD m_dwUpdateCommandID; ///< Indicates the command ID for the Update command, s_dwInvalidOperationID (-1) if not supported
  188. DWORD m_dwCommitCommandID; ///< Indicates the command ID for the Commit/Submit/Checkin command, s_dwInvalidOperationID (-1) if not supported
  189. DWORD m_dwRenameCommandID; ///< Indicates the command ID for the Rename command, s_dwInvalidOperationID (-1) if not supported
  190. DWORD m_dwMoveCommandID; ///< Indicates the command ID for the Move command, s_dwInvalidOperationID (-1) if not supported
  191. DWORD m_dwAddCommandID; ///< Indicates the command ID for the Add command, s_dwInvalidOperationID (-1) if not supported
  192. DWORD m_dwDeleteCommandID; ///< Indicates the command ID for the Delete command, s_dwInvalidOperationID (-1) if not supported
  193. DWORD m_dwRevertCommandID; ///< Indicates the command ID for the Revert command, s_dwInvalidOperationID (-1) if not supported
  194. DWORD m_dwDiffCommandID; ///< Indicates the command ID for the Diff command, s_dwInvalidOperationID (-1) if not supported
  195. DWORD m_dwCheckOutCommandID; ///< Indicates the command ID for the CheckOut command, s_dwInvalidOperationID (-1) if not supported
  196. DWORD m_dwRenameNoUICommandID; ///< Indicates the command ID for the Rename command, showing no User Interface, s_dwInvalidOperationID (-1) if not supported
  197. DWORD m_dwMoveNoUICommandID; ///< Indicates the command ID for the Move command, showing no User Interface, s_dwInvalidOperationID (-1) if not supported
  198. DWORD m_dwAddNoUICommandID; ///< Indicates the command ID for the Add command, showing no User Interface, s_dwInvalidOperationID (-1) if not supported
  199. DWORD m_dwDeleteNoUICommandID; ///< Indicates the command ID for the Delete command, showing no User Interface, s_dwInvalidOperationID (-1) if not supported
  200. DWORD m_dwRevertNoUICommandID; ///< Indicates the command ID for the Revert command, showing no User Interface, s_dwInvalidOperationID (-1) if not supported
  201. DWORD m_dwCheckOutNoUICommandID;///< Indicates the command ID for the CheckOut command, showing no User Interface, s_dwInvalidOperationID (-1) if not supported
  202. bool m_bStatusIconAvailable; ///< Indicates that the plug-in supports Project Explorer custom icons
  203. };
  204. /// This function is called when the plug-in is initialized after its creation.
  205. virtual void Init(
  206. AK::Wwise::ISourceControlUtilities* in_pUtilities, ///< A pointer to the utilities class. The interface is not
  207. ///< destroyed while an instance of the plug-in exists.
  208. bool in_bAutoAccept ///< Used when running in command line mode, where user should not be prompted to confirm source control transactions.
  209. ) = 0;
  210. /// This function is called when the plug-in is terminated before its destruction.
  211. virtual void Term() = 0;
  212. /// This function destroys the plug-in. The implementation is generally '{ delete this; }'.
  213. virtual void Destroy() = 0;
  214. /// This function is called when the user clicks the 'Config...' button in the Project Settings.
  215. /// \return True if the user accepts the configuration, False otherwise
  216. /// \sa
  217. /// - AK::Wwise::ISourceControl::PluginInfo::m_bShowConfigDlgAvailable
  218. virtual bool ShowConfigDlg() = 0;
  219. /// Gets the operation list to be displayed in a menu.
  220. /// \return The result of the operation
  221. virtual AK::Wwise::ISourceControl::OperationResult GetOperationList(
  222. OperationMenuType in_menuType, ///< The type of menu where the operation list will be displayed
  223. const StringList& in_rFilenameList, ///< The file name list for which Wwise needs to get the operation list
  224. OperationList& out_rOperationList ///< The returned operation list available in this context
  225. ) = 0;
  226. /// Gets the operation name to display in user interface
  227. // \return A mask of all the applicable OperationEffect enum values
  228. virtual LPCWSTR GetOperationName(
  229. DWORD in_dwOperationID ///< The ID of the operation, as specified in OperationListItem
  230. ) = 0;
  231. /// Gets the operation effect on the file(s) involved in the operation.
  232. // \return A mask of all the applicable OperationEffect enum values
  233. virtual DWORD GetOperationEffect(
  234. DWORD in_dwOperationID ///< The ID of the operation, as specified in OperationListItem
  235. ) = 0;
  236. /// Gets the text to be displayed in the 'Status' and 'Owners' columns of the File Manager.
  237. /// \return The result of the operation
  238. virtual AK::Wwise::ISourceControl::OperationResult GetFileStatus(
  239. const StringList& in_rFilenameList, ///< A list of the file names for which Wwise needs to get the status
  240. FilenameToStatusMap& out_rFileStatusMap,///< The returned 'Filename To Status' map
  241. DWORD in_dwTimeoutMs = INFINITE ///< The maximum timeout in millisecond for the request to be cancelled, pass INFINITE for no timeout
  242. ) = 0;
  243. /// In a similar way to AK::Wwise::ISourceControl::GetFileStatus(), this function gets the icons to be displayed in the
  244. /// Project Explorer.
  245. /// \return The result of the operation
  246. virtual AK::Wwise::ISourceControl::OperationResult GetFileStatusIcons(
  247. const StringList& in_rFilenameList, ///< A list of the file names for which Wwise needs to get the icons
  248. FilenameToIconMap& out_rFileIconsMap, ///< The returned 'Filename To Icons' map
  249. DWORD in_dwTimeoutMs = INFINITE ///< The maximum timeout in millisecond for the request to be cancelled, pass INFINITE for no timeout
  250. ) = 0;
  251. /// Combines GetFileStatus() and GetFileStatusIcons() to get the source control file icons and the text to be displayed in the 'Status' and 'Owners'
  252. /// columns of the File Manager.
  253. /// \return The result of the operation
  254. virtual AK::Wwise::ISourceControl::OperationResult GetFileStatusAndIcons(
  255. const StringList& in_rFilenameList, ///< A list of the file names for which Wwise needs to get the icons
  256. FilenameToStatusMap& out_rFileStatusMap,///< The returned 'Filename To Status' map
  257. FilenameToIconMap& out_rFileIconsMap, ///< The returned 'Filename To Icons' map
  258. DWORD in_dwTimeoutMs = INFINITE ///< The maximum timeout in millisecond for the request to be cancelled, pass INFINITE for no timeout
  259. ) = 0;
  260. /// Gets the files that should be displayed in the File Manager file list, but that are not on the local disk.
  261. /// Deleted files that need to be submitted to the server are an example of implementation.
  262. /// \return The result of the operation
  263. virtual AK::Wwise::ISourceControl::OperationResult GetMissingFilesInDirectories(
  264. const StringList& in_rDirectoryList, ///< A list of directories in which Wwise needs to get missing files
  265. StringList& out_rFilenameList ///< The returned missing files
  266. ) = 0;
  267. /// Performs an operation on files. This function is called when the user clicks on a source control operation in a menu.
  268. /// The returned IOperationResult must be allocated on the heap and freed by the caller using IOperationResult::Destroy.
  269. /// For Rename and Move operations in No-User-Interface mode, in_pTargetFilenameList contains the list of target names are known in advance.
  270. [[nodiscard]] virtual IOperationResult* DoOperation(
  271. DWORD in_dwOperationID, ///< The ID of the operation that the user selected from the menu
  272. const StringList& in_rFilenameList, ///< A list of the names of the files that the user selected in the File Manager or in the Project Explorer.
  273. const StringList* in_pTargetFilenameList = NULL ///< Optional: A list of the names of the destination files. Pass NULL when not specified.
  274. ) = 0;
  275. /// This method is called when the user adds files to the project (Work Units or Sources), saves the project,
  276. /// or triggers any call to a Wwise operation that could alter source control files. It is called before Wwise performs
  277. /// the operation and is always followed by a call to PostCreateOrModify.
  278. /// \return The result of the operation
  279. virtual AK::Wwise::ISourceControl::OperationResult PreCreateOrModify(
  280. const StringList& in_rFilenameList, ///< A list of the names of the files that are to be added (some files may already exist)
  281. CreateOrModifyOperation in_eOperation, ///< The operation(s) that will be performed on these files
  282. bool& out_rContinue ///< A returned flag that indicates if Wwise is continuing the current operation
  283. ) = 0;
  284. /// This method is called when the user adds files to the project (Work Units or Sources), saves the project,
  285. /// or triggers any call to a Wwise operation that could alter source control files. It is called after Wwise performs
  286. /// the operation and is always preceded by a call to PreCreateOrModify.
  287. /// \return The result of the operation
  288. virtual AK::Wwise::ISourceControl::OperationResult PostCreateOrModify(
  289. const StringList& in_rFilenameList, ///< A list of the names of the files that are to be added (Some files may already exist)
  290. CreateOrModifyOperation in_eOperation, ///< The operation(s) that will be performed on these files
  291. bool& out_rContinue ///< A returned flag that indicates if Wwise is continuing the current operation
  292. ) = 0;
  293. /// This methods returns the list files that can be committed
  294. /// \return The result of the operation
  295. virtual AK::Wwise::ISourceControl::OperationResult GetFilesForOperation(
  296. DWORD in_dwOperationID, ///< The operation to verify on each file
  297. const StringList& in_rFilenameList, ///< The files to query
  298. StringList& out_rFilenameList, ///< Out: The files that can have the operation done
  299. FilenameToStatusMap& out_rFileStatusMap ///< Out: The file status of all files
  300. ) = 0;
  301. /// This methods returns whether the specified operation can be applied to each file.
  302. /// \return The result of the operation
  303. virtual AK::Wwise::ISourceControl::OperationResult CheckFilesForOperation(
  304. DWORD in_dwOperationID, ///< The operation to verify on each file
  305. const StringList& in_rFilenameList, ///< The files to query
  306. BooleanList& out_rFileStatusList ///< Out: For each file in in_rFilenameList, whether in_dwOperationID can be applied.
  307. ) = 0;
  308. /// This methods returns a boolean for each file, indicating whether the file is under source control.
  309. /// \return The result of the operation
  310. virtual AK::Wwise::ISourceControl::OperationResult FilesUnderSourceControl(
  311. const StringList& in_rFilenameList, ///< The files to query
  312. BooleanList& out_rFileStatusList ///< Out: List of source control file status.
  313. ) = 0;
  314. //@}
  315. /// \name Exported functions prototypes
  316. //@{
  317. /// Gets the plug-in ID list contained by the DLL file.
  318. typedef void (__stdcall* GetSourceControlIDListFuncPtr)(
  319. PluginIDList& out_rPluginIDList ///< The List of plug-in IDs
  320. );
  321. /// Gets the AK::Wwise::ISourceControl::PluginInfo class associated with a given plug-in ID.
  322. typedef void (__stdcall* GetSourceControlPluginInfoFuncPtr)(
  323. const GUID& in_rguidPluginID, ///< The ID of the plug-in
  324. PluginInfo& out_rPluginInfo ///< The returned plug-in info
  325. );
  326. /// Gets an instance of a plug-in.
  327. /// \return A pointer to an AK::Wwise::ISourceControl instance
  328. typedef ISourceControl* (__stdcall* GetSourceControlInstanceFuncPtr)(
  329. const GUID& in_guidPluginID ///< The requested plug-in ID
  330. );
  331. };
  332. }
  333. }
  334. #endif // _AK_WWISE_ISOURCECONTROL_H