tgba: simplify usage of named properties

* src/tgba/tgba.hh, src/tgba/tgba.cc (set_named_prop): Add a template
version.
(get_named_prop): Hide the old version, and supply a template version
that casts.
* src/bin/ltlcross.cc, src/hoaparse/hoaparse.yy, src/tgbaalgos/hoa.cc,
src/tgbaalgos/product.cc: Adjust usage.
This commit is contained in:
Alexandre Duret-Lutz 2014-12-09 16:20:12 +01:00
parent 5a1e38d90f
commit 61edf7f41d
6 changed files with 23 additions and 12 deletions

View file

@ -665,12 +665,28 @@ namespace spot
std::pair<void*,
std::function<void(void*)>>> named_prop_;
#endif
void* get_named_prop_(std::string s) const;
public:
#ifndef SWIG
void set_named_prop(std::string s,
void* val, std::function<void(void*)> destructor);
void* get_named_prop(std::string s) const;
template<typename T>
void set_named_prop(std::string s, T* val)
{
set_named_prop(s, val, [](void *p) { delete static_cast<T*>(p); });
}
template<typename T>
T* get_named_prop(std::string s) const
{
void* p = get_named_prop_(s);
if (!p)
return nullptr;
return static_cast<T*>(p);
}
#endif
bool has_single_acc_set() const