Skip to content

Commit

Permalink
Add C++ and Python support for iteration through components of a Comp…
Browse files Browse the repository at this point in the history
…ositeHybridAutomaton, resolve #643
  • Loading branch information
lgeretti committed Jul 22, 2021
1 parent 3a8ff08 commit 6d9e8e9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Legenda for the issue kind:
- [#628](https://github.com/ariadne-cps/ariadne/issues/628) (A) Implement some methods for Polynomial, in particular for vectors thereof
- [#636](https://github.com/ariadne-cps/ariadne/issues/636) (A) Add Python bindings for hybrid automaton target method
- [#642](https://github.com/ariadne-cps/ariadne/issues/642) (A) Add Python bindings for hybrid automaton name and symbolic expressions in dynamics/guards/invariants/resets
- [#643](https://github.com/ariadne-cps/ariadne/issues/643) (A) Add C++ and Python support for iteration through components of a CompositeHybridAutomaton
- [#612](https://github.com/ariadne-cps/ariadne/issues/612) (C) Remove unused legend from Gnuplot output
- [#639](https://github.com/ariadne-cps/ariadne/issues/639) (C) Use a finer (3/4) refinement strategy for the step size when computing a flow step based on an accuracy threshold
- [#616](https://github.com/ariadne-cps/ariadne/issues/616) (F) Fix behavior of unary symbolic expression predicates
Expand Down
2 changes: 1 addition & 1 deletion python/source/hybrid_submodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Void export_hybrid_automaton(pybind11::module& module)
composite_hybrid_automaton_class.def(pybind11::init<const List<HybridAutomaton>&>());
composite_hybrid_automaton_class.def(pybind11::init<Identifier,const List<HybridAutomaton>&>());
composite_hybrid_automaton_class.def("__repr__", &__cstr__<CompositeHybridAutomaton>);

composite_hybrid_automaton_class.def("__iter__", [](CompositeHybridAutomaton const& c){return pybind11::make_iterator(c.begin(),c.end());});
}


Expand Down
7 changes: 7 additions & 0 deletions source/hybrid/hybrid_automaton-composite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class CompositeHybridAutomaton
static Writer<CompositeHybridAutomaton> default_writer() { return _default_writer; }
public:
typedef HybridTime TimeType;
typedef List<HybridAutomaton>::ConstIterator ConstIterator;
public:
//!@{
//! \name Constructors.
Expand Down Expand Up @@ -107,6 +108,12 @@ class CompositeHybridAutomaton
Nat number_of_components() const;
//! \brief The \a i<sup>th</sup> component automaton.
const HybridAutomaton& component(Nat i) const;

//! \brief Iterator begin
ConstIterator begin() const { return _components.begin(); }
//! \brief Iterator end
ConstIterator end() const { return _components.end(); }

//!@}

//!@{
Expand Down

0 comments on commit 6d9e8e9

Please sign in to comment.