1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef _SOT_FACTORY_HXX 29 #define _SOT_FACTORY_HXX 30 31 #ifndef _TOOLS_GLOBNAME_HXX 32 #include <tools/globname.hxx> 33 #endif 34 #ifndef _TOOLS_RTTI_HXX 35 #include <tools/rtti.hxx> 36 #endif 37 #include "sot/sotdllapi.h" 38 39 /************************************************************************* 40 *************************************************************************/ 41 class SotObject; 42 class SotFactory; 43 44 DECLARE_LIST( SotFactoryList, SotFactory * ) 45 typedef void * (*CreateInstanceType)( SotObject ** ); 46 47 //==================class SotFactory======================================= 48 class SOT_DLLPUBLIC SotFactory : public SvGlobalName 49 { 50 sal_uInt16 nSuperCount; // Anzahl der Superklassen 51 const SotFactory ** pSuperClasses; // Superklassen 52 CreateInstanceType pCreateFunc; 53 54 String aClassName; 55 56 static sal_Bool ExistTest( const SvGlobalName & ); 57 protected: 58 virtual ~SotFactory(); 59 public: 60 TYPEINFO(); 61 static void DeInit(); 62 static void IncSvObjectCount( SotObject * = NULL ); 63 static void DecSvObjectCount( SotObject * = NULL ); 64 static sal_uInt32 GetSvObjectCount(); 65 static void TestInvariant(); 66 67 static const SotFactory * Find( const SvGlobalName & ); 68 static const SotFactoryList * GetFactoryList(); 69 70 SotFactory( const SvGlobalName &, 71 const String & rClassName, CreateInstanceType ); 72 73 void PutSuperClass( const SotFactory * ); 74 virtual void * CreateInstance( SotObject ** ppObj = NULL ) const; 75 void * CastAndAddRef( SotObject * ) const; 76 77 sal_Bool Is( const SotFactory * pSuperClass ) const; 78 const SotFactory * GetSuper( sal_uInt16 nPos ) const 79 { 80 return nPos < nSuperCount ? 81 pSuperClasses[ nPos ] 82 : NULL; 83 } 84 85 private: 86 SOT_DLLPRIVATE SotFactory( const SotFactory & ); 87 SOT_DLLPRIVATE SotFactory & operator = ( const SotFactory & ); 88 }; 89 90 #endif // _FACTORY_HXX 91