xref: /trunk/main/stoc/source/registry_tdprovider/tdconsts.cxx (revision 9d37da743abb7db0a497688391f6e55a19f27c44)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_stoc.hxx"
26 #include <osl/diagnose.h>
27 #include <rtl/ustrbuf.hxx>
28 #include "registry/reader.hxx"
29 #include "registry/version.h"
30 #include "base.hxx"
31 
32 namespace stoc_rdbtdp
33 {
34 
35 //__________________________________________________________________________________________________
36 // virtual
37 ConstantsTypeDescriptionImpl::~ConstantsTypeDescriptionImpl()
38 {
39     delete _pMembers;
40 
41     g_moduleCount.modCnt.release( &g_moduleCount.modCnt );
42 }
43 
44 // XTypeDescription
45 //__________________________________________________________________________________________________
46 // virtual
47 TypeClass ConstantsTypeDescriptionImpl::getTypeClass()
48 {
49     return TypeClass_CONSTANTS;
50 }
51 //__________________________________________________________________________________________________
52 // virtual
53 OUString ConstantsTypeDescriptionImpl::getName()
54 {
55     return _aName;
56 }
57 
58 // XConstantsTypeDescription
59 //__________________________________________________________________________________________________
60 // virtual
61 Sequence< Reference< XConstantTypeDescription > > SAL_CALL
62 ConstantsTypeDescriptionImpl::getConstants()
63 {
64     if ( !_pMembers )
65     {
66         typereg::Reader aReader(
67             _aBytes.getConstArray(), _aBytes.getLength(), false,
68             TYPEREG_VERSION_1);
69 
70         sal_uInt16 nFields = aReader.getFieldCount();
71         Sequence< Reference< XConstantTypeDescription > > * pTempConsts
72             = new Sequence< Reference< XConstantTypeDescription > >( nFields );
73         Reference< XConstantTypeDescription > * pConsts
74             = pTempConsts->getArray();
75 
76         while ( nFields-- )
77         {
78             rtl::OUStringBuffer aName( _aName );
79             aName.appendAscii( "." );
80             aName.append( aReader.getFieldName( nFields ) );
81 
82             Any aValue( getRTValue( aReader.getFieldValue( nFields ) ) );
83 
84             pConsts[ nFields ]
85                 = new ConstantTypeDescriptionImpl( aName.makeStringAndClear(),
86                                                    aValue );
87         }
88 
89         ClearableMutexGuard aGuard( getMutex() );
90         if ( _pMembers )
91         {
92             aGuard.clear();
93             delete pTempConsts;
94         }
95         else
96         {
97             _pMembers = pTempConsts;
98         }
99     }
100     return *_pMembers;
101 }
102 
103 }
104