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
5.2 KiB

  1. /******************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. History.h
  5. Abstract:
  6. This file contains the declaration of the classes used to implement
  7. the storage of Historical Information from the Data Collection system.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 07/30/99
  10. created
  11. ******************************************************************************/
  12. #if !defined(__INCLUDED___PCH___HISTORY_H___)
  13. #define __INCLUDED___PCH___HISTORY_H___
  14. #include <MPC_COM.h>
  15. /////////////////////////////////////////////////////////////////////////////
  16. #define WMIHISTORY_MAX_NUMBER_OF_DELTAS (30)
  17. namespace WMIHistory
  18. {
  19. class Data // Hungarian: wmihpd
  20. {
  21. friend class Provider;
  22. friend class Database;
  23. private:
  24. Provider* m_wmihp;
  25. MPC::wstring m_szFile;
  26. LONG m_lSequence;
  27. DWORD m_dwCRC;
  28. DATE m_dTimestampT0;
  29. DATE m_dTimestampT1;
  30. bool m_fDontDelete;
  31. public:
  32. Data( /*[in]*/ Provider* wmihp );
  33. ~Data();
  34. HRESULT get_File ( /*[out]*/ MPC::wstring& szFile );
  35. HRESULT get_Sequence ( /*[out]*/ LONG & lSequence );
  36. HRESULT get_TimestampT0( /*[out]*/ DATE & dTimestampT0 );
  37. HRESULT get_TimestampT1( /*[out]*/ DATE & dTimestampT1 );
  38. bool IsSnapshot();
  39. HRESULT LoadCIM( /*[in]*/ MPC::XmlUtil& xmlNode );
  40. };
  41. class Provider // Hungarian: wmihp
  42. {
  43. friend class Data;
  44. friend class Database;
  45. public:
  46. typedef std::list<Data*> DataList;
  47. typedef DataList::iterator DataIter;
  48. typedef DataList::const_iterator DataIterConst;
  49. private:
  50. Database* m_wmihd;
  51. DataList m_lstData; // List of all the data collected for this provider.
  52. DataList m_lstDataTmp; // List of temporary data.
  53. MPC::wstring m_szNamespace;
  54. MPC::wstring m_szClass;
  55. MPC::wstring m_szWQL;
  56. public:
  57. Provider( Database* wmihd );
  58. ~Provider();
  59. HRESULT enum_Data ( /*[out]*/ DataIterConst& itBegin , /*[out]*/ DataIterConst& itEnd );
  60. HRESULT get_Namespace( /*[out]*/ MPC::wstring& szNamespace );
  61. HRESULT get_Class ( /*[out]*/ MPC::wstring& szClass );
  62. HRESULT get_WQL ( /*[out]*/ MPC::wstring& szWQL );
  63. HRESULT insert_Snapshot( /*[in]*/ Data* wmihpd, /*[in]*/ bool fPersist = true );
  64. HRESULT remove_Snapshot( /*[in]*/ Data* wmihpd, /*[in]*/ bool fPersist = true );
  65. HRESULT alloc_Snapshot( /*[in]*/ MPC::XmlUtil& xmlNode, /*[out]*/ Data*& wmihpd );
  66. HRESULT get_Snapshot ( /*[out]*/ Data*& wmihpd );
  67. HRESULT get_Delta ( /*[in]*/ int iIndex , /*[out]*/ Data*& wmihpd );
  68. HRESULT get_Date ( /*[in]*/ DATE dDate , /*[out]*/ Data*& wmihpd );
  69. HRESULT get_Sequence ( /*[in]*/ LONG lSequence , /*[out]*/ Data*& wmihpd );
  70. HRESULT ComputeDiff( /*[in]*/ Data* wmihpd_T0, /*[in]*/ Data* wmihpd_T1, /*[out]*/ Data*& wmihpd );
  71. HRESULT EnsureFreeSpace();
  72. };
  73. class Database : public MPC::NamedMutex // Hungarian: wmihd
  74. {
  75. friend class Data;
  76. friend class Provider;
  77. public:
  78. typedef std::list<Provider*> ProvList;
  79. typedef ProvList::iterator ProvIter;
  80. typedef ProvList::const_iterator ProvIterConst;
  81. private:
  82. ProvList m_lstProviders; // List of all the providers of this database.
  83. MPC::wstring m_szBase;
  84. MPC::wstring m_szSchema;
  85. LONG m_lSequence;
  86. LONG m_lSequence_Latest;
  87. DATE m_dTimestamp;
  88. DATE m_dTimestamp_Latest;
  89. void GetFullPathName( /*[in]*/ MPC::wstring& szFile );
  90. HRESULT GetNewUniqueFileName( /*[in]*/ MPC::wstring& szFile );
  91. HRESULT PurgeFiles();
  92. HRESULT LoadCIM( /*[in]*/ LPCWSTR szFile, /*[in]*/ MPC::XmlUtil& xmlNode, /*[in]*/ LPCWSTR szTag );
  93. HRESULT SaveCIM( /*[in]*/ LPCWSTR szFile, /*[in]*/ MPC::XmlUtil& xmlNode, /*[out]*/ DWORD& dwCRC );
  94. HRESULT GetLock( /*[in]*/ DWORD dwMilliseconds = INFINITE );
  95. public:
  96. Database();
  97. ~Database();
  98. DATE LastTime() const { return m_dTimestamp_Latest; }
  99. HRESULT Init( /*[in]*/ LPCWSTR szBase, /*[in]*/ LPCWSTR szSchema );
  100. HRESULT Load();
  101. HRESULT Save();
  102. HRESULT get_Providers( /*[out]*/ ProvIterConst& itBegin, /*[out]*/ ProvIterConst& itEnd );
  103. HRESULT find_Provider( /*[in]*/ ProvIterConst* it ,
  104. /*[in]*/ const MPC::wstring* szNamespace,
  105. /*[in]*/ const MPC::wstring* szClass ,
  106. /*[in]*/ Provider* & wmihp );
  107. };
  108. };
  109. #endif // !defined(__INCLUDED___PCH___HISTORY_H___)