X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fviewitemowner.hpp;fp=pv%2Fview%2Fviewitemowner.hpp;h=60c8507626eaae243b12aba2b05c409609512be1;hp=0000000000000000000000000000000000000000;hb=c373f82810ad9c5376a7370118de9dd587ee0e43;hpb=21d5f19c7992046c7a1735096364138eb6de50cf diff --git a/pv/view/viewitemowner.hpp b/pv/view/viewitemowner.hpp new file mode 100644 index 00000000..60c85076 --- /dev/null +++ b/pv/view/viewitemowner.hpp @@ -0,0 +1,101 @@ +/* + * This file is part of the PulseView project. + * + * Copyright (C) 2014 Joel Holdsworth + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef PULSEVIEW_PV_VIEW_VIEWITEMOWNER_HPP +#define PULSEVIEW_PV_VIEW_VIEWITEMOWNER_HPP + +#include +#include + +#include "viewitemiterator.hpp" + +namespace pv { + +class Session; + +namespace view { + +class ViewItem; +class View; + +class ViewItemOwner +{ +public: + typedef std::vector< std::shared_ptr > item_list; + typedef ViewItemIterator iterator; + typedef ViewItemIterator const_iterator; + +public: + /** + * Returns a list of row items owned by this object. + */ + virtual item_list& child_items() = 0; + + /** + * Returns a list of row items owned by this object. + */ + virtual const item_list& child_items() const = 0; + + /** + * Returns a depth-first iterator at the beginning of the child ViewItem + * tree. + */ + iterator begin(); + + /** + * Returns a depth-first iterator at the end of the child ViewItem tree. + */ + iterator end(); + + /** + * Returns a constant depth-first iterator at the beginning of the + * child ViewItem tree. + */ + const_iterator begin() const; + + /** + * Returns a constant depth-first iterator at the end of the child + * ViewItem tree. + */ + const_iterator end() const; + + /** + * Creates a list of decendant signals filtered by type. + */ + template + std::vector< std::shared_ptr > list_by_type() { + std::vector< std::shared_ptr > items; + for (const auto &r : *this) { + std::shared_ptr p = std::dynamic_pointer_cast(r); + if (p) + items.push_back(p); + } + + return items; + } + +protected: + item_list items_; +}; + +} // view +} // pv + +#endif // PULSEVIEW_PV_VIEW_VIEWITEMOWNER_HPP