[Aptitude-devel] r3064 - in branches/aptitude-0.3/aptitude: . src/generic

Daniel Burrows dburrows@costa.debian.org
Sat, 23 Apr 2005 02:17:32 +0000


Author: dburrows
Date: Sat Apr 23 02:17:29 2005
New Revision: 3064

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/aptcache.cc
   branches/aptitude-0.3/aptitude/src/generic/aptcache.h
Log:
Add routines to read off the total count of solutions and
the currently selected solution index.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Sat Apr 23 02:17:29 2005
@@ -1,5 +1,10 @@
 2005-04-22  Daniel Burrows  <dburrows@debian.org>
 
+	* src/generic/aptcache.cc, src/generic/aptcache.h:
+
+	  Add routines to extract more information about cached solutions
+	  (to add to the suggestion bar).
+
 	* src/generic/aptcache.cc:
 
 	  In next_solution(), always advance to the newly created solution

Modified: branches/aptitude-0.3/aptitude/src/generic/aptcache.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptcache.cc	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptcache.cc	Sat Apr 23 02:17:29 2005
@@ -1370,16 +1370,31 @@
   return resolver != NULL;
 }
 
+unsigned int aptitudeDepCache::generated_solution_count() const
+{
+  return solutions.size();
+}
+
+bool aptitudeDepCache::solution_generation_complete() const
+{
+  return resolver->exhausted();
+}
+
 bool aptitudeDepCache::solutions_exhausted() const
 {
-  return (!resolver) || (resolver->exhausted() &&
-			 (solutions.empty() ||
-			  selected_solution == solutions.size()-1));
+  if(!resolver_exists())
+    return true;
+  else
+    return selected_solution == generated_solution_count()+1 &&
+      solution_generation_complete();
 }
 
 bool aptitudeDepCache::solutions_at_start() const
 {
-  return solutions.empty() || selected_solution == 0;
+  if(!resolver_exists())
+    return true;
+  else
+    return selected_solution == 0;
 }
 
 const aptitude_resolver::solution &aptitudeDepCache::get_current_solution()

Modified: branches/aptitude-0.3/aptitude/src/generic/aptcache.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/aptcache.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/aptcache.h	Sat Apr 23 02:17:29 2005
@@ -367,6 +367,18 @@
    */
   bool resolver_exists() const;
 
+  /** The number of solutions generated. */
+  unsigned int generated_solution_count() const;
+
+  /** Get the selection location, which will be in the range
+   *  [0,generated_solution_count()-1).  Note that this is meaningless
+   *  if generated_solution_count==0.
+   */
+  unsigned int get_selected_solution() const {return selected_solution;}
+
+  /** If \b true, all solutions have been generated. */
+  bool solution_generation_complete() const;
+
   /** If \b true, then either there is no resolver, or the resolver
    *  has been exhausted and the solution pointer is set to the last
    *  solution.