xref: /trunk/main/cppuhelper/inc/cppuhelper/typeprovider.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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 #ifndef _CPPUHELPER_TYPEPROVIDER_HXX_
24 #define _CPPUHELPER_TYPEPROVIDER_HXX_
25 
26 #include <rtl/alloc.h>
27 #include <rtl/uuid.h>
28 #include <com/sun/star/uno/Sequence.hxx>
29 
30 #include "cppuhelper/cppuhelperdllapi.h"
31 
32 namespace cppu
33 {
34 
35 /** Helper class to implement ::com::sun::star::lang::XTypeProvider.  Construct a static object
36     of this class with your UNO object's supported types.
37 */
38 class CPPUHELPER_DLLPUBLIC OTypeCollection
39 {
40     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > _aTypes;
41 
42 public:
43     // these are here to force memory de/allocation to sal lib.
44     /** @internal */
operator new(size_t nSize)45     inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
46         { return ::rtl_allocateMemory( nSize ); }
47     /** @internal */
operator delete(void * pMem)48     inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
49         { ::rtl_freeMemory( pMem ); }
50     /** @internal */
operator new(size_t,void * pMem)51     inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () )
52         { return pMem; }
53     /** @internal */
operator delete(void *,void *)54     inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () )
55         {}
56 
57     inline OTypeCollection( const OTypeCollection & rCollection )
58         SAL_THROW( () )
59         : _aTypes( rCollection._aTypes )
60         {}
61     OTypeCollection(
62         const ::com::sun::star::uno::Type & rType1,
63         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
64         SAL_THROW( () );
65     OTypeCollection(
66         const ::com::sun::star::uno::Type & rType1,
67         const ::com::sun::star::uno::Type & rType2,
68         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
69         SAL_THROW( () );
70     OTypeCollection(
71         const ::com::sun::star::uno::Type & rType1,
72         const ::com::sun::star::uno::Type & rType2,
73         const ::com::sun::star::uno::Type & rType3,
74         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
75         SAL_THROW( () );
76     OTypeCollection(
77         const ::com::sun::star::uno::Type & rType1,
78         const ::com::sun::star::uno::Type & rType2,
79         const ::com::sun::star::uno::Type & rType3,
80         const ::com::sun::star::uno::Type & rType4,
81         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
82         SAL_THROW( () );
83     OTypeCollection(
84         const ::com::sun::star::uno::Type & rType1,
85         const ::com::sun::star::uno::Type & rType2,
86         const ::com::sun::star::uno::Type & rType3,
87         const ::com::sun::star::uno::Type & rType4,
88         const ::com::sun::star::uno::Type & rType5,
89         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
90         SAL_THROW( () );
91     OTypeCollection(
92         const ::com::sun::star::uno::Type & rType1,
93         const ::com::sun::star::uno::Type & rType2,
94         const ::com::sun::star::uno::Type & rType3,
95         const ::com::sun::star::uno::Type & rType4,
96         const ::com::sun::star::uno::Type & rType5,
97         const ::com::sun::star::uno::Type & rType6,
98         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
99         SAL_THROW( () );
100     OTypeCollection(
101         const ::com::sun::star::uno::Type & rType1,
102         const ::com::sun::star::uno::Type & rType2,
103         const ::com::sun::star::uno::Type & rType3,
104         const ::com::sun::star::uno::Type & rType4,
105         const ::com::sun::star::uno::Type & rType5,
106         const ::com::sun::star::uno::Type & rType6,
107         const ::com::sun::star::uno::Type & rType7,
108         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
109         SAL_THROW( () );
110     OTypeCollection(
111         const ::com::sun::star::uno::Type & rType1,
112         const ::com::sun::star::uno::Type & rType2,
113         const ::com::sun::star::uno::Type & rType3,
114         const ::com::sun::star::uno::Type & rType4,
115         const ::com::sun::star::uno::Type & rType5,
116         const ::com::sun::star::uno::Type & rType6,
117         const ::com::sun::star::uno::Type & rType7,
118         const ::com::sun::star::uno::Type & rType8,
119         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
120         SAL_THROW( () );
121     OTypeCollection(
122         const ::com::sun::star::uno::Type & rType1,
123         const ::com::sun::star::uno::Type & rType2,
124         const ::com::sun::star::uno::Type & rType3,
125         const ::com::sun::star::uno::Type & rType4,
126         const ::com::sun::star::uno::Type & rType5,
127         const ::com::sun::star::uno::Type & rType6,
128         const ::com::sun::star::uno::Type & rType7,
129         const ::com::sun::star::uno::Type & rType8,
130         const ::com::sun::star::uno::Type & rType9,
131         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
132         SAL_THROW( () );
133     OTypeCollection(
134         const ::com::sun::star::uno::Type & rType1,
135         const ::com::sun::star::uno::Type & rType2,
136         const ::com::sun::star::uno::Type & rType3,
137         const ::com::sun::star::uno::Type & rType4,
138         const ::com::sun::star::uno::Type & rType5,
139         const ::com::sun::star::uno::Type & rType6,
140         const ::com::sun::star::uno::Type & rType7,
141         const ::com::sun::star::uno::Type & rType8,
142         const ::com::sun::star::uno::Type & rType9,
143         const ::com::sun::star::uno::Type & rType10,
144         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
145         SAL_THROW( () );
146     OTypeCollection(
147         const ::com::sun::star::uno::Type & rType1,
148         const ::com::sun::star::uno::Type & rType2,
149         const ::com::sun::star::uno::Type & rType3,
150         const ::com::sun::star::uno::Type & rType4,
151         const ::com::sun::star::uno::Type & rType5,
152         const ::com::sun::star::uno::Type & rType6,
153         const ::com::sun::star::uno::Type & rType7,
154         const ::com::sun::star::uno::Type & rType8,
155         const ::com::sun::star::uno::Type & rType9,
156         const ::com::sun::star::uno::Type & rType10,
157         const ::com::sun::star::uno::Type & rType11,
158         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
159         SAL_THROW( () );
160     OTypeCollection(
161         const ::com::sun::star::uno::Type & rType1,
162         const ::com::sun::star::uno::Type & rType2,
163         const ::com::sun::star::uno::Type & rType3,
164         const ::com::sun::star::uno::Type & rType4,
165         const ::com::sun::star::uno::Type & rType5,
166         const ::com::sun::star::uno::Type & rType6,
167         const ::com::sun::star::uno::Type & rType7,
168         const ::com::sun::star::uno::Type & rType8,
169         const ::com::sun::star::uno::Type & rType9,
170         const ::com::sun::star::uno::Type & rType10,
171         const ::com::sun::star::uno::Type & rType11,
172         const ::com::sun::star::uno::Type & rType12,
173         const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > & rAddTypes = ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type >() )
174         SAL_THROW( () );
175 
176     /** Called upon XTypeProvider::getTypes().
177 
178         @return type collection
179     */
getTypes()180     ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes() SAL_THROW( () )
181         { return _aTypes; }
182 };
183 
184 /** Helper class to implement ::com::sun::star::lang::XTypeProvider.  Construct a static object
185     of this class for your UNO object's implementation id.
186 */
187 class CPPUHELPER_DLLPUBLIC OImplementationId
188 {
189     /** @internal */
190     mutable ::com::sun::star::uno::Sequence< sal_Int8 > * _pSeq;
191     /** @internal */
192     sal_Bool _bUseEthernetAddress;
193 
194 public:
195     // these are here to force memory de/allocation to sal lib.
196     /** @internal */
operator new(size_t nSize)197     inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
198         { return ::rtl_allocateMemory( nSize ); }
199     /** @internal */
operator delete(void * pMem)200     inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
201         { ::rtl_freeMemory( pMem ); }
202     /** @internal */
operator new(size_t,void * pMem)203     inline static void * SAL_CALL operator new( size_t, void * pMem ) SAL_THROW( () )
204         { return pMem; }
205     /** @internal */
operator delete(void *,void *)206     inline static void SAL_CALL operator delete( void *, void * ) SAL_THROW( () )
207         {}
208 
209     /** @internal */
210     ~OImplementationId() SAL_THROW( () );
211     /** Constructor.
212 
213         @param bUseEthernetAddress whether an ethernet mac address should be taken into account
214     */
215     inline OImplementationId( sal_Bool bUseEthernetAddress = sal_True ) SAL_THROW( () )
216         : _pSeq( 0 )
217         , _bUseEthernetAddress( bUseEthernetAddress )
218         {}
219     /** Constructor giving implementation id.
220 
221         @param rSeq implementation id
222     */
223     inline OImplementationId( const ::com::sun::star::uno::Sequence< sal_Int8 > & rSeq ) SAL_THROW( () )
224         : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rSeq ) )
225         {}
226     inline OImplementationId( const OImplementationId & rId ) SAL_THROW( () )
227         : _pSeq( new ::com::sun::star::uno::Sequence< sal_Int8 >( rId.getImplementationId() ) )
228         {}
229 
230     /** Called upon XTypeProvider::getImplementationId().
231 
232         @return implementation id
233     */
234     ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() const SAL_THROW( () );
235 };
236 
237 }
238 
239 #endif
240