LCOV - code coverage report
Current view: top level - rdbmaker/inc/codemaker - registry.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 70 76 92.1 %
Date: 2012-08-25 Functions: 25 27 92.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 20 36 55.6 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #ifndef _CODEMAKER_REGISTRY_HXX_
      21                 :            : #define _CODEMAKER_REGISTRY_HXX_
      22                 :            : 
      23                 :            : #include <rtl/alloc.h>
      24                 :            : #include <osl/interlck.h>
      25                 :            : #include    <registry/registry.hxx>
      26                 :            : #include "registry/reader.hxx"
      27                 :            : #include "registry/version.h"
      28                 :            : #include    <codemaker/options.hxx>
      29                 :            : 
      30                 :            : struct TypeReader_Impl
      31                 :            : {
      32                 :        444 :     TypeReader_Impl(const sal_uInt8* buffer,
      33                 :            :                        sal_uInt32 bufferLen,
      34                 :            :                        sal_Bool copyData)
      35                 :            :         : m_refCount(0)
      36                 :            :         , m_copyData(copyData)
      37                 :            :         , m_blopSize(bufferLen)
      38                 :        444 :         , m_pBlop(buffer)
      39                 :            :         {
      40         [ +  - ]:        444 :             if (copyData)
      41                 :            :             {
      42                 :        444 :                 m_pBlop = (sal_uInt8*)rtl_allocateMemory(bufferLen);
      43                 :        444 :                 rtl_copyMemory((void*)m_pBlop, buffer, bufferLen);
      44                 :            :             } else
      45                 :            :             {
      46                 :          0 :                 m_blopSize = bufferLen;
      47                 :          0 :                 m_pBlop = buffer;
      48                 :            :             }
      49                 :            : 
      50                 :            :             m_pReader = new typereg::Reader(
      51         [ +  - ]:        444 :                 m_pBlop, m_blopSize, false, TYPEREG_VERSION_1);
      52                 :        444 :         }
      53                 :            : 
      54                 :        444 :     ~TypeReader_Impl()
      55                 :            :         {
      56 [ +  - ][ +  - ]:        444 :             if (m_copyData && m_pReader)
      57                 :            :             {
      58         [ +  - ]:        444 :                 delete m_pReader;
      59                 :            :             }
      60                 :        444 :         }
      61                 :            : 
      62                 :            :     sal_Int32           m_refCount;
      63                 :            :     sal_Bool            m_copyData;
      64                 :            :     sal_Int32           m_blopSize;
      65                 :            :     const sal_uInt8*    m_pBlop;
      66                 :            :     typereg::Reader*    m_pReader;
      67                 :            : };
      68                 :            : 
      69                 :            : class TypeReader
      70                 :            : {
      71                 :            : public:
      72                 :        444 :     inline TypeReader()
      73                 :        444 :         : m_pImpl(NULL)
      74                 :        444 :     {}
      75                 :            : 
      76                 :        444 :     inline TypeReader(        const sal_uInt8* buffer,
      77                 :            :                               sal_uInt32 bufferLen,
      78                 :            :                               sal_Bool copyData)
      79                 :            :     {
      80         [ +  - ]:        444 :         m_pImpl = new TypeReader_Impl(buffer, bufferLen, copyData);
      81                 :        444 :         acquire();
      82                 :        444 :     }
      83                 :            : 
      84                 :            :     inline TypeReader(const TypeReader& toCopy)
      85                 :            :         : m_pImpl(toCopy.m_pImpl)
      86                 :            :     {
      87                 :            :         acquire();
      88                 :            :     }
      89                 :            : 
      90                 :        888 :     inline ~TypeReader()
      91                 :            :     {
      92                 :        888 :         release();
      93                 :        888 :     }
      94                 :            : 
      95                 :        888 :     inline void acquire()
      96                 :            :     {
      97         [ +  - ]:        888 :         if (m_pImpl)
      98                 :        888 :             osl_incrementInterlockedCount(&m_pImpl->m_refCount);
      99                 :        888 :     }
     100                 :            : 
     101                 :       1332 :     inline void release()
     102                 :            :     {
     103 [ +  + ][ +  + ]:       1332 :         if (m_pImpl && 0 == osl_decrementInterlockedCount(&m_pImpl->m_refCount))
                 [ +  + ]
     104                 :            :         {
     105         [ +  - ]:        444 :             delete m_pImpl;
     106                 :            :         }
     107                 :       1332 :     }
     108                 :            : 
     109                 :        444 :     inline TypeReader& operator = ( const TypeReader& value )
     110                 :            :     {
     111                 :        444 :         release();
     112                 :        444 :         m_pImpl = value.m_pImpl;
     113                 :        444 :         acquire();
     114                 :        444 :         return *this;
     115                 :            :     }
     116                 :            : 
     117                 :        444 :     inline sal_Bool         isValid() const
     118                 :            :         {
     119         [ +  - ]:        444 :             if (m_pImpl)
     120                 :        444 :                 return m_pImpl->m_pReader->isValid();
     121                 :            :             else
     122                 :        444 :                 return sal_False;
     123                 :            :         }
     124                 :            : 
     125                 :        264 :     inline RTTypeClass              getTypeClass() const
     126                 :        264 :         { return m_pImpl->m_pReader->getTypeClass(); }
     127                 :            :     inline const ::rtl::OString     getTypeName() const
     128                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getTypeName() ); }
     129                 :        360 :     inline sal_uInt16 getSuperTypeCount() const
     130                 :        360 :         { return m_pImpl->m_pReader->getSuperTypeCount(); }
     131                 :        166 :     inline const ::rtl::OString     getSuperTypeName(sal_uInt16 index) const
     132         [ +  - ]:        166 :         { return inGlobalSet( m_pImpl->m_pReader->getSuperTypeName(index) ); }
     133                 :            :     inline const ::rtl::OString     getDoku() const
     134                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getDocumentation() ); }
     135                 :            :     inline const ::rtl::OString     getFileName() const
     136                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getFileName() ); }
     137                 :        222 :     inline sal_uInt32               getFieldCount() const
     138                 :        222 :         { return m_pImpl->m_pReader->getFieldCount(); }
     139                 :            :     inline const ::rtl::OString     getFieldName( sal_uInt16 index ) const
     140                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getFieldName(index) ); }
     141                 :         74 :     inline const ::rtl::OString     getFieldType( sal_uInt16 index ) const
     142         [ +  - ]:         74 :         { return inGlobalSet( m_pImpl->m_pReader->getFieldTypeName(index) ); }
     143                 :         74 :     inline RTFieldAccess            getFieldAccess( sal_uInt16 index ) const
     144                 :         74 :         { return m_pImpl->m_pReader->getFieldFlags(index); }
     145                 :            :     inline RTConstValue             getFieldConstValue( sal_uInt16 index ) const
     146                 :            :         { return m_pImpl->m_pReader->getFieldValue(index); }
     147                 :            :     inline const ::rtl::OString     getFieldDoku( sal_uInt16 index ) const
     148                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getFieldDocumentation(index) ); }
     149                 :            :     inline const ::rtl::OString     getFieldFileName( sal_uInt16 index ) const
     150                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getFieldFileName(index) ); }
     151                 :        194 :     inline sal_uInt32               getMethodCount() const
     152                 :        194 :         { return m_pImpl->m_pReader->getMethodCount(); }
     153                 :            :     inline const ::rtl::OString     getMethodName( sal_uInt16 index ) const
     154                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getMethodName(index) ); }
     155                 :        354 :     inline sal_uInt32               getMethodParamCount( sal_uInt16 index ) const
     156                 :        354 :         { return m_pImpl->m_pReader->getMethodParameterCount(index); }
     157                 :        194 :     inline const ::rtl::OString     getMethodParamType( sal_uInt16 index, sal_uInt16 paramIndex ) const
     158         [ +  - ]:        194 :         { return inGlobalSet( m_pImpl->m_pReader->getMethodParameterTypeName(index,paramIndex) ); }
     159                 :            :     inline const ::rtl::OString     getMethodParamName( sal_uInt16 index, sal_uInt16 paramIndex ) const
     160                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getMethodParameterName(index,paramIndex) ); }
     161                 :        194 :     inline RTParamMode              getMethodParamMode( sal_uInt16 index, sal_uInt16 paramIndex ) const
     162                 :        194 :         { return m_pImpl->m_pReader->getMethodParameterFlags(index,paramIndex); }
     163                 :        354 :     inline sal_uInt32               getMethodExcCount( sal_uInt16 index ) const
     164                 :        354 :         { return m_pImpl->m_pReader->getMethodExceptionCount(index); }
     165                 :        172 :     inline const ::rtl::OString     getMethodExcType( sal_uInt16 index, sal_uInt16 excIndex ) const
     166         [ +  - ]:        172 :         { return inGlobalSet( m_pImpl->m_pReader->getMethodExceptionTypeName(index,excIndex) ); }
     167                 :        354 :     inline const ::rtl::OString     getMethodReturnType( sal_uInt16 index ) const
     168         [ +  - ]:        354 :         { return inGlobalSet( m_pImpl->m_pReader->getMethodReturnTypeName(index) ); }
     169                 :            :     inline RTMethodMode             getMethodMode( sal_uInt16 index ) const
     170                 :            :         { return m_pImpl->m_pReader->getMethodFlags(index); }
     171                 :            :     inline const ::rtl::OString     getMethodDoku( sal_uInt16 index ) const
     172                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getMethodDocumentation(index) ); }
     173                 :            : 
     174                 :        194 :     inline sal_uInt32               getReferenceCount() const
     175                 :        194 :         { return m_pImpl->m_pReader->getReferenceCount(); }
     176                 :          0 :     inline const ::rtl::OString     getReferenceName( sal_uInt16 index ) const
     177         [ #  # ]:          0 :         { return inGlobalSet( m_pImpl->m_pReader->getReferenceTypeName(index) ); }
     178                 :          0 :     inline RTReferenceType          getReferenceType( sal_uInt16 index ) const
     179                 :          0 :         { return m_pImpl->m_pReader->getReferenceSort(index); }
     180                 :            :     inline const ::rtl::OString     getReferenceDoku( sal_uInt16 index ) const
     181                 :            :         { return inGlobalSet( m_pImpl->m_pReader->getReferenceDocumentation(index) ); }
     182                 :            : 
     183                 :        222 :     inline sal_uInt32 getBlopSize() const
     184                 :        222 :         { return m_pImpl->m_blopSize; }
     185                 :            : 
     186                 :        222 :     inline const sal_uInt8* getBlop() const
     187                 :        222 :         { return m_pImpl->m_pBlop; }
     188                 :            : 
     189                 :            : private:
     190                 :            :     TypeReader_Impl* m_pImpl;
     191                 :            : };
     192                 :            : 
     193                 :            : 
     194                 :            : #endif // _CODEMAKER_REGISTRY_HXX_
     195                 :            : 
     196                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10