xref: /trunk/main/sot/inc/sot/factory.hxx (revision bbfc4cc7)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SOT_FACTORY_HXX
25 #define _SOT_FACTORY_HXX
26 
27 #ifndef _TOOLS_GLOBNAME_HXX
28 #include <tools/globname.hxx>
29 #endif
30 #ifndef _TOOLS_RTTI_HXX
31 #include <tools/rtti.hxx>
32 #endif
33 #include "sot/sotdllapi.h"
34 
35 /*************************************************************************
36 *************************************************************************/
37 class SotObject;
38 class SotFactory;
39 
40 DECLARE_LIST( SotFactoryList, SotFactory * )
41 typedef void * (*CreateInstanceType)( SotObject ** );
42 
43 //==================class SotFactory=======================================
44 class SOT_DLLPUBLIC SotFactory : public SvGlobalName
45 {
46     sal_uInt16              nSuperCount;    // Anzahl der Superklassen
47     const SotFactory ** pSuperClasses;  // Superklassen
48     CreateInstanceType  pCreateFunc;
49 
50     String              aClassName;
51 
52     static  sal_Bool        ExistTest( const SvGlobalName & );
53 protected:
54     virtual             ~SotFactory();
55 public:
56 						TYPEINFO();
57 	static	void		DeInit();
58     static  void        IncSvObjectCount( SotObject * = NULL );
59     static  void        DecSvObjectCount( SotObject * = NULL );
60     static  sal_uInt32      GetSvObjectCount();
61     static  void        TestInvariant();
62 
63     static  const SotFactory * 		Find( const SvGlobalName & );
64     static  const SotFactoryList *	GetFactoryList();
65 
66             SotFactory( const SvGlobalName &,
67                        const String & rClassName, CreateInstanceType );
68 
69     void                PutSuperClass( const SotFactory * );
70     virtual void *      CreateInstance( SotObject ** ppObj = NULL ) const;
71 	void *				CastAndAddRef( SotObject * ) const;
72 
73     sal_Bool                Is( const SotFactory * pSuperClass ) const;
GetSuper(sal_uInt16 nPos) const74     const SotFactory *  GetSuper( sal_uInt16 nPos ) const
75 						{
76 							return nPos < nSuperCount ?
77 										 pSuperClasses[ nPos ]
78 										 : NULL;
79 						}
80 
81 private:
82                         SOT_DLLPRIVATE SotFactory( const SotFactory & );
83     SOT_DLLPRIVATE SotFactory &        operator = ( const SotFactory & );
84 };
85 
86 #endif // _FACTORY_HXX
87