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.

154 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. Pointer.hxx
  5. Abstract:
  6. Declaration of VSS_OBJECT_PROP_Ptr
  7. This class is used as an element in the CSimpleArrays.
  8. This class is NOT a smart pointer. Life management of the internal pointer
  9. must be done explicitely from outside.
  10. WARNING:
  11. Beware how variables with VSS_OBJECT_PROP_Ptr are used!
  12. The destructor is called at the end of variable scope. To avoid destruction of the structure reffered
  13. by the variable, call Reset each time when you pass lifetime ownership to another code!
  14. The destructor is really needed in CSimpleArray clean destruction.
  15. Author:
  16. Adi Oltean [aoltean] 09/21/1999
  17. Revision History:
  18. Name Date Comments
  19. aoltean 09/21/1999 Created for having VSS_OBJECT_PROP_Ptr as a pointer to the properties structure.
  20. This pointer will serve as element in CSimpleArray constructs.
  21. aoltean 09/22/1999 Adding InitializeAsEmpty and Print
  22. aoltean 10/05/1999 Adding internal data member m_pInterface;
  23. aoltean 10/07/1999 Adding m_pwszSnapshotVolumeName, device object, modif timestamp
  24. aoltean 03/27/2000 Adding Writer support
  25. --*/
  26. #ifndef __VSS_PTR_HXX__
  27. #define __VSS_PTR_HXX__
  28. #if _MSC_VER > 1000
  29. #pragma once
  30. #endif
  31. ////////////////////////////////////////////////////////////////////////
  32. // Standard foo for file name aliasing. This code block must be after
  33. // all includes of VSS header files.
  34. //
  35. #ifdef VSS_FILE_ALIAS
  36. #undef VSS_FILE_ALIAS
  37. #endif
  38. #define VSS_FILE_ALIAS "INCPNTRH"
  39. //
  40. ////////////////////////////////////////////////////////////////////////
  41. /////////////////////////////////////////////////////////////////////////////
  42. // VSS_OBJECT_PROP_Ptr
  43. class VSS_OBJECT_PROP_Ptr
  44. {
  45. // Constructors and destructors
  46. public:
  47. VSS_OBJECT_PROP_Ptr(): m_pStruct(NULL) {};
  48. VSS_OBJECT_PROP_Ptr(const VSS_OBJECT_PROP_Ptr& rhs): m_pStruct(rhs.m_pStruct), m_pProviderItf(NULL) {};
  49. ~VSS_OBJECT_PROP_Ptr() // Called in CSimpleArray::RemoveAll
  50. {
  51. if (m_pStruct)
  52. {
  53. VSS_OBJECT_PROP_Copy::destroy(m_pStruct);
  54. ::CoTaskMemFree(static_cast<LPVOID>(m_pStruct));
  55. }
  56. };
  57. // Attributes
  58. public:
  59. VSS_OBJECT_PROP* GetStruct() const { return m_pStruct; };
  60. // Operators
  61. public:
  62. VSS_OBJECT_PROP_Ptr& operator = (const VSS_OBJECT_PROP_Ptr& rhs)
  63. {
  64. BS_ASSERT(m_pStruct == NULL);
  65. m_pStruct = rhs.m_pStruct;
  66. return (*this);
  67. };
  68. bool operator == (const VSS_OBJECT_PROP_Ptr& rhs)
  69. {
  70. return (m_pStruct == rhs.m_pStruct);
  71. };
  72. // Operations
  73. public:
  74. void Reset() { m_pStruct = NULL; }; // Must be called after detaching the internal pointer.
  75. void InitializeAsSnapshot(
  76. IN CVssFunctionTracer& ft,
  77. IN VSS_ID Id,
  78. IN VSS_ID SnapshotSetId,
  79. IN LONG lSnapshotsCount,
  80. IN VSS_PWSZ pwszSnapshotDeviceObject,
  81. IN VSS_PWSZ pwszOriginalVolumeName,
  82. IN VSS_PWSZ pwszOriginatingMachine,
  83. IN VSS_PWSZ pwszServiceMachine,
  84. IN VSS_PWSZ pwszExposedName,
  85. IN VSS_PWSZ pwszExposedPath,
  86. IN VSS_ID ProviderId,
  87. IN LONG lSnapshotAttributes,
  88. IN VSS_TIMESTAMP tsCreationTimestamp,
  89. IN VSS_SNAPSHOT_STATE eStatus
  90. ) throw (HRESULT);
  91. void InitializeAsProvider(
  92. IN CVssFunctionTracer& ft,
  93. IN VSS_ID ProviderId,
  94. IN VSS_PWSZ pwszProviderName,
  95. IN VSS_PROVIDER_TYPE eProviderType,
  96. IN VSS_PWSZ pwszProviderVersion,
  97. IN VSS_ID ProviderVersionId,
  98. IN CLSID ClassId
  99. ) throw (HRESULT);
  100. void InitializeAsEmpty(
  101. IN CVssFunctionTracer& ft
  102. ) throw (HRESULT);
  103. void Print(
  104. IN CVssFunctionTracer& ft,
  105. IN LPWSTR wszOutputBuffer,
  106. IN LONG lBufferSize
  107. ) throw (HRESULT);
  108. // Data member
  109. private:
  110. VSS_OBJECT_PROP* m_pStruct; // Must be allocated using CoTaskMemAlloc
  111. public:
  112. CComPtr<IVssSnapshotProvider> m_pProviderItf; // Used only in providers array management.
  113. // Must be managed by outside.
  114. // It is not copied in the normal copy process.
  115. // But it is released by the destructor.
  116. };
  117. #endif // __VSS_PTR_HXX__