aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-23 18:03:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-23 18:03:27 +0000
commita7cc219d30b452bb3c76cbd4186fa0fd38f83c4f (patch)
treea080a4fa4032741e5dee1ff9dc9e7da8fdd04a4d
parentf946430c361864a353707eb91b48209ba7b52550 (diff)
downloadpaludis-a7cc219d30b452bb3c76cbd4186fa0fd38f83c4f.tar.gz
paludis-a7cc219d30b452bb3c76cbd4186fa0fd38f83c4f.tar.xz
Resolver stage notification event
-rw-r--r--paludis/notifier_callback-fwd.hh1
-rw-r--r--paludis/notifier_callback.cc11
-rw-r--r--paludis/notifier_callback.hh16
-rw-r--r--paludis/resolver/resolver.cc2
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.cc23
-rw-r--r--src/clients/cave/cmd_resolve_display_callback.hh2
-rw-r--r--src/clients/inquisitio/do_search.cc4
-rw-r--r--src/output/console_install_task.cc4
8 files changed, 57 insertions, 6 deletions
diff --git a/paludis/notifier_callback-fwd.hh b/paludis/notifier_callback-fwd.hh
index 16e7634..dd97d83 100644
--- a/paludis/notifier_callback-fwd.hh
+++ b/paludis/notifier_callback-fwd.hh
@@ -27,6 +27,7 @@ namespace paludis
struct NotifierCallbackEvent;
struct NotifierCallbackGeneratingMetadataEvent;
struct NotifierCallbackResolverStepEvent;
+ struct NotifierCallbackResolverStageEvent;
typedef std::tr1::function<void (const NotifierCallbackEvent &) > NotifierCallbackFunction;
diff --git a/paludis/notifier_callback.cc b/paludis/notifier_callback.cc
index 613fad6..4ebc466 100644
--- a/paludis/notifier_callback.cc
+++ b/paludis/notifier_callback.cc
@@ -35,6 +35,17 @@ NotifierCallbackGeneratingMetadataEvent::repository() const
return _repo;
}
+NotifierCallbackResolverStageEvent::NotifierCallbackResolverStageEvent(const std::string & r) :
+ _stage(r)
+{
+}
+
+const std::string
+NotifierCallbackResolverStageEvent::stage() const
+{
+ return _stage;
+}
+
namespace paludis
{
template <>
diff --git a/paludis/notifier_callback.hh b/paludis/notifier_callback.hh
index e33ac11..2a28e90 100644
--- a/paludis/notifier_callback.hh
+++ b/paludis/notifier_callback.hh
@@ -32,7 +32,8 @@ namespace paludis
class PALUDIS_VISIBLE NotifierCallbackEvent :
public virtual DeclareAbstractAcceptMethods<NotifierCallbackEvent, MakeTypeList<
NotifierCallbackGeneratingMetadataEvent,
- NotifierCallbackResolverStepEvent>::Type>
+ NotifierCallbackResolverStepEvent,
+ NotifierCallbackResolverStageEvent>::Type>
{
};
@@ -55,6 +56,19 @@ namespace paludis
{
};
+ class PALUDIS_VISIBLE NotifierCallbackResolverStageEvent :
+ public NotifierCallbackEvent,
+ public ImplementAcceptMethods<NotifierCallbackEvent, NotifierCallbackResolverStageEvent>
+ {
+ private:
+ const std::string _stage;
+
+ public:
+ NotifierCallbackResolverStageEvent(const std::string &);
+
+ const std::string stage() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+
class PALUDIS_VISIBLE ScopedNotifierCallback :
private PrivateImplementationPattern<ScopedNotifierCallback>
{
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index d98d57e..cf318d7 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -109,7 +109,9 @@ Resolver::add_target(const SetName & set_name)
void
Resolver::resolve()
{
+ _imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Deciding"));
_imp->decider->resolve();
+ _imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Ordering"));
_imp->orderer->resolve();
}
diff --git a/src/clients/cave/cmd_resolve_display_callback.cc b/src/clients/cave/cmd_resolve_display_callback.cc
index d37c09b..696a7be 100644
--- a/src/clients/cave/cmd_resolve_display_callback.cc
+++ b/src/clients/cave/cmd_resolve_display_callback.cc
@@ -33,11 +33,13 @@ namespace paludis
struct Implementation<DisplayCallback>
{
mutable Mutex mutex;
- mutable unsigned width;
mutable std::map<std::string, int> metadata, steps;
+ mutable std::string stage;
+ mutable unsigned width;
Implementation() :
- width(0)
+ stage("Resolving: "),
+ width(stage.length())
{
}
};
@@ -47,7 +49,7 @@ namespace paludis
DisplayCallback::DisplayCallback() :
PrivateImplementationPattern<DisplayCallback>(new Implementation<DisplayCallback>)
{
- std::cout << "Resolving: " << std::flush;
+ std::cout << _imp->stage << std::flush;
}
DisplayCallback::~DisplayCallback()
@@ -78,6 +80,14 @@ DisplayCallback::visit(const NotifierCallbackGeneratingMetadataEvent & e) const
}
void
+DisplayCallback::visit(const NotifierCallbackResolverStageEvent & e) const
+{
+ Lock lock(_imp->mutex);
+ _imp->stage = e.stage() + ": ";
+ update();
+}
+
+void
DisplayCallback::visit(const NotifierCallbackResolverStepEvent &) const
{
Lock lock(_imp->mutex);
@@ -88,14 +98,17 @@ DisplayCallback::visit(const NotifierCallbackResolverStepEvent &) const
void
DisplayCallback::update() const
{
- std::string s;
+ std::string s(_imp->stage);
+ bool first(true);
+
if (! _imp->steps.empty())
{
for (std::map<std::string, int>::const_iterator i(_imp->steps.begin()), i_end(_imp->steps.end()) ;
i != i_end ; ++i)
{
- if (! s.empty())
+ if (! first)
s.append(", ");
+ first = false;
s.append(stringify(i->second) + " " + i->first);
}
diff --git a/src/clients/cave/cmd_resolve_display_callback.hh b/src/clients/cave/cmd_resolve_display_callback.hh
index c443911..e71b4ae 100644
--- a/src/clients/cave/cmd_resolve_display_callback.hh
+++ b/src/clients/cave/cmd_resolve_display_callback.hh
@@ -49,6 +49,8 @@ namespace paludis
void visit(const NotifierCallbackGeneratingMetadataEvent &) const;
void visit(const NotifierCallbackResolverStepEvent &) const;
+
+ void visit(const NotifierCallbackResolverStageEvent &) const;
};
}
}
diff --git a/src/clients/inquisitio/do_search.cc b/src/clients/inquisitio/do_search.cc
index b88e6f7..101ec13 100644
--- a/src/clients/inquisitio/do_search.cc
+++ b/src/clients/inquisitio/do_search.cc
@@ -77,6 +77,10 @@ namespace
update();
}
+ void visit(const NotifierCallbackResolverStageEvent &) const
+ {
+ }
+
void visit(const NotifierCallbackResolverStepEvent &) const
{
Lock lock(mutex);
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index e741c6a..d5d54ef 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -230,6 +230,10 @@ struct ConsoleInstallTask::CallbackDisplayer
update();
}
+ void visit(const NotifierCallbackResolverStageEvent &)
+ {
+ }
+
void update()
{
std::string s;