summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel_Burrows@alumni.brown.edu <Daniel_Burrows@alumni.brown.edu>2010-05-25 20:59:37 -0700
committerDaniel Burrows <Daniel Burrows Daniel_Burrows@alumni.brown.edu>2010-06-08 18:46:13 -0700
commit084d8537e44de3f3ff47f9bed66faac2914ae8e5 (patch)
tree198339aa337d49e19fa77b59458641e1ea621a86 /src
parentd936361811f05539c27ce8d6e64014d7ed918e1c (diff)
downloadaptitude-084d8537e44de3f3ff47f9bed66faac2914ae8e5.tar.gz
Add a first draft of some wrapper code to display search progress events.
The design needs to be improved, but it's a proof-of-concept. The wrapper takes care of displaying which pattern is being searched for as part of the displayed progress message. This has the side effect of causing the construction of progress messages to be a substantial fraction of the overall run-time. The API needs to be redesigned so that messages are only formatted when they'll actually be displayed.
Diffstat (limited to 'src')
-rw-r--r--src/cmdline/Makefile.am2
-rw-r--r--src/cmdline/SConscript2
-rw-r--r--src/cmdline/cmdline_search_progress.cc76
-rw-r--r--src/cmdline/cmdline_search_progress.h44
4 files changed, 124 insertions, 0 deletions
diff --git a/src/cmdline/Makefile.am b/src/cmdline/Makefile.am
index f1621c12..f79cf788 100644
--- a/src/cmdline/Makefile.am
+++ b/src/cmdline/Makefile.am
@@ -38,6 +38,8 @@ libcmdline_a_SOURCES=\
cmdline_resolver.h \
cmdline_search.cc \
cmdline_search.h \
+ cmdline_search_progress.cc \
+ cmdline_search_progress.h \
cmdline_show.cc \
cmdline_show.h \
cmdline_show_broken.cc \
diff --git a/src/cmdline/SConscript b/src/cmdline/SConscript
index b1b2d484..b87f9f79 100644
--- a/src/cmdline/SConscript
+++ b/src/cmdline/SConscript
@@ -34,6 +34,8 @@ src_filenames = [
'cmdline_resolver.h',
'cmdline_search.cc',
'cmdline_search.h',
+ 'cmdline_search_progress.cc',
+ 'cmdline_search_progress.h',
'cmdline_show.cc',
'cmdline_show.h',
'cmdline_show_broken.cc',
diff --git a/src/cmdline/cmdline_search_progress.cc b/src/cmdline/cmdline_search_progress.cc
new file mode 100644
index 00000000..68962860
--- /dev/null
+++ b/src/cmdline/cmdline_search_progress.cc
@@ -0,0 +1,76 @@
+/** \file cmdline_search_progress.cc */
+
+
+// Copyright (C) 2010 Daniel Burrows
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+
+#include "cmdline_search_progress.h"
+
+#include "cmdline_progress_display.h"
+
+#include <generic/util/progress_info.h>
+
+
+#include <boost/format.hpp>
+
+#include <cwidget/generic/util/ref_ptr.h>
+
+using aptitude::util::progress_info;
+using aptitude::util::progress_type_bar;
+using aptitude::util::progress_type_none;
+using aptitude::util::progress_type_pulse;
+using boost::format;
+using boost::shared_ptr;
+using cwidget::util::ref_ptr;
+
+namespace aptitude
+{
+ namespace cmdline
+ {
+ void search_progress(const progress_info &info,
+ const shared_ptr<progress_display> &progress_msg,
+ const std::string &pattern)
+ {
+ // We interpret the progress_info to add a prefix to its message
+ // if it has one.
+ switch(info.get_type())
+ {
+ case progress_type_none:
+ progress_msg->set_progress(info, false);
+ break;
+
+ case progress_type_pulse:
+ progress_msg->set_progress(progress_info::pulse( (format("%s: %s")
+ % pattern
+ % info.get_progress_status())
+ .str()),
+ false);
+ break;
+
+ case progress_type_bar:
+ progress_msg->set_progress(progress_info::bar(info.get_progress_fraction(),
+ (format("%s: %s")
+ % pattern
+ % info.get_progress_status())
+ .str()),
+ false);
+ break;
+ }
+ }
+ }
+}
diff --git a/src/cmdline/cmdline_search_progress.h b/src/cmdline/cmdline_search_progress.h
new file mode 100644
index 00000000..8079a2da
--- /dev/null
+++ b/src/cmdline/cmdline_search_progress.h
@@ -0,0 +1,44 @@
+/** \file cmdline_search_progress.h */ // -*-c++-*-
+
+// Copyright (C) 2010 Daniel Burrows
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; see the file COPYING. If not, write to
+// the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+#ifndef APTITUDE_CMDLINE_SEARCH_PROGRESS_H
+#define APTITUDE_CMDLINE_SEARCH_PROGRESS_H
+
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+
+namespace aptitude
+{
+ namespace util
+ {
+ class progress_info;
+ }
+
+ namespace cmdline
+ {
+ class progress_display;
+
+ void search_progress(const aptitude::util::progress_info &info,
+ const boost::shared_ptr<progress_display> &progress_msg,
+ const std::string &pattern);
+ }
+}
+
+#endif // APTITUDE_CMDLINE_SEARCH_PROGRESS_H