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.

142 lines
3.2 KiB

  1. //+-------------------------------------------------------------------
  2. //
  3. // File: cubescf.cxx
  4. //
  5. // Contents: test class factory object implementation
  6. //
  7. // Classes: CCubesClassFactory
  8. //
  9. // Functions:
  10. //
  11. // History: 23-Nov-92 Rickhi Created
  12. //
  13. //--------------------------------------------------------------------
  14. #include <pch.cxx>
  15. #pragma hdrstop
  16. #include <cubescf.hxx> // class definiton
  17. #include <ccubes.hxx> // CCubes defines
  18. const GUID CLSID_Cubes =
  19. {0x0000013b,0x0001,0x0008,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  20. //+-------------------------------------------------------------------
  21. //
  22. // Member: CCubesClassFactory::CCubesClassFactory, public
  23. //
  24. // Algorithm:
  25. //
  26. // History: 23-Nov-92 Rickhi Created
  27. //
  28. //--------------------------------------------------------------------
  29. CCubesClassFactory::CCubesClassFactory(void)
  30. {
  31. ENLIST_TRACKING(CCubesClassFactory);
  32. }
  33. //+-------------------------------------------------------------------
  34. //
  35. // Member: CCubesClassFactory::~CCubesClassFactory, public
  36. //
  37. // Algorithm:
  38. //
  39. // History: 23-Nov-92 Rickhi Created
  40. //
  41. //--------------------------------------------------------------------
  42. CCubesClassFactory::~CCubesClassFactory(void)
  43. {
  44. // automatic actions do the rest of the work
  45. }
  46. //+-------------------------------------------------------------------
  47. //
  48. // Member: CCubesClassFactory::QueryInterface, public
  49. //
  50. // Algorithm: if the interface is not one implemented by us,
  51. // pass the request to the proxy manager
  52. //
  53. // History: 23-Nov-92 Rickhi Created
  54. //
  55. //--------------------------------------------------------------------
  56. STDMETHODIMP CCubesClassFactory::QueryInterface(REFIID riid, void **ppUnk)
  57. {
  58. SCODE sc = S_OK;
  59. if (IsEqualIID(riid, IID_IUnknown) ||
  60. IsEqualIID(riid, IID_IClassFactory))
  61. {
  62. *ppUnk = (void *)(IClassFactory *) this;
  63. AddRef();
  64. }
  65. else
  66. {
  67. *ppUnk = NULL;
  68. sc = E_NOINTERFACE;
  69. }
  70. return sc;
  71. }
  72. //+-------------------------------------------------------------------
  73. //
  74. // Member: CCubesClassFactory::CreateInstance, public
  75. //
  76. // Synopsis: create a new object with the same class
  77. //
  78. // History: 23-Nov-92 Rickhi Created
  79. //
  80. //--------------------------------------------------------------------
  81. STDMETHODIMP CCubesClassFactory::CreateInstance(IUnknown *punkOuter,
  82. REFIID riid,
  83. void **ppunkObject)
  84. {
  85. SCODE sc = E_OUTOFMEMORY;
  86. *ppunkObject = NULL; // in case of failure
  87. // create a Cube object.
  88. ICube *pCubes = (ICube *) new CCube();
  89. if (pCubes)
  90. {
  91. // get the interface the caller wants to use
  92. sc = pCubes->QueryInterface(riid, ppunkObject);
  93. // release our hold on the Cube, since the QI got a hold for
  94. // the client.
  95. pCubes->Release();
  96. }
  97. return sc;
  98. }
  99. //+-------------------------------------------------------------------
  100. //
  101. // Member: CCubesClassFactory::LockServer, public
  102. //
  103. // Synopsis: create a new object with the same class
  104. //
  105. // History: 23-Nov-92 Rickhi Created
  106. //
  107. //--------------------------------------------------------------------
  108. STDMETHODIMP CCubesClassFactory::LockServer(BOOL fLock)
  109. {
  110. if (fLock)
  111. GlobalRefs(TRUE);
  112. else
  113. GlobalRefs(FALSE);
  114. return S_OK;
  115. }