1 /* Copyright (c) Mark Harmstone 2016-17 2 * 3 * This file is part of WinBtrfs. 4 * 5 * WinBtrfs is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Lesser General Public Licence as published by 7 * the Free Software Foundation, either version 3 of the Licence, or 8 * (at your option) any later version. 9 * 10 * WinBtrfs is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public Licence for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public Licence 16 * along with WinBtrfs. If not, see <http://www.gnu.org/licenses/>. */ 17 18 #pragma once 19 20 extern LONG objs_loaded; 21 22 typedef enum { 23 FactoryUnknown, 24 FactoryIconHandler, 25 FactoryContextMenu, 26 FactoryPropSheet, 27 FactoryVolPropSheet 28 } factory_type; 29 30 class Factory : public IClassFactory { 31 public: 32 Factory() { 33 refcount = 0; 34 type = FactoryUnknown; 35 InterlockedIncrement(&objs_loaded); 36 } 37 38 virtual ~Factory() { 39 InterlockedDecrement(&objs_loaded); 40 } 41 42 // IUnknown 43 44 HRESULT __stdcall QueryInterface(REFIID riid, void **ppObj); 45 46 ULONG __stdcall AddRef() { 47 return InterlockedIncrement(&refcount); 48 } 49 50 ULONG __stdcall Release() { 51 LONG rc = InterlockedDecrement(&refcount); 52 53 if (rc == 0) 54 delete this; 55 56 return rc; 57 } 58 59 // IClassFactory 60 61 virtual HRESULT __stdcall CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv); 62 virtual HRESULT __stdcall LockServer(BOOL bLock); 63 64 factory_type type; 65 66 private: 67 LONG refcount; 68 }; 69