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.

138 lines
3.9 KiB

  1. /*****************************************************************************
  2. *
  3. * mapcf.c - IClassFactory interface
  4. *
  5. *****************************************************************************/
  6. #include "map.h"
  7. /*****************************************************************************
  8. *
  9. * The sqiffle for this file.
  10. *
  11. *****************************************************************************/
  12. #define sqfl sqflFactory
  13. /*****************************************************************************
  14. *
  15. * Declare the interfaces we will be providing.
  16. *
  17. *****************************************************************************/
  18. Primary_Interface(CMapFactory, IClassFactory);
  19. /*****************************************************************************
  20. *
  21. * CMapFactory
  22. *
  23. * Really nothing doing.
  24. *
  25. *****************************************************************************/
  26. typedef struct CMapFactory {
  27. /* Supported interfaces */
  28. IClassFactory cf;
  29. } CMapFactory, FCF, *PFCF;
  30. typedef IClassFactory CF, *PCF;
  31. /*****************************************************************************
  32. *
  33. * CMapFactory_QueryInterface (from IUnknown)
  34. * CMapFactory_AddRef (from IUnknown)
  35. * CMapFactory_Finalize (from Common)
  36. * CMapFactory_Release (from IUnknown)
  37. *
  38. *****************************************************************************/
  39. #ifdef DEBUG
  40. Default_QueryInterface(CMapFactory)
  41. Default_AddRef(CMapFactory)
  42. Default_Release(CMapFactory)
  43. #else
  44. #define CMapFactory_QueryInterface Common_QueryInterface
  45. #define CMapFactory_AddRef Common_AddRef
  46. #define CMapFactory_Release Common_Release
  47. #endif
  48. #define CMapFactory_Finalize Common_Finalize
  49. /*****************************************************************************
  50. *
  51. * CMapFactory_CreateInstance (from IClassFactory)
  52. *
  53. *****************************************************************************/
  54. STDMETHODIMP
  55. CMapFactory_CreateInstance(PCF pcf, LPUNKNOWN punkOuter, RIID riid, PPV ppvObj)
  56. {
  57. HRESULT hres;
  58. SquirtSqflPtszV(sqfl, TEXT("CMapFactory_CreateInstance()"));
  59. if (!punkOuter) {
  60. /* The only object we know how to create is a propsheet extension */
  61. hres = CMapPsx_New(riid, ppvObj);
  62. } else { /* Does anybody support aggregation any more? */
  63. hres = CLASS_E_NOAGGREGATION;
  64. }
  65. SquirtSqflPtszV(sqfl, TEXT("CMapFactory_CreateInstance() -> %08x [%08x]"),
  66. hres, *ppvObj);
  67. return hres;
  68. }
  69. /*****************************************************************************
  70. *
  71. * CMapFactory_LockServer (from IClassFactory)
  72. *
  73. * What a stupid function. Locking the server is identical to
  74. * creating an object and not releasing it until you want to unlock
  75. * the server.
  76. *
  77. *****************************************************************************/
  78. STDMETHODIMP
  79. CMapFactory_LockServer(PCF pcf, BOOL fLock)
  80. {
  81. PFCF this = IToClass(CMapFactory, cf, pcf);
  82. if (fLock) {
  83. InterlockedIncrement((LPLONG)&g_cRef);
  84. } else {
  85. AssertF(0 != g_cRef);
  86. InterlockedDecrement((LPLONG)&g_cRef);
  87. }
  88. return S_OK;
  89. }
  90. /*****************************************************************************
  91. *
  92. * CMapFactory_New
  93. *
  94. *****************************************************************************/
  95. STDMETHODIMP
  96. CMapFactory_New(RIID riid, PPV ppvObj)
  97. {
  98. HRESULT hres;
  99. if (IsEqualIID(riid, &IID_IClassFactory)) {
  100. hres = Common_New(CMapFactory, ppvObj);
  101. } else {
  102. hres = E_NOINTERFACE;
  103. }
  104. return hres;
  105. }
  106. /*****************************************************************************
  107. *
  108. * The long-awaited vtbl
  109. *
  110. *****************************************************************************/
  111. #pragma BEGIN_CONST_DATA
  112. Primary_Interface_Begin(CMapFactory, IClassFactory)
  113. CMapFactory_CreateInstance,
  114. CMapFactory_LockServer,
  115. Primary_Interface_End(CMapFactory, IClassFactory)