diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 00a816ebd5..4b48f39aad 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -2614,6 +2614,37 @@ TempoMap::dump (std::ostream& ostr) const ostr << "------------\n\n\n"; } +Points::size_type +TempoMap::count_tempos_in_points () const +{ + Points::size_type n = 0; + + for (Points::const_iterator p = _points.begin(); p != _points.end(); ++p) { + if (dynamic_cast (&(*p))) { + /* ignore */ + } else if (dynamic_cast (&(*p))) { + ++n; + } + } + return n; +} + +Points::size_type +TempoMap::count_meters_in_points () const +{ + Points::size_type n = 0; + + for (Points::const_iterator p = _points.begin(); p != _points.end(); ++p) { + if (dynamic_cast (&(*p))) { + /* ignore */ + } else if (dynamic_cast (&(*p))) { + ++n; + } + } + return n; +} + + template typename const_traits_t::iterator_type TempoMap::_get_tempo_and_meter (typename const_traits_t::tempo_point_type & tp, typename const_traits_t::meter_point_type & mp, diff --git a/libs/temporal/temporal/tempo.h b/libs/temporal/temporal/tempo.h index 738dda4392..8858e8d09c 100644 --- a/libs/temporal/temporal/tempo.h +++ b/libs/temporal/temporal/tempo.h @@ -741,6 +741,10 @@ class /*LIBTEMPORAL_API*/ TempoMap : public PBD::StatefulDestructible static thread_local SharedPtr _tempo_map_p; static SerializedRCUManager _map_mgr; static bool fetch_condition (); + public: + /* These are only for use in unit tests */ + Points::size_type count_tempos_in_points() const; + Points::size_type count_meters_in_points() const; public: LIBTEMPORAL_API static void init (); diff --git a/libs/temporal/test/TempoMapTest.cc b/libs/temporal/test/TempoMapTest.cc index 3d36c71c94..98ff4467bc 100644 --- a/libs/temporal/test/TempoMapTest.cc +++ b/libs/temporal/test/TempoMapTest.cc @@ -50,6 +50,8 @@ TempoMapTest::addRemoveTest() tmap->dump (std::cout); CPPUNIT_ASSERT (tmap->tempo_at (BBT_Argument (8, 1, 0)).note_types_per_minute() == Tempo (64, 4).note_types_per_minute()); + CPPUNIT_ASSERT (tmap->count_tempos_in_points () == 3); + CPPUNIT_ASSERT (tmap->count_meters_in_points () == 3); tmap->abort_update (); }