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.

136 lines
3.1 KiB

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