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.

152 lines
3.9 KiB

  1. /*
  2. * classes.hxx
  3. */
  4. #ifndef _CLASSES_
  5. #define _CLASSES_
  6. #define IUnknownMETHODS( ClassName ) \
  7. HRESULT STDMETHODCALLTYPE \
  8. ClassName::QueryInterface ( \
  9. REFIID iid, \
  10. void ** ppv ) \
  11. { \
  12. return pObject->QueryInterface( iid, ppv ); \
  13. } \
  14. \
  15. ULONG STDMETHODCALLTYPE \
  16. ClassName::AddRef() \
  17. { \
  18. return pObject->AddRef(); \
  19. } \
  20. \
  21. ULONG STDMETHODCALLTYPE \
  22. ClassName::Release() \
  23. { \
  24. return pObject->Release(); \
  25. }
  26. class MyObject;
  27. //
  28. // PersistFile class.
  29. //
  30. class PersistFile : public IPersistFile
  31. {
  32. private:
  33. MyObject * pObject;
  34. public:
  35. PersistFile( MyObject * pObj );
  36. // IUnknown
  37. HRESULT __stdcall QueryInterface(
  38. REFIID iid,
  39. void ** ppv );
  40. ULONG __stdcall AddRef();
  41. ULONG __stdcall Release();
  42. // IPersist
  43. HRESULT __stdcall GetClassID(
  44. CLSID * pClassID );
  45. // IPersistFile
  46. HRESULT __stdcall IsDirty();
  47. HRESULT __stdcall Load(
  48. LPCOLESTR pszFileName,
  49. DWORD dwMode );
  50. HRESULT __stdcall Save(
  51. LPCOLESTR pszFileName,
  52. BOOL fRemember );
  53. HRESULT __stdcall SaveCompleted(
  54. LPCOLESTR pszFileName );
  55. HRESULT __stdcall GetCurFile(
  56. LPOLESTR * ppszFileName );
  57. };
  58. //
  59. // PersistStorage class.
  60. //
  61. class PersistStorage : public IPersistStorage
  62. {
  63. private:
  64. MyObject * pObject;
  65. public:
  66. PersistStorage( MyObject * pObj );
  67. // IUnknown
  68. HRESULT __stdcall QueryInterface(
  69. REFIID iid,
  70. void ** ppv );
  71. ULONG __stdcall AddRef();
  72. ULONG __stdcall Release();
  73. // IPersist
  74. HRESULT __stdcall GetClassID(
  75. CLSID *pClassID );
  76. // IPersistStorage
  77. HRESULT __stdcall IsDirty();
  78. HRESULT __stdcall InitNew(
  79. IStorage *pStg );
  80. HRESULT __stdcall Load(
  81. IStorage *pStg );
  82. HRESULT __stdcall Save(
  83. IStorage *pStgSave,
  84. BOOL fSameAsLoad );
  85. HRESULT __stdcall SaveCompleted(
  86. IStorage *pStgNew );
  87. HRESULT __stdcall HandsOffStorage();
  88. };
  89. //
  90. // Goober class.
  91. //
  92. class Goober : IGoober
  93. {
  94. private:
  95. MyObject * pObject;
  96. public:
  97. Goober( MyObject * pObj );
  98. // IUnknown
  99. HRESULT __stdcall QueryInterface(
  100. REFIID iid,
  101. void ** ppv );
  102. ULONG __stdcall AddRef();
  103. ULONG __stdcall Release();
  104. // IGoober
  105. HRESULT __stdcall Ping();
  106. };
  107. //
  108. // MyObject class.
  109. //
  110. class MyObject : public IUnknown
  111. {
  112. private:
  113. ulong Refs;
  114. int ActivationType;
  115. PersistFile PersistFileObj;
  116. PersistStorage PersistStorageObj;
  117. Goober GooberObj;
  118. public:
  119. MyObject( int ActType );
  120. ~MyObject();
  121. // IUnknown
  122. HRESULT __stdcall QueryInterface(
  123. REFIID iid,
  124. void ** ppv );
  125. ULONG __stdcall AddRef();
  126. ULONG __stdcall Release();
  127. inline int GetActivationType() { return ActivationType; }
  128. };
  129. #endif
  130.