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.

123 lines
2.9 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // SYNOPSIS
  6. //
  7. // Declares the class ReportEventCommand.
  8. //
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef REPORTEVENTCMD_H
  11. #define REPORTEVENTCMD_H
  12. #pragma once
  13. #include "oledb.h"
  14. // Invokes the report_event stored procedure.
  15. class ReportEventCommand
  16. {
  17. public:
  18. ReportEventCommand() throw ();
  19. ~ReportEventCommand() throw ();
  20. // Used to detect stale command objects.
  21. unsigned int Version() const throw ();
  22. void SetVersion(unsigned int newVersion) throw ();
  23. // Functions for managing linked lists of commands.
  24. ReportEventCommand* Next() const throw ();
  25. void SetNext(ReportEventCommand* cmd) throw ();
  26. // Prepare the command for execution.
  27. HRESULT Prepare(IDBCreateSession* dbCreateSession) throw ();
  28. // Test if the command is prepared.
  29. bool IsPrepared() const throw ();
  30. // Execute the command. IsPrepared must be 'true'.
  31. HRESULT Execute(const wchar_t* doc) throw ();
  32. // Release all resources associated with the command.
  33. void Unprepare() throw ();
  34. static HRESULT CreateDataSource(
  35. const wchar_t* dataSource,
  36. IDBCreateSession** newDataSource
  37. ) throw ();
  38. private:
  39. // Parameters passed to the stored procedure.
  40. struct SprocParams
  41. {
  42. long retval;
  43. const wchar_t* doc;
  44. };
  45. void ReleaseAccessorHandle() throw ();
  46. static void TraceComError(
  47. const char* function,
  48. HRESULT error
  49. ) throw ();
  50. static void TraceOleDbError(
  51. const char* function,
  52. HRESULT error
  53. ) throw ();
  54. CComPtr<ICommand> command;
  55. CComPtr<IAccessor> accessorManager;
  56. HACCESSOR accessorHandle;
  57. unsigned int version;
  58. ReportEventCommand* next;
  59. // Not implemented.
  60. ReportEventCommand(const ReportEventCommand&);
  61. ReportEventCommand& operator=(const ReportEventCommand&);
  62. };
  63. inline ReportEventCommand::ReportEventCommand() throw ()
  64. : accessorHandle(0), version(0), next(0)
  65. {
  66. }
  67. inline ReportEventCommand::~ReportEventCommand() throw ()
  68. {
  69. ReleaseAccessorHandle();
  70. }
  71. inline unsigned int ReportEventCommand::Version() const throw ()
  72. {
  73. return version;
  74. }
  75. inline void ReportEventCommand::SetVersion(
  76. unsigned int newVersion
  77. ) throw ()
  78. {
  79. version = newVersion;
  80. }
  81. inline ReportEventCommand* ReportEventCommand::Next() const throw ()
  82. {
  83. return next;
  84. }
  85. inline void ReportEventCommand::SetNext(ReportEventCommand* cmd) throw ()
  86. {
  87. next = cmd;
  88. }
  89. inline bool ReportEventCommand::IsPrepared() const throw ()
  90. {
  91. return command.p != 0;
  92. }
  93. #endif // REPORTEVENTCMD_H