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.

87 lines
2.4 KiB

  1. //=================================================================
  2. //
  3. // FactoryRouter.h --
  4. //
  5. // Copyright (c) 2000-2001 Microsoft Corporation, All Rights Reserved
  6. //
  7. //=================================================================
  8. #ifndef _WMI_FACTORY_ROUTER_H
  9. #define _WMI_FACTORY_ROUTER_H
  10. #include <cautolock.h>
  11. //=================================================================================
  12. // This is the router factory
  13. //=================================================================================
  14. class CFactoryRouter : public IClassFactory
  15. {
  16. private:
  17. DWORD m_Register;
  18. GUID m_ClsId;
  19. CHString m_sDescription;
  20. public:
  21. CFactoryRouter ( REFGUID a_rClsId, LPCWSTR a_pClassName ) ;
  22. ~CFactoryRouter () ;
  23. //IUnknown members
  24. STDMETHODIMP QueryInterface( REFIID , LPVOID FAR * ) ;
  25. STDMETHODIMP_( ULONG ) AddRef() ;
  26. STDMETHODIMP_( ULONG ) Release() ;
  27. //IClassFactory members
  28. STDMETHODIMP CreateInstance( LPUNKNOWN , REFIID , LPVOID FAR * ) ;
  29. STDMETHODIMP LockServer( BOOL ) ;
  30. static void ClsToString( CHString &a_chsClsId, REFGUID a_rClsId ) ;
  31. REFGUID GetClsId();
  32. LPCWSTR GetClassDescription();
  33. DWORD GetRegister();
  34. void SetRegister( DWORD a_dwRegister );
  35. // pure virtuals
  36. virtual IUnknown * CreateInstance ( REFIID a_riid , LPVOID FAR *a_ppvObject ) = 0 ;
  37. };
  38. //=================================================================================
  39. // There is only one global instance of this class to manage all of the data
  40. // from the CFactoryRouter guys
  41. //=================================================================================
  42. class CFactoryRouterData
  43. {
  44. private:
  45. typedef std::map<CHString, CFactoryRouter*> Factory_Map ;
  46. Factory_Map mg_oFactoryMap ;
  47. CCriticalSec m_cs;
  48. LONG s_LocksInProgress ;
  49. LONG s_ObjectsInProgress ;
  50. long m_ReferenceCount ;
  51. public:
  52. CFactoryRouterData();
  53. ~CFactoryRouterData();
  54. void AddToMap( REFGUID a_rClsId, CFactoryRouter * pFactory ) ;
  55. void AddLock();
  56. void ReleaseLock();
  57. STDMETHODIMP_( ULONG ) AddRef() ;
  58. STDMETHODIMP_( ULONG ) Release() ;
  59. // dll level interfaces
  60. BOOL DllCanUnloadNow() ;
  61. HRESULT DllGetClassObject( REFCLSID rclsid, REFIID riid, PPVOID ppv ) ;
  62. HRESULT DllRegisterServer() ;
  63. HRESULT DllUnregisterServer() ;
  64. HRESULT InitComServer() ;
  65. HRESULT UninitComServer() ;
  66. };
  67. #endif // _WMI_FACTORY_ROUTER_H