]> sigrok.org Git - pulseview.git/commitdiff
RowItemOwner: Added list_by_type
authorJoel Holdsworth <redacted>
Sat, 13 Jun 2015 09:46:39 +0000 (10:46 +0100)
committerUwe Hermann <redacted>
Tue, 30 Jun 2015 09:23:21 +0000 (11:23 +0200)
pv/view/rowitemowner.cpp
pv/view/rowitemowner.hpp

index ba2e1f4838ab44874b831b7ad06d9b79c12dd70c..49e6e1a59afca5b796252f44c26e93b90450b2c1 100644 (file)
@@ -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<class T>
+set< shared_ptr<T> > RowItemOwner::list_by_type()
+{
+       set< shared_ptr<T> > items;
+       for (const auto &r : *this) {
+               shared_ptr<T> p = dynamic_pointer_cast<T>(r);
+               if (p)
+                       items.insert(p);
+       }
+
+       return items;
+}
+
+template set< shared_ptr<Trace> > RowItemOwner::list_by_type();
+
 pair<int, int> RowItemOwner::v_extents() const
 {
        pair<int, int> extents(INT_MAX, INT_MIN);
index d72dddb2f2300848ed9ed8ee2a3b772193fe1e60..f64b25920f3c06960436accccf8f4fbff5677a73 100644 (file)
@@ -124,6 +124,12 @@ public:
         */
        std::set< RowItemOwner* > list_row_item_owners();
 
+       /**
+        * Creates a list of decendant signals filtered by type.
+        */
+       template<class T>
+       std::set< std::shared_ptr<T> > 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.