LCOV - code coverage report
Current view: top level - src/engraving/dom - spannermap.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 6 6
Test Date: 2026-11-05 04:07:02

            Line data    Source code
       1              : /*
       2              :  * SPDX-License-Identifier: GPL-3.0-only
       3              :  * MuseScore-Studio-CLA-applies
       4              :  *
       5              :  * MuseScore Studio
       6              :  * Music Composition & Notation
       7              :  *
       8              :  * Copyright (C) 2021 MuseScore Limited and others
       9              :  *
      10              :  * This program is free software: you can redistribute it and/or modify
      11              :  * it under the terms of the GNU General Public License version 3 as
      12              :  * published by the Free Software Foundation.
      13              :  *
      14              :  * This program is distributed in the hope that it will be useful,
      15              :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16              :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      17              :  * GNU General Public License for more details.
      18              :  *
      19              :  * You should have received a copy of the GNU General Public License
      20              :  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
      21              :  */
      22              : 
      23              : #ifndef MU_ENGRAVING_SPANNERMAP_H
      24              : #define MU_ENGRAVING_SPANNERMAP_H
      25              : 
      26              : #include <map>
      27              : 
      28              : #include "engraving/thirdparty/intervaltree/IntervalTree.h"
      29              : 
      30              : namespace mu::engraving {
      31              : class Spanner;
      32              : 
      33              : //---------------------------------------------------------
      34              : //   SpannerMap
      35              : //---------------------------------------------------------
      36              : 
      37              : class SpannerMap : std::multimap<int, Spanner*>
      38              : {
      39              : public:
      40              :     typedef typename std::multimap<int, Spanner*>::const_reverse_iterator const_reverse_it;
      41              :     typedef typename std::multimap<int, Spanner*>::const_iterator const_it;
      42              : 
      43              :     using IntervalList = std::vector<interval_tree::Interval<Spanner*> >;
      44              : 
      45              :     SpannerMap();
      46              : 
      47              :     const IntervalList& findContained(int start, int stop, bool excludeCollisions = false) const;
      48              :     const IntervalList& findOverlapping(int start, int stop, bool excludeCollisions = false) const;
      49        60719 :     const std::multimap<int, Spanner*>& map() const { return *this; }
      50              : 
      51              :     void collectIntervals(IntervalList& regularIntervals, IntervalList& collisionFreeIntervals) const;
      52              : 
      53              :     const_reverse_it crbegin() const { return std::multimap<int, Spanner*>::crbegin(); }
      54              :     const_reverse_it crend() const { return std::multimap<int, Spanner*>::crend(); }
      55           25 :     const_it cbegin() const { return std::multimap<int, Spanner*>::cbegin(); }
      56           43 :     const_it cend() const { return std::multimap<int, Spanner*>::cend(); }
      57              :     void addSpanner(Spanner* s);
      58              :     bool removeSpanner(Spanner* s);
      59         2095 :     void clear() { std::multimap<int, Spanner*>::clear(); m_dirty = true; }
      60         2790 :     bool empty() const { return std::multimap<int, Spanner*>::empty(); }
      61              :     void update() const;
      62         2959 :     void setDirty() const { m_dirty = true; }     // must be called if a spanner changes start/length
      63              : #ifndef NDEBUG
      64              :     void dump() const;
      65              : #endif
      66              : 
      67              : private:
      68              : 
      69              :     mutable bool m_dirty = false;
      70              :     mutable interval_tree::IntervalTree<Spanner*> m_tree;
      71              :     mutable interval_tree::IntervalTree<Spanner*> m_collisionFreeTree;
      72              :     mutable std::vector<interval_tree::Interval<Spanner*> > m_results;
      73              : };
      74              : } // namespace mu::engraving
      75              : 
      76              : #endif
        

Generated by: LCOV version 2.0-1