xref: /trunk/main/cppuhelper/source/typeprovider.cxx (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 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cppuhelper.hxx"
30 
31 #include <cppuhelper/typeprovider.hxx>
32 #include <osl/mutex.hxx>
33 
34 using namespace osl;
35 using namespace com::sun::star::uno;
36 
37 namespace cppu
38 {
39 
40 //__________________________________________________________________________________________________
41 OImplementationId::~OImplementationId() SAL_THROW( () )
42 {
43     delete _pSeq;
44 }
45 //__________________________________________________________________________________________________
46 Sequence< sal_Int8 > OImplementationId::getImplementationId() const SAL_THROW( () )
47 {
48     if (! _pSeq)
49     {
50         MutexGuard aGuard( Mutex::getGlobalMutex() );
51         if (! _pSeq)
52         {
53             Sequence< sal_Int8 > * pSeq = new Sequence< sal_Int8 >( 16 );
54             ::rtl_createUuid( (sal_uInt8 *)pSeq->getArray(), 0, _bUseEthernetAddress );
55             _pSeq = pSeq;
56         }
57     }
58     return *_pSeq;
59 }
60 
61 //--------------------------------------------------------------------------------------------------
62 static inline void copy( Sequence< Type > & rDest, const Sequence< Type > & rSource, sal_Int32 nOffset )
63     SAL_THROW( () )
64 {
65     Type * pDest = rDest.getArray();
66     const Type * pSource = rSource.getConstArray();
67 
68     for ( sal_Int32 nPos = rSource.getLength(); nPos--; )
69         pDest[nOffset+ nPos] = pSource[nPos];
70 }
71 
72 //__________________________________________________________________________________________________
73 OTypeCollection::OTypeCollection(
74     const Type & rType1,
75     const Sequence< Type > & rAddTypes )
76     SAL_THROW( () )
77     : _aTypes( 1 + rAddTypes.getLength() )
78 {
79     _aTypes[0] = rType1;
80     copy( _aTypes, rAddTypes, 1 );
81 }
82 //__________________________________________________________________________________________________
83 OTypeCollection::OTypeCollection(
84     const Type & rType1,
85     const Type & rType2,
86     const Sequence< Type > & rAddTypes )
87     SAL_THROW( () )
88     : _aTypes( 2 + rAddTypes.getLength() )
89 {
90     _aTypes[0] = rType1;
91     _aTypes[1] = rType2;
92     copy( _aTypes, rAddTypes, 2 );
93 }
94 //__________________________________________________________________________________________________
95 OTypeCollection::OTypeCollection(
96     const Type & rType1,
97     const Type & rType2,
98     const Type & rType3,
99     const Sequence< Type > & rAddTypes )
100     SAL_THROW( () )
101     : _aTypes( 3 + rAddTypes.getLength() )
102 {
103     _aTypes[0] = rType1;
104     _aTypes[1] = rType2;
105     _aTypes[2] = rType3;
106     copy( _aTypes, rAddTypes, 3 );
107 }
108 //__________________________________________________________________________________________________
109 OTypeCollection::OTypeCollection(
110     const Type & rType1,
111     const Type & rType2,
112     const Type & rType3,
113     const Type & rType4,
114     const Sequence< Type > & rAddTypes )
115     SAL_THROW( () )
116     : _aTypes( 4 + rAddTypes.getLength() )
117 {
118     _aTypes[0] = rType1;
119     _aTypes[1] = rType2;
120     _aTypes[2] = rType3;
121     _aTypes[3] = rType4;
122     copy( _aTypes, rAddTypes, 4 );
123 }
124 //__________________________________________________________________________________________________
125 OTypeCollection::OTypeCollection(
126     const Type & rType1,
127     const Type & rType2,
128     const Type & rType3,
129     const Type & rType4,
130     const Type & rType5,
131     const Sequence< Type > & rAddTypes )
132     SAL_THROW( () )
133     : _aTypes( 5 + rAddTypes.getLength() )
134 {
135     _aTypes[0] = rType1;
136     _aTypes[1] = rType2;
137     _aTypes[2] = rType3;
138     _aTypes[3] = rType4;
139     _aTypes[4] = rType5;
140     copy( _aTypes, rAddTypes, 5 );
141 }
142 //__________________________________________________________________________________________________
143 OTypeCollection::OTypeCollection(
144     const Type & rType1,
145     const Type & rType2,
146     const Type & rType3,
147     const Type & rType4,
148     const Type & rType5,
149     const Type & rType6,
150     const Sequence< Type > & rAddTypes )
151     SAL_THROW( () )
152     : _aTypes( 6 + rAddTypes.getLength() )
153 {
154     _aTypes[0] = rType1;
155     _aTypes[1] = rType2;
156     _aTypes[2] = rType3;
157     _aTypes[3] = rType4;
158     _aTypes[4] = rType5;
159     _aTypes[5] = rType6;
160     copy( _aTypes, rAddTypes, 6 );
161 }
162 //__________________________________________________________________________________________________
163 OTypeCollection::OTypeCollection(
164     const Type & rType1,
165     const Type & rType2,
166     const Type & rType3,
167     const Type & rType4,
168     const Type & rType5,
169     const Type & rType6,
170     const Type & rType7,
171     const Sequence< Type > & rAddTypes )
172     SAL_THROW( () )
173     : _aTypes( 7 + rAddTypes.getLength() )
174 {
175     _aTypes[0] = rType1;
176     _aTypes[1] = rType2;
177     _aTypes[2] = rType3;
178     _aTypes[3] = rType4;
179     _aTypes[4] = rType5;
180     _aTypes[5] = rType6;
181     _aTypes[6] = rType7;
182     copy( _aTypes, rAddTypes, 7 );
183 }
184 //__________________________________________________________________________________________________
185 OTypeCollection::OTypeCollection(
186     const Type & rType1,
187     const Type & rType2,
188     const Type & rType3,
189     const Type & rType4,
190     const Type & rType5,
191     const Type & rType6,
192     const Type & rType7,
193     const Type & rType8,
194     const Sequence< Type > & rAddTypes )
195     SAL_THROW( () )
196     : _aTypes( 8 + rAddTypes.getLength() )
197 {
198     _aTypes[0] = rType1;
199     _aTypes[1] = rType2;
200     _aTypes[2] = rType3;
201     _aTypes[3] = rType4;
202     _aTypes[4] = rType5;
203     _aTypes[5] = rType6;
204     _aTypes[6] = rType7;
205     _aTypes[7] = rType8;
206     copy( _aTypes, rAddTypes, 8 );
207 }
208 //__________________________________________________________________________________________________
209 OTypeCollection::OTypeCollection(
210     const Type & rType1,
211     const Type & rType2,
212     const Type & rType3,
213     const Type & rType4,
214     const Type & rType5,
215     const Type & rType6,
216     const Type & rType7,
217     const Type & rType8,
218     const Type & rType9,
219     const Sequence< Type > & rAddTypes )
220     SAL_THROW( () )
221     : _aTypes( 9 + rAddTypes.getLength() )
222 {
223     _aTypes[0] = rType1;
224     _aTypes[1] = rType2;
225     _aTypes[2] = rType3;
226     _aTypes[3] = rType4;
227     _aTypes[4] = rType5;
228     _aTypes[5] = rType6;
229     _aTypes[6] = rType7;
230     _aTypes[7] = rType8;
231     _aTypes[8] = rType9;
232     copy( _aTypes, rAddTypes, 9 );
233 }
234 //__________________________________________________________________________________________________
235 OTypeCollection::OTypeCollection(
236     const Type & rType1,
237     const Type & rType2,
238     const Type & rType3,
239     const Type & rType4,
240     const Type & rType5,
241     const Type & rType6,
242     const Type & rType7,
243     const Type & rType8,
244     const Type & rType9,
245     const Type & rType10,
246     const Sequence< Type > & rAddTypes )
247     SAL_THROW( () )
248     : _aTypes( 10 + rAddTypes.getLength() )
249 {
250     _aTypes[0] = rType1;
251     _aTypes[1] = rType2;
252     _aTypes[2] = rType3;
253     _aTypes[3] = rType4;
254     _aTypes[4] = rType5;
255     _aTypes[5] = rType6;
256     _aTypes[6] = rType7;
257     _aTypes[7] = rType8;
258     _aTypes[8] = rType9;
259     _aTypes[9] = rType10;
260     copy( _aTypes, rAddTypes, 10 );
261 }
262 //__________________________________________________________________________________________________
263 OTypeCollection::OTypeCollection(
264     const Type & rType1,
265     const Type & rType2,
266     const Type & rType3,
267     const Type & rType4,
268     const Type & rType5,
269     const Type & rType6,
270     const Type & rType7,
271     const Type & rType8,
272     const Type & rType9,
273     const Type & rType10,
274     const Type & rType11,
275     const Sequence< Type > & rAddTypes )
276     SAL_THROW( () )
277     : _aTypes( 11 + rAddTypes.getLength() )
278 {
279     _aTypes[0] = rType1;
280     _aTypes[1] = rType2;
281     _aTypes[2] = rType3;
282     _aTypes[3] = rType4;
283     _aTypes[4] = rType5;
284     _aTypes[5] = rType6;
285     _aTypes[6] = rType7;
286     _aTypes[7] = rType8;
287     _aTypes[8] = rType9;
288     _aTypes[9] = rType10;
289     _aTypes[10] = rType11;
290     copy( _aTypes, rAddTypes, 11 );
291 }
292 //__________________________________________________________________________________________________
293 OTypeCollection::OTypeCollection(
294     const Type & rType1,
295     const Type & rType2,
296     const Type & rType3,
297     const Type & rType4,
298     const Type & rType5,
299     const Type & rType6,
300     const Type & rType7,
301     const Type & rType8,
302     const Type & rType9,
303     const Type & rType10,
304     const Type & rType11,
305     const Type & rType12,
306     const Sequence< Type > & rAddTypes )
307     SAL_THROW( () )
308     : _aTypes( 12 + rAddTypes.getLength() )
309 {
310     _aTypes[0] = rType1;
311     _aTypes[1] = rType2;
312     _aTypes[2] = rType3;
313     _aTypes[3] = rType4;
314     _aTypes[4] = rType5;
315     _aTypes[5] = rType6;
316     _aTypes[6] = rType7;
317     _aTypes[7] = rType8;
318     _aTypes[8] = rType9;
319     _aTypes[9] = rType10;
320     _aTypes[10] = rType11;
321     _aTypes[11] = rType12;
322     copy( _aTypes, rAddTypes, 12 );
323 }
324 
325 }
326 
327