CDManager.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. //----------------------------------------------------------------------------
  24. //
  25. // Westwood Studios Pacific.
  26. //
  27. // Confidential Information
  28. // Copyright (C) 2001 - All Rights Reserved
  29. //
  30. //----------------------------------------------------------------------------
  31. //
  32. // Project: Generals
  33. //
  34. // Module: Game Engine Common
  35. //
  36. // File name: Common/CDManager.h
  37. //
  38. // Created: 11/26/01 TR
  39. //
  40. //----------------------------------------------------------------------------
  41. #pragma once
  42. #ifndef _COMMON_CDMANAGER_H_
  43. #define _COMMON_CDMANAGER_H_
  44. //----------------------------------------------------------------------------
  45. // Includes
  46. //----------------------------------------------------------------------------
  47. #include "Common/List.h"
  48. #include "Common/SubSystemInterface.h"
  49. #include "Common/AsciiString.h"
  50. //----------------------------------------------------------------------------
  51. // Forward References
  52. //----------------------------------------------------------------------------
  53. //----------------------------------------------------------------------------
  54. // Type Defines
  55. //----------------------------------------------------------------------------
  56. namespace CD
  57. {
  58. enum Disk
  59. {
  60. UNKNOWN_DISK = -3,
  61. NO_DISK = -2,
  62. ANY_DISK = -1,
  63. DISK_1 = 0,
  64. NUM_DISKS
  65. };
  66. };
  67. //===============================
  68. // CDDriveInterface
  69. //===============================
  70. /**
  71. * Interface to a CD ROM drive
  72. */
  73. //===============================
  74. class CDDriveInterface
  75. {
  76. public:
  77. virtual ~CDDriveInterface() {};
  78. virtual void refreshInfo( void ) = 0; ///< Update drive with least
  79. virtual AsciiString getDiskName( void ) = 0; ///< Returns the drive path for this drive
  80. virtual AsciiString getPath( void ) = 0; ///< Returns the drive path for this drive
  81. virtual CD::Disk getDisk( void ) = 0; ///< Returns ID of current disk in this drive
  82. };
  83. //===============================
  84. // CDDrive
  85. //===============================
  86. class CDDrive : public CDDriveInterface
  87. {
  88. friend class CDManager;
  89. public:
  90. CDDrive();
  91. virtual ~CDDrive();
  92. // CDDriveInterface operations
  93. virtual AsciiString getPath( void ); ///< Returns the drive path for this drive
  94. virtual AsciiString getDiskName( void ); ///< Returns the drive path for this drive
  95. virtual CD::Disk getDisk( void ); ///< Returns ID of current disk in this drive
  96. virtual void refreshInfo( void ); ///< Update drive with least
  97. // CDDrive operations
  98. void setPath( const Char *path ); ///< Set the drive's path
  99. protected:
  100. LListNode m_node; ///< Link list node
  101. AsciiString m_diskName; ///< disk's volume name
  102. AsciiString m_drivePath; ///< drive's device path
  103. CD::Disk m_disk; ///< ID of disk in drive
  104. };
  105. //===============================
  106. // CDManagerInterface
  107. //===============================
  108. class CDManagerInterface : public SubsystemInterface
  109. {
  110. public:
  111. virtual ~CDManagerInterface(){};
  112. virtual Int driveCount( void ) = 0; ///< Number of CD drives detected
  113. virtual CDDriveInterface* getDrive( Int index ) = 0; ///< Return the specified drive
  114. virtual CDDriveInterface* newDrive( const Char *path ) = 0; ///< add new drive of specified path
  115. virtual void refreshDrives( void ) = 0; ///< Refresh drive info
  116. virtual void destroyAllDrives( void ) = 0; ///< Like it says, destroy all drives
  117. protected:
  118. virtual CDDriveInterface* createDrive( void ) = 0;
  119. };
  120. //===============================
  121. // CDManager
  122. //===============================
  123. class CDManager : public CDManagerInterface
  124. {
  125. public:
  126. CDManager();
  127. virtual ~CDManager();
  128. // sub system operations
  129. virtual void init( void );
  130. virtual void update( void );
  131. virtual void reset( void );
  132. //
  133. virtual Int driveCount( void ); ///< Number of CD drives detected
  134. virtual CDDriveInterface* getDrive( Int index ); ///< Return the specified drive
  135. virtual CDDriveInterface* newDrive( const Char *path ); ///< add new drive of specified path
  136. virtual void refreshDrives( void ); ///< Refresh drive info
  137. virtual void destroyAllDrives( void ); ///< Like it says, destroy all drives
  138. protected:
  139. LList m_drives; ///< List of drives detected on this machine
  140. };
  141. //----------------------------------------------------------------------------
  142. // Inlining
  143. //----------------------------------------------------------------------------
  144. extern CDManagerInterface *TheCDManager;
  145. CDManagerInterface* CreateCDManager( void );
  146. #endif // _COMMON_CDMANAGER_H_