twa: implement a copy_named_properties_of() method
It was noted in #470 that make_twa_graph did not copy named properties. Let's fix that. * spot/twa/twa.hh, spot/twa/twa.cc (copy_named_properties_of): New method. * spot/twa/twagraph.hh (make_twa_graph): Add an extra argument to call copy_named_properties_of() optionally. * python/spot/__init__.py (twa_graph.__copy__): Use it. * tests/python/twagraph.py: Test that. * tests/sanity/namedprop.test: Ensure copy_named_properties_of copies all known named properties.
This commit is contained in:
parent
0cf2d285b6
commit
31a681c285
6 changed files with 70 additions and 10 deletions
|
|
@ -290,6 +290,29 @@ namespace spot
|
|||
bddaps_ = bdd_exist(bddaps_, bdd_ithvar(b));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
twa::copy_named_properties_of(const const_twa_ptr& a)
|
||||
{
|
||||
#define COPY_PROP(type, name) \
|
||||
if (auto* prop = a->get_named_prop<type>(name)) \
|
||||
set_named_prop(name, new type(*prop));
|
||||
COPY_PROP(std::string, "accepted-word");
|
||||
COPY_PROP(std::string, "automaton-name");
|
||||
COPY_PROP(std::vector<unsigned>, "degen-levels");
|
||||
typedef std::map<unsigned, unsigned> hlmap;
|
||||
COPY_PROP(hlmap, "highlight-edges");
|
||||
COPY_PROP(hlmap, "highlight-states");
|
||||
COPY_PROP(std::set<unsigned>, "incomplete-states");
|
||||
COPY_PROP(std::vector<unsigned>, "original-clauses");
|
||||
COPY_PROP(std::vector<unsigned>, "original-states");
|
||||
COPY_PROP(spot::product_states, "product-states");
|
||||
COPY_PROP(std::string, "rejected-word");
|
||||
COPY_PROP(std::vector<unsigned>, "simulated-states");
|
||||
COPY_PROP(std::vector<std::string>, "state-names");
|
||||
COPY_PROP(std::vector<bool>, "state-player");
|
||||
COPY_PROP(std::vector<bool>, "state-winner");
|
||||
COPY_PROP(std::vector<unsigned>, "strategy");
|
||||
COPY_PROP(bdd, "synthesis-outputs");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// -*- coding: utf-8 -*-
|
||||
// Copyright (C) 2009, 2011, 2013-2020 Laboratoire de Recherche et
|
||||
// Copyright (C) 2009, 2011, 2013-2021 Laboratoire de Recherche et
|
||||
// Développement de l'Epita (LRDE).
|
||||
// Copyright (C) 2003-2005 Laboratoire d'Informatique de Paris 6
|
||||
// (LIP6), département Systèmes Répartis Coopératifs (SRC), Université
|
||||
|
|
@ -972,6 +972,9 @@ namespace spot
|
|||
this->register_ap(f);
|
||||
}
|
||||
|
||||
/// Copy all the named properties of \a a into this automaton.
|
||||
void copy_named_properties_of(const const_twa_ptr& a);
|
||||
|
||||
/// \brief Set generalized Büchi acceptance
|
||||
///
|
||||
/// \param num the number of acceptance sets to use
|
||||
|
|
|
|||
|
|
@ -773,11 +773,19 @@ namespace spot
|
|||
}
|
||||
|
||||
/// \ingroup twa_representation
|
||||
/// \brief Build an explicit automaton from all states of \a aut,
|
||||
/// \brief Clone a twa_graph
|
||||
///
|
||||
/// The \a p and \a preserve_name_properties argument are used to
|
||||
/// select what automata properties should be preserved by the copy.
|
||||
///
|
||||
inline twa_graph_ptr make_twa_graph(const const_twa_graph_ptr& aut,
|
||||
twa::prop_set p)
|
||||
twa::prop_set p,
|
||||
bool preserve_name_properties = false)
|
||||
{
|
||||
return SPOT_make_shared_enabled__(twa_graph, aut, p);
|
||||
twa_graph_ptr res = SPOT_make_shared_enabled__(twa_graph, aut, p);
|
||||
if (preserve_name_properties)
|
||||
res->copy_named_properties_of(aut);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// \ingroup twa_representation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue