Factory.h (1326B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <hstring.h> 5 #include <inspectable.h> 6 #include <winrt/Windows.Foundation.h> 7 #include <atomic> 8 9 namespace Microsoft::Management::Configuration::OutOfProc 10 { 11 struct Factory : winrt::implements<Factory, winrt::Windows::Foundation::IActivationFactory, IClassFactory> 12 { 13 Factory(); 14 ~Factory(); 15 16 // Returns true if the reference count is not 0; false if it is. 17 static bool HasReferences(); 18 19 // Forcibly destroys any static objects. 20 static void Terminate(); 21 22 // Determines if the given CLSID is the CLSID for the factory. 23 static bool IsCLSID(const GUID& clsid); 24 25 // Determines if the given CLSID is the CLSID for the factory. 26 static bool IsCLSID(HSTRING clsid); 27 28 // IActivationFactory 29 winrt::Windows::Foundation::IInspectable ActivateInstance(); 30 31 // IClassFactory 32 HRESULT STDMETHODCALLTYPE CreateInstance(::IUnknown *pUnkOuter, REFIID riid, void **ppvObject); 33 HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock); 34 35 private: 36 static void IncrementRefCount(); 37 static void DecrementRefCount(); 38 39 static std::atomic<int32_t> s_referenceCount; 40 }; 41 }