From: Joel Holdsworth Date: Sat, 13 Jun 2015 09:46:39 +0000 (+0100) Subject: RowItemOwner: Added list_by_type X-Git-Tag: pulseview-0.3.0~181 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6046c19df08472d69aa06216136ea7fafaf25492;p=pulseview.git RowItemOwner: Added list_by_type --- diff --git a/pv/view/rowitemowner.cpp b/pv/view/rowitemowner.cpp index ba2e1f48..49e6e1a5 100644 --- a/pv/view/rowitemowner.cpp +++ b/pv/view/rowitemowner.cpp @@ -22,7 +22,9 @@ #include "rowitem.hpp" #include "rowitemowner.hpp" +#include "trace.hpp" +using std::dynamic_pointer_cast; using std::max; using std::make_pair; using std::min; @@ -101,6 +103,21 @@ set< RowItemOwner* > RowItemOwner::list_row_item_owners() return owners; } +template +set< shared_ptr > RowItemOwner::list_by_type() +{ + set< shared_ptr > items; + for (const auto &r : *this) { + shared_ptr p = dynamic_pointer_cast(r); + if (p) + items.insert(p); + } + + return items; +} + +template set< shared_ptr > RowItemOwner::list_by_type(); + pair RowItemOwner::v_extents() const { pair extents(INT_MAX, INT_MIN); diff --git a/pv/view/rowitemowner.hpp b/pv/view/rowitemowner.hpp index d72dddb2..f64b2592 100644 --- a/pv/view/rowitemowner.hpp +++ b/pv/view/rowitemowner.hpp @@ -124,6 +124,12 @@ public: */ std::set< RowItemOwner* > list_row_item_owners(); + /** + * Creates a list of decendant signals filtered by type. + */ + template + std::set< std::shared_ptr > list_by_type(); + /** * Computes the vertical extents of the contents of this row item owner. * @return A pair containing the minimum and maximum y-values.