LCOV - code coverage report
Current view: top level - rdbmaker/inc/codemaker - typemanager.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 28 28.6 %
Date: 2012-08-25 Functions: 3 16 18.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

           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                 :            : #include    <boost/unordered_map.hpp>
      20                 :            : 
      21                 :            : #ifndef _CODEMAKER_TYPEMANAGER_HXX_
      22                 :            : #define _CODEMAKER_TYPEMANAGER_HXX_
      23                 :            : #include    <codemaker/registry.hxx>
      24                 :            : 
      25                 :            : typedef ::std::list< Registry* >    RegistryList;
      26                 :            : 
      27                 :            : typedef ::boost::unordered_map
      28                 :            : <
      29                 :            :     ::rtl::OString, // Typename
      30                 :            :     RTTypeClass,    // TypeClass
      31                 :            :     HashString,
      32                 :            :     EqualString
      33                 :            : > T2TypeClassMap;
      34                 :            : 
      35                 :            : struct TypeManagerImpl
      36                 :            : {
      37                 :          4 :     TypeManagerImpl()
      38                 :          4 :         : m_refCount(0)
      39                 :          4 :         {}
      40                 :            : 
      41                 :            :     sal_Int32       m_refCount;
      42                 :            : };
      43                 :            : 
      44                 :            : class TypeManager
      45                 :            : {
      46                 :            : public:
      47                 :            :     TypeManager();
      48                 :            :     virtual ~TypeManager();
      49                 :            : 
      50                 :            :     TypeManager( const TypeManager& value )
      51                 :            :         : m_pImpl( value.m_pImpl )
      52                 :            :     {
      53                 :            :         acquire();
      54                 :            :     }
      55                 :            : 
      56                 :            :     TypeManager& operator = ( const TypeManager& value )
      57                 :            :     {
      58                 :            :         release();
      59                 :            :         m_pImpl = value.m_pImpl;
      60                 :            :         acquire();
      61                 :            :         return *this;
      62                 :            :     }
      63                 :            : 
      64                 :          0 :     virtual sal_Bool init(sal_Bool /*bMerge*/, const StringVector& /*regFiles*/)
      65                 :          0 :         { return sal_False; }
      66                 :          0 :     virtual sal_Bool init(const ::rtl::OString& /*registryName*/)
      67                 :          0 :         { return sal_False; }
      68                 :            : 
      69                 :          0 :     virtual sal_Bool isValidType(const ::rtl::OString& /*name*/)
      70                 :          0 :         { return sal_False; }
      71                 :            : 
      72                 :          0 :     virtual RegistryKey getTypeKey(const ::rtl::OString& /*name*/)
      73                 :          0 :         { return RegistryKey(); }
      74                 :          0 :     virtual TypeReader getTypeReader(const ::rtl::OString& /*name*/)
      75                 :          0 :         { return TypeReader(); }
      76                 :          0 :     virtual RTTypeClass getTypeClass(const ::rtl::OString& /*name*/)
      77                 :          0 :         { return RT_TYPE_INVALID; }
      78                 :            : 
      79                 :          0 :     virtual void setBase(const ::rtl::OString& /*base*/) {}
      80                 :          0 :     virtual ::rtl::OString getBase() { return ::rtl::OString(); }
      81                 :            : 
      82                 :          0 :     virtual sal_Int32 getSize() { return 0; }
      83                 :            : 
      84                 :            : protected:
      85                 :            :     sal_Int32 acquire();
      86                 :            :     sal_Int32 release();
      87                 :            : 
      88                 :            : protected:
      89                 :            :     TypeManagerImpl* m_pImpl;
      90                 :            : };
      91                 :            : 
      92                 :          0 : struct RegistryTypeManagerImpl
      93                 :            : {
      94                 :          4 :     RegistryTypeManagerImpl()
      95                 :            :         : m_pMergedRegistry(NULL)
      96                 :            :         , m_base("/")
      97 [ +  - ][ +  - ]:          4 :         , m_isMerged(sal_False)
      98                 :          4 :         {}
      99                 :            : 
     100                 :            :     T2TypeClassMap  m_t2TypeClass;
     101                 :            :     RegistryList    m_registries;
     102                 :            :     Registry*       m_pMergedRegistry;
     103                 :            :     ::rtl::OString  m_base;
     104                 :            :     sal_Bool        m_isMerged;
     105                 :            : };
     106                 :            : 
     107                 :            : class RegistryTypeManager : public TypeManager
     108                 :            : {
     109                 :            : public:
     110                 :            :     RegistryTypeManager();
     111                 :            :     virtual ~RegistryTypeManager();
     112                 :            : 
     113                 :            :     RegistryTypeManager( const RegistryTypeManager& value )
     114                 :            :         : TypeManager(value)
     115                 :            :         , m_pImpl( value.m_pImpl )
     116                 :            :     {
     117                 :            :         acquire();
     118                 :            :     }
     119                 :            : 
     120                 :            :     using TypeManager::init;
     121                 :            :     sal_Bool init(sal_Bool bMerge, const StringVector& regFiles);
     122                 :            : 
     123                 :       1312 :     sal_Bool    isValidType(const ::rtl::OString& name)
     124                 :       1312 :         { return searchTypeKey(name).isValid(); }
     125                 :          0 :     RegistryKey getTypeKey(const ::rtl::OString& name)
     126                 :          0 :         { return searchTypeKey(name); }
     127                 :            :     TypeReader  getTypeReader(const ::rtl::OString& name);
     128                 :            :     RTTypeClass getTypeClass(const ::rtl::OString& name);
     129                 :            : 
     130                 :            :     void setBase(const ::rtl::OString& base);
     131                 :          0 :     ::rtl::OString getBase() { return m_pImpl->m_base; }
     132                 :            : 
     133                 :          0 :     sal_Int32 getSize() { return m_pImpl->m_t2TypeClass.size(); }
     134                 :            : protected:
     135                 :            :     RegistryKey searchTypeKey(const ::rtl::OString& name);
     136                 :            :     void        freeRegistries();
     137                 :            : 
     138                 :            :     void acquire();
     139                 :            :     void release();
     140                 :            : 
     141                 :            : protected:
     142                 :            :     RegistryTypeManagerImpl* m_pImpl;
     143                 :            : };
     144                 :            : 
     145                 :            : #endif // _CODEMAKER_TYPEMANAGER_HXX_
     146                 :            : 
     147                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10