diff --git a/NEWS b/NEWS index ab3a26455e1ed54c6a3e4b52840d6ca74ab6c622..2504817b0bfdfa8902acb756452fa0422613371f 100644 --- a/NEWS +++ b/NEWS @@ -143,6 +143,10 @@ New in spot 2.0.3a (not yet released) - {s[*0..j]}[]->b = {s[*1..j]}[]->b - {s[*0..j]}<>->b = {s[*1..j]}<>->b + * spot::twa::succ_iterable renamed to + spot::internal::twa_succ_iterable to make it clear this is not for + public consumption. + Python: * The __format__() method for formula supports the same diff --git a/spot/twa/twa.hh b/spot/twa/twa.hh index d5f06dbb952a0e1eb9926295b2212c02ebda3d10..cd73aa8ee4dc2b7f2f0580f8891b11db7ab8f705 100644 --- a/spot/twa/twa.hh +++ b/spot/twa/twa.hh @@ -515,6 +515,43 @@ namespace spot it_ = nullptr; } }; + +#ifndef SWIG + /// \brief Helper class to iterate over the successor of a state + /// using the on-the-fly interface + /// + /// This one emulates an STL-like container with begin()/end() + /// methods so that it can be iterated using a ranged-for. + class twa_succ_iterable + { + protected: + const twa* aut_; + twa_succ_iterator* it_; + public: + twa_succ_iterable(const twa* aut, twa_succ_iterator* it) + : aut_(aut), it_(it) + { + } + + twa_succ_iterable(twa_succ_iterable&& other) + : aut_(other.aut_), it_(other.it_) + { + other.it_ = nullptr; + } + + ~twa_succ_iterable(); // Defined in this file after twa + + internal::succ_iterator begin() + { + return it_->first() ? it_ : nullptr; + } + + internal::succ_iterator end() + { + return nullptr; + } + }; +#endif // SWIG } /// \defgroup twa TωA (Transition-based ω-Automata) @@ -591,47 +628,6 @@ namespace spot bdd_dict_ptr dict_; public: -#ifndef SWIG - /// \brief Helper class to iterate over the successor of a state - /// using the on-the-fly interface - /// - /// This one emulates an STL-like container with begin()/end() - /// methods so that it can be iterated using a ranged-for. - class succ_iterable - { - protected: - const twa* aut_; - twa_succ_iterator* it_; - public: - succ_iterable(const twa* aut, twa_succ_iterator* it) - : aut_(aut), it_(it) - { - } - - succ_iterable(succ_iterable&& other) - : aut_(other.aut_), it_(other.it_) - { - other.it_ = nullptr; - } - - ~succ_iterable() - { - if (it_) - aut_->release_iter(it_); - } - - internal::succ_iterator begin() - { - return it_->first() ? it_ : nullptr; - } - - internal::succ_iterator end() - { - return nullptr; - } - }; -#endif - virtual ~twa(); /// \brief Get the initial state of the automaton. @@ -675,12 +671,12 @@ namespace spot /// while (i->next()); /// aut->release_iter(i); /// \endcode - succ_iterable + internal::twa_succ_iterable succ(const state* s) const { return {this, succ_iter(s)}; } -#endif + #endif /// \brief Release an iterator after usage. /// @@ -1401,6 +1397,17 @@ namespace spot }; +#ifndef SWIG + namespace internal + { + inline twa_succ_iterable::~twa_succ_iterable() + { + if (it_) + aut_->release_iter(it_); + } + } +#endif // SWIG + /// \addtogroup twa_representation TωA representations /// \ingroup twa