From 6b2eeff1235a32b97736a564dbc2b02bfcda3587 Mon Sep 17 00:00:00 2001 From: Daniel Burrows Date: Thu, 4 Mar 2010 09:11:02 -0800 Subject: Let client code query the components of a tier operation. --- src/generic/problemresolver/tier_operation.cc | 13 ++++++++++ src/generic/problemresolver/tier_operation.h | 34 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) (limited to 'src/generic/problemresolver') diff --git a/src/generic/problemresolver/tier_operation.cc b/src/generic/problemresolver/tier_operation.cc index 1b6e83ba..31de3808 100644 --- a/src/generic/problemresolver/tier_operation.cc +++ b/src/generic/problemresolver/tier_operation.cc @@ -215,6 +215,19 @@ tier_operation::op_impl::op_impl(const op_impl &op1, const op_impl &op2, lower_b } } +level tier_operation::op_impl::get_user_level(level_index idx) const +{ + + // "Slow" implementation right now because this isn't used much + // (only for display). + for(std::vector >::const_iterator it = + actions.begin(); it != actions.end(); ++it) + if(it->first == idx) + return it->second; + + return level(); +} + tier_operation tier_operation::least_upper_bound(const tier_operation &op1, const tier_operation &op2) { diff --git a/src/generic/problemresolver/tier_operation.h b/src/generic/problemresolver/tier_operation.h index 62e74ecb..c6231dc1 100644 --- a/src/generic/problemresolver/tier_operation.h +++ b/src/generic/problemresolver/tier_operation.h @@ -124,6 +124,18 @@ class tier_operation return rval; } + int get_structural_level() const + { + return structural_level; + } + + level get_user_level(std::size_t idx) const; + + bool get_has_user_level_changes() const + { + return !actions.empty(); + } + /** \brief Test two tier operations for equality. * * \note Relies on the fact that the level's equality comparison @@ -320,6 +332,28 @@ public: get_impl().dump(out); } + /** \brief Get the structural level that this operation raises its + * target to. + */ + int get_structural_level() const + { + return get_impl().get_structural_level(); + } + + /** \brief Get the operation performed on a user level. */ + level get_user_level(int idx) const + { + return get_impl().get_user_level(idx); + } + + /** \brief Check whether any actions performed by the operation + * affect user levels. + */ + bool get_has_user_level_changes() const + { + return get_impl().get_has_user_level_changes(); + } + std::size_t get_hash_value() const { return get_impl().get_hash_value(); -- cgit v1.2.3