Source code of Windows XP (NT5)
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.

137 lines
3.7 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. InterlockedDecrement((LPLONG)&g_cRef);
  86. }
  87. return S_OK;
  88. }
  89. /*****************************************************************************
  90. *
  91. * CMapFactory_New
  92. *
  93. *****************************************************************************/
  94. STDMETHODIMP
  95. CMapFactory_New(RIID riid, PPV ppvObj)
  96. {
  97. HRESULT hres;
  98. if (IsEqualIID(riid, &IID_IClassFactory)) {
  99. hres = Common_New(CMapFactory, ppvObj);
  100. } else {
  101. hres = E_NOINTERFACE;
  102. }
  103. return hres;
  104. }
  105. /*****************************************************************************
  106. *
  107. * The long-awaited vtbl
  108. *
  109. *****************************************************************************/
  110. #pragma BEGIN_CONST_DATA
  111. Primary_Interface_Begin(CMapFactory, IClassFactory)
  112. CMapFactory_CreateInstance,
  113. CMapFactory_LockServer,
  114. Primary_Interface_End(CMapFactory, IClassFactory)