LCOV - code coverage report
Current view: top level - configmgr/source - nodemap.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 12 15 80.0 %
Date: 2015-06-13 12:38:46 Functions: 12 15 80.0 %
Legend: Lines: hit not hit

          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_CONFIGMGR_SOURCE_NODEMAP_HXX
      21             : #define INCLUDED_CONFIGMGR_SOURCE_NODEMAP_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : #include "config_map.hxx"
      25             : #include <rtl/ref.hxx>
      26             : #include <node.hxx>
      27             : 
      28             : namespace configmgr {
      29             : 
      30             : typedef config_map< rtl::Reference< Node > > NodeMapImpl;
      31             : class NodeMap
      32             : {
      33             :     NodeMapImpl maImpl;
      34             : 
      35             :     NodeMap(const NodeMap &rMap) :
      36             :         maImpl(rMap.maImpl) { clearCache(); }
      37             : 
      38             :   public:
      39             :     typedef NodeMapImpl::iterator iterator;
      40             :     typedef NodeMapImpl::const_iterator const_iterator;
      41             :     typedef NodeMapImpl::value_type value_type;
      42             : 
      43     4167726 :      NodeMap() { clearCache(); }
      44     4135672 :     ~NodeMap() {}
      45           0 :     bool empty() const { return maImpl.empty(); }
      46     9979543 :     iterator find(const OUString &aStr) { return maImpl.find( aStr ); }
      47             : 
      48   145445161 :     const_iterator find(const OUString &aStr) const { return maImpl.find( aStr ); }
      49       12721 :     iterator begin() { return maImpl.begin(); }
      50    27061070 :     const_iterator begin() const { return maImpl.begin(); }
      51             : 
      52    11698519 :     iterator end() { return maImpl.end(); }
      53   177479697 :     const_iterator end() const { return maImpl.end(); }
      54             : 
      55     1954118 :     rtl::Reference<Node> &operator[](const OUString &aStr) { clearCache(); return maImpl[aStr]; }
      56     2444750 :     std::pair<iterator,bool> insert(const value_type &vt) { clearCache(); return maImpl.insert(vt); }
      57           0 :     void clear() { maImpl.clear(); clearCache(); }
      58        1359 :     void erase(const iterator &it) { maImpl.erase(it); clearCache(); }
      59           0 :     void erase(const OUString &aStr) { maImpl.erase(aStr); clearCache(); }
      60             : 
      61             :     rtl::Reference< Node > findNode(int layer, OUString const & name) const;
      62             :     void cloneInto(NodeMap * target) const;
      63             : 
      64             : private:
      65             :     // We get a large number of repeated identical lookups.
      66             :     mutable const_iterator maCache;
      67    12411679 :     void clearCache() { maCache = maImpl.end(); }
      68             : };
      69             : 
      70             : }
      71             : 
      72             : #endif
      73             : 
      74             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11