LCOV - code coverage report
Current view: top level - codemaker/inc/codemaker - dependencies.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 17 17 100.0 %
Date: 2012-08-25 Functions: 15 15 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 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                 :            : 
      20                 :            : #ifndef INCLUDED_CODEMAKER_DEPENDENCIES_HXX
      21                 :            : #define INCLUDED_CODEMAKER_DEPENDENCIES_HXX
      22                 :            : 
      23                 :            : #include "rtl/string.hxx"
      24                 :            : 
      25                 :            : #include <boost/unordered_map.hpp>
      26                 :            : 
      27                 :            : namespace rtl { class OUString; }
      28                 :            : class TypeManager;
      29                 :            : 
      30                 :            : /// @HTML
      31                 :            : 
      32                 :            : namespace codemaker {
      33                 :            : 
      34                 :            : /**
      35                 :            :    A simple class to track which other types a given type depends on.
      36                 :            : 
      37                 :            :    <p>This class is not multi-thread&ndash;safe.</p>
      38                 :            :  */
      39                 :            : class Dependencies {
      40                 :            : public:
      41                 :            :     /**
      42                 :            :        Flags to distinguish whether or not one type depends on another type
      43                 :            :        because the second is a direct base of the first.
      44                 :            :      */
      45                 :            :     enum Kind { KIND_NO_BASE, KIND_BASE };
      46                 :            : 
      47                 :            :     typedef boost::unordered_map< rtl::OString, Kind, rtl::OStringHash > Map;
      48                 :            : 
      49                 :            :     /**
      50                 :            :        Constructs the dependencies for a given type.
      51                 :            : 
      52                 :            :        <p>If the given type is not successfully available at the given type
      53                 :            :        manager, <code>isValid()</code> will return <code>false</code>.</p>
      54                 :            : 
      55                 :            :        @param manager a type manager, to obtain information about the given type
      56                 :            : 
      57                 :            :        @param type the UNO type registry name of an enum type, plain struct
      58                 :            :        type, polymorphic struct type template, exception type, interface type,
      59                 :            :        typedef, module, constant group, service, or singleton
      60                 :            :      */
      61                 :            :     Dependencies(TypeManager const & manager, rtl::OString const & type);
      62                 :            : 
      63                 :            :     ~Dependencies();
      64                 :            : 
      65                 :            :     /**
      66                 :            :        Add a special dependency (which is not obvious from the type's data
      67                 :            :        available at the type manager).
      68                 :            : 
      69                 :            :        @param type a UNO type registry name
      70                 :            :      */
      71                 :       7832 :     void add(rtl::OString const & type) { insert(type, false); }
      72                 :            : 
      73                 :      15512 :     bool isValid() const { return m_valid; }
      74                 :            : 
      75                 :      42128 :     Map const & getMap() const { return m_map; }
      76                 :            : 
      77                 :            :     bool hasVoidDependency() const { return m_voidDependency; }
      78                 :            : 
      79                 :      29700 :     bool hasBooleanDependency() const { return m_booleanDependency; }
      80                 :            : 
      81                 :      24950 :     bool hasByteDependency() const { return m_byteDependency; }
      82                 :            : 
      83                 :      24098 :     bool hasShortDependency() const { return m_shortDependency; }
      84                 :            : 
      85                 :      35810 :     bool hasUnsignedShortDependency() const
      86                 :      35810 :     { return m_unsignedShortDependency; }
      87                 :            : 
      88                 :      21438 :     bool hasLongDependency() const { return m_longDependency; }
      89                 :            : 
      90                 :            :     bool hasUnsignedLongDependency() const { return m_unsignedLongDependency; }
      91                 :            : 
      92                 :      14308 :     bool hasHyperDependency() const { return m_hyperDependency; }
      93                 :            : 
      94                 :      14216 :     bool hasUnsignedHyperDependency() const
      95                 :      14216 :     { return m_unsignedHyperDependency; }
      96                 :            : 
      97                 :            :     bool hasFloatDependency() const { return m_floatDependency; }
      98                 :            : 
      99                 :            :     bool hasDoubleDependency() const { return m_doubleDependency; }
     100                 :            : 
     101                 :      14208 :     bool hasCharDependency() const { return m_charDependency; }
     102                 :            : 
     103                 :      29700 :     bool hasStringDependency() const { return m_stringDependency; }
     104                 :            : 
     105                 :      29700 :     bool hasTypeDependency() const { return m_typeDependency; }
     106                 :            : 
     107                 :      29700 :     bool hasAnyDependency() const { return m_anyDependency; }
     108                 :            : 
     109                 :      29700 :     bool hasSequenceDependency() const { return m_sequenceDependency; }
     110                 :            : 
     111                 :            : private:
     112                 :            :     Dependencies(Dependencies &); // not implemented
     113                 :            :     void operator =(Dependencies); // not implemented
     114                 :            : 
     115                 :            :     void insert(rtl::OUString const & type, bool base);
     116                 :            : 
     117                 :            :     void insert(rtl::OString const & type, bool base);
     118                 :            : 
     119                 :            :     Map m_map;
     120                 :            :     bool m_valid;
     121                 :            :     bool m_voidDependency;
     122                 :            :     bool m_booleanDependency;
     123                 :            :     bool m_byteDependency;
     124                 :            :     bool m_shortDependency;
     125                 :            :     bool m_unsignedShortDependency;
     126                 :            :     bool m_longDependency;
     127                 :            :     bool m_unsignedLongDependency;
     128                 :            :     bool m_hyperDependency;
     129                 :            :     bool m_unsignedHyperDependency;
     130                 :            :     bool m_floatDependency;
     131                 :            :     bool m_doubleDependency;
     132                 :            :     bool m_charDependency;
     133                 :            :     bool m_stringDependency;
     134                 :            :     bool m_typeDependency;
     135                 :            :     bool m_anyDependency;
     136                 :            :     bool m_sequenceDependency;
     137                 :            : };
     138                 :            : 
     139                 :            : }
     140                 :            : 
     141                 :            : #endif // INCLUDED_CODEMAKER_DEPENDENCIES_HXX
     142                 :            : 
     143                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10