Leaked source code of windows server 2003
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.

151 lines
4.3 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved
  3. Module Name:
  4. RmsDrive.h
  5. Abstract:
  6. Declaration of the CRmsDrive class
  7. Author:
  8. Brian Dodd [brian] 15-Nov-1996
  9. Revision History:
  10. --*/
  11. #ifndef _RMSDRIVE_
  12. #define _RMSDRIVE_
  13. #include "resource.h" // resource symbols
  14. #include "RmsDvice.h" // CRmsDevice
  15. /*++
  16. Class Name:
  17. CRmsDrive
  18. Class Description:
  19. A CRmsDrive represents a specific data transfer device: a disk, tape,
  20. or optical drive.
  21. Each drive is member of at least one DriveClass. The DriveClass contains
  22. additional properties that are associated with a Drive (See CRmsDriveClass).
  23. --*/
  24. class CRmsDrive :
  25. public CComDualImpl<IRmsDrive, &IID_IRmsDrive, &LIBID_RMSLib>,
  26. public CRmsDevice, // inherits CRmsChangerElement
  27. public CWsbObject, // inherits CComObjectRoot
  28. public CComCoClass<CRmsDrive,&CLSID_CRmsDrive>
  29. {
  30. public:
  31. CRmsDrive() {}
  32. BEGIN_COM_MAP(CRmsDrive)
  33. COM_INTERFACE_ENTRY2(IDispatch, IRmsDrive)
  34. COM_INTERFACE_ENTRY(IRmsDrive)
  35. COM_INTERFACE_ENTRY(IRmsComObject)
  36. COM_INTERFACE_ENTRY(IRmsChangerElement)
  37. COM_INTERFACE_ENTRY(IRmsDevice)
  38. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  39. COM_INTERFACE_ENTRY2(IPersist, IPersistStream)
  40. COM_INTERFACE_ENTRY(IPersistStream)
  41. COM_INTERFACE_ENTRY(IWsbCollectable)
  42. COM_INTERFACE_ENTRY(IWsbPersistStream)
  43. COM_INTERFACE_ENTRY(IWsbTestable)
  44. END_COM_MAP()
  45. DECLARE_REGISTRY_RESOURCEID(IDR_RmsDrive)
  46. // CComObjectRoot
  47. public:
  48. STDMETHOD(FinalConstruct)(void);
  49. STDMETHOD(FinalRelease)(void);
  50. // IPersist
  51. public:
  52. STDMETHOD(GetClassID)(CLSID *pClsid);
  53. // IPersistStream
  54. public:
  55. STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pSize);
  56. STDMETHOD(Load)(IStream* pStream);
  57. STDMETHOD(Save)(IStream* pStream, BOOL clearDirty);
  58. // IWsbCollectable
  59. public:
  60. STDMETHOD(CompareTo)(IUnknown* pCollectable, SHORT* pResult);
  61. WSB_FROM_CWSBOBJECT;
  62. // IWsbTestable
  63. public:
  64. STDMETHOD(Test)(USHORT *pPassed, USHORT *pFailed);
  65. // IRmsDrive
  66. public:
  67. STDMETHOD(GetMountReference)( OUT LONG *pRefs );
  68. STDMETHOD(ResetMountReference)();
  69. STDMETHOD(SelectForMount)();
  70. STDMETHOD(AddMountReference)();
  71. STDMETHOD(ReleaseMountReference)(IN DWORD dwOptions = RMS_NONE);
  72. STDMETHOD(CreateDataMover)( OUT IDataMover **ptr );
  73. STDMETHOD(ReleaseDataMover)( IN IDataMover *ptr );
  74. STDMETHOD(Eject)(void);
  75. STDMETHOD(GetLargestFreeSpace)( OUT LONGLONG *freeSpace, OUT LONGLONG *capacity );
  76. STDMETHOD(UnloadNow)(void);
  77. // CRmsDrive member functions
  78. public:
  79. HRESULT FlushBuffers(void);
  80. HRESULT Unload(void);
  81. private:
  82. enum { // Class specific constants:
  83. //
  84. Version = 1, // Class version, this should be
  85. // incremented each time the
  86. // the class definition changes.
  87. }; //
  88. LONG m_MountReference; // A reference count for the number
  89. // concurrent mounts for the mounted
  90. // Cartridge. When zero the Cartridge
  91. // can be safely returned to it's
  92. // storage location.
  93. FILETIME m_UnloadNowTime; // Indicates the time when the media
  94. // should be dismounted.
  95. HANDLE m_UnloadNowEvent; // When signal the drive will unload immediately.
  96. HANDLE m_UnloadedEvent; // When signal the drive has been unloaded.
  97. HANDLE m_UnloadThreadHandle; // The thread handle to the thread that unloads the drive.
  98. CRITICAL_SECTION m_CriticalSection; // Object sychronization support
  99. BOOL m_bCritSecCreated; // Indicates whether all CritSec were created successfully (for cleanup)
  100. static int s_InstanceCount; // Counter of the number of object instances.
  101. HRESULT Lock(void);
  102. HRESULT Unlock(void);
  103. // Thread routines
  104. public:
  105. static DWORD WINAPI StartUnloadThread(IN LPVOID pv);
  106. };
  107. #endif // _RMSDRIVE_