From 7c07f3149f208fb09ebbff8c53c6e9a8b9458114 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 7 Jan 2005 10:27:17 +0000 Subject: [PATCH] * src/tgbaalgos/ndfs_result.hxx (ndfs_result, acss_interface): Conditionally inherit from acss_statistics. * src/tgbaalgos/magic.cc, src/tgbaalgos/se05.cc, src/tgbaalgos/tau03.cc, src/tgbaalgos/tau03opt.cc: Define Has_Size in all heaps. --- ChangeLog | 7 +++++++ src/tgbaalgos/magic.cc | 8 ++------ src/tgbaalgos/ndfs_result.hxx | 36 ++++++++++++++++++++++++++++------- src/tgbaalgos/se05.cc | 8 ++------ src/tgbaalgos/tau03.cc | 1 + src/tgbaalgos/tau03opt.cc | 1 + 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 215a2c5a4..ea51b4701 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-01-07 Alexandre Duret-Lutz + + * src/tgbaalgos/ndfs_result.hxx (ndfs_result, acss_interface): + Conditionally inherit from acss_statistics. + * src/tgbaalgos/magic.cc, src/tgbaalgos/se05.cc, src/tgbaalgos/tau03.cc, + src/tgbaalgos/tau03opt.cc: Define Has_Size in all heaps. + 2005-01-06 Denis Poitrenaud * src/ltltest/randltl.cc: Include cassert. diff --git a/src/tgbaalgos/magic.cc b/src/tgbaalgos/magic.cc index 6f86b0ed8..5115f8ca2 100644 --- a/src/tgbaalgos/magic.cc +++ b/src/tgbaalgos/magic.cc @@ -387,6 +387,7 @@ namespace spot return (it != h.end()); } + enum { Has_Size = 1 }; int size() const { return h.size(); @@ -461,12 +462,7 @@ namespace spot return color((h[ha%size_] >> ((ha%4)*2)) & 3U) != WHITE; } - int size() const - { - // this method must return the number of state stored in the heap. Due - // to potential conflicts this size cannot be computed. - return 0; - } + enum { Has_Size = 0 }; private: size_t size_; diff --git a/src/tgbaalgos/ndfs_result.hxx b/src/tgbaalgos/ndfs_result.hxx index f8c543761..6cfd74a70 100644 --- a/src/tgbaalgos/ndfs_result.hxx +++ b/src/tgbaalgos/ndfs_result.hxx @@ -61,11 +61,37 @@ namespace spot typedef std::list stack_type; + namespace + { + // The acss_statistics is available only when the heap has a + // size() method (which we indicate using n==1). + + template + struct acss_interface + { + }; + + template + struct acss_interface + : public acss_statistics + { + int + acss_states() const + { + // all visited states are in the state space search + return dynamic_cast(this)->h_.size(); + } + }; + + } + + template class ndfs_result: public emptiness_check_result, public ars_statistics, - public acss_statistics + // Conditionally inherit from acss_statistics. + public acss_interface, heap::Has_Size> { public: ndfs_result(const ndfs_search& ms) @@ -74,12 +100,6 @@ namespace spot { } - int acss_states() const - { - // all visited states are in the state space search - return h_.size(); - } - virtual ~ndfs_result() { } @@ -195,6 +215,8 @@ namespace spot private: const ndfs_search& ms_; const heap& h_; + template + friend struct acss_interface; struct transition { const state* source; diff --git a/src/tgbaalgos/se05.cc b/src/tgbaalgos/se05.cc index e11371444..9e2a3cc87 100644 --- a/src/tgbaalgos/se05.cc +++ b/src/tgbaalgos/se05.cc @@ -445,6 +445,7 @@ namespace spot return true; } + enum { Has_Size = 1 }; int size() const { return h.size() + hc.size(); @@ -548,12 +549,7 @@ namespace spot return color((h[ha%size_] >> ((ha%4)*2)) & 3U) != WHITE; } - int size() const - { - // this method must return the number of state stored in the heap. Due - // to potential conflicts this size cannot be computed. - return 0; - } + enum { Has_Size = 0 }; private: size_t size_; diff --git a/src/tgbaalgos/tau03.cc b/src/tgbaalgos/tau03.cc index 49d9e5302..b1b9723a6 100644 --- a/src/tgbaalgos/tau03.cc +++ b/src/tgbaalgos/tau03.cc @@ -361,6 +361,7 @@ namespace spot return (it != h.end()); } + enum { Has_Size = 1 }; int size() const { return h.size(); diff --git a/src/tgbaalgos/tau03opt.cc b/src/tgbaalgos/tau03opt.cc index 8f5ccce2a..f8dc61263 100644 --- a/src/tgbaalgos/tau03opt.cc +++ b/src/tgbaalgos/tau03opt.cc @@ -481,6 +481,7 @@ namespace spot return true; } + enum { Has_Size = 1 }; int size() const { return h.size() + hc.size();