xref: /trunk/main/cppuhelper/inc/cppuhelper/implbase_ex.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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 #ifndef _CPPUHELPER_IMPLBASE_EX_HXX_
28 #define _CPPUHELPER_IMPLBASE_EX_HXX_
29 
30 #include <cppuhelper/weak.hxx>
31 #include <cppuhelper/weakagg.hxx>
32 #include <com/sun/star/lang/XTypeProvider.hpp>
33 
34 // Despite the fact that the following include is not used in this header, it has to remain,
35 // because it is expected by files including cppuhelper/implbaseN.hxx.
36 // So maybe we can omit it some time in the future...
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 
39 /* If you need to define implementation helper classes that deal with more than
40    12 interfaces, then use macros as follows, e.g. for 3 interfaces:
41 
42 #include <cppuhelper/implbase_ex_pre.hxx>
43 #define __IFC_EX_TYPE_INIT3( class_cast ) \
44     __IFC_EX_TYPE_INIT( class_cast, 1 ), __IFC_EX_TYPE_INIT( class_cast, 2 ), \
45     __IFC_EX_TYPE_INIT( class_cast, 3 )
46 #include <cppuhelper/implbase_ex_post.hxx>
47 __DEF_IMPLHELPER_EX( 3 )
48 */
49 
50 
51 namespace cppu
52 {
53 
54 /** function pointer signature for getCppuType
55     @internal
56 */
57 typedef ::com::sun::star::uno::Type const & (SAL_CALL * fptr_getCppuType)( void * ) SAL_THROW( () );
58 
59 /** single type + object offset
60     @internal
61 */
62 struct type_entry
63 {
64     /** the type_entry is initialized with function pointer to ::getCppuType() function first,
65         but holds an unacquired typelib_TypeDescriptionReference * after initialization,
66         thus reusing the memory.  Flag class_data::m_storedTypeRefs
67     */
68     union
69     {
70         fptr_getCppuType getCppuType;
71         typelib_TypeDescriptionReference * typeRef;
72     } m_type;
73     /** offset for interface pointer
74     */
75     sal_IntPtr m_offset;
76 };
77 
78 /** identical dummy struct for casting class_dataN to class_data
79     @internal
80 */
81 struct class_data
82 {
83     /** number of supported types in m_typeEntries
84     */
85     sal_Int16 m_nTypes;
86 
87     /** determines whether m_typeEntries is initialized and carries unacquired type refs
88     */
89     sal_Bool m_storedTypeRefs;
90 
91     /** determines whether an implementation id was created in m_id
92     */
93     sal_Bool m_createdId;
94 
95     /** implementation id
96      */
97     sal_Int8 m_id[ 16 ];
98 
99     /** type, object offset
100     */
101     type_entry m_typeEntries[ 1 ];
102 };
103 
104 /** ImplHelper
105     @internal
106 */
107 ::com::sun::star::uno::Any SAL_CALL ImplHelper_query(
108     ::com::sun::star::uno::Type const & rType,
109     class_data * cd,
110     void * that )
111     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
112 /** ImplHelper
113     @internal
114 */
115 ::com::sun::star::uno::Any SAL_CALL ImplHelper_queryNoXInterface(
116     ::com::sun::star::uno::Type const & rType,
117     class_data * cd,
118     void * that )
119     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
120 /** ImplHelper
121     @internal
122 */
123 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ImplHelper_getTypes(
124     class_data * cd )
125     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
126 /** ImplHelper
127     @internal
128 */
129 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ImplInhHelper_getTypes(
130     class_data * cd,
131     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > const & rAddTypes )
132     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
133 /** ImplHelper
134     @internal
135 */
136 ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL ImplHelper_getImplementationId(
137     class_data * cd )
138     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
139 
140 /** WeakImplHelper
141     @internal
142 */
143 ::com::sun::star::uno::Any SAL_CALL WeakImplHelper_query(
144     ::com::sun::star::uno::Type const & rType,
145     class_data * cd,
146     void * that,
147     ::cppu::OWeakObject * pBase )
148     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
149 /** WeakImplHelper
150     @internal
151 */
152 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakImplHelper_getTypes(
153     class_data * cd )
154     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
155 
156 /** WeakAggImplHelper
157     @internal
158 */
159 ::com::sun::star::uno::Any SAL_CALL WeakAggImplHelper_queryAgg(
160     ::com::sun::star::uno::Type const & rType,
161     class_data * cd,
162     void * that,
163     ::cppu::OWeakAggObject * pBase )
164     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
165 /** WeakAggImplHelper
166     @internal
167 */
168 ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL WeakAggImplHelper_getTypes(
169     class_data * cd )
170     SAL_THROW( (::com::sun::star::uno::RuntimeException) );
171 
172 }
173 
174 #endif
175