aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-03 20:16:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-01-03 20:16:28 +0000
commite0f8be954b475cd2d337461f43406b0607a9f159 (patch)
tree6d6be163003932570d8169e967fe402dc06b9c5e
parented1459ace725ef9c8ce8dd49946cdeb1b167fcbb (diff)
downloadpaludis-e0f8be954b475cd2d337461f43406b0607a9f159.tar.gz
paludis-e0f8be954b475cd2d337461f43406b0607a9f159.tar.xz
OutputManager::want_to_flush
-rw-r--r--paludis/buffer_output_manager.cc8
-rw-r--r--paludis/buffer_output_manager.hh3
-rw-r--r--paludis/file_output_manager.cc6
-rw-r--r--paludis/file_output_manager.hh3
-rw-r--r--paludis/format_messages_output_manager.cc6
-rw-r--r--paludis/format_messages_output_manager.hh1
-rw-r--r--paludis/forward_on_failure_output_manager.cc8
-rw-r--r--paludis/forward_on_failure_output_manager.hh3
-rw-r--r--paludis/output_manager.cc8
-rw-r--r--paludis/output_manager.hh10
-rw-r--r--paludis/standard_output_manager.cc8
-rw-r--r--paludis/standard_output_manager.hh3
-rw-r--r--paludis/tee_output_manager.cc17
-rw-r--r--paludis/tee_output_manager.hh3
14 files changed, 75 insertions, 12 deletions
diff --git a/paludis/buffer_output_manager.cc b/paludis/buffer_output_manager.cc
index 27808c3..15b739e 100644
--- a/paludis/buffer_output_manager.cc
+++ b/paludis/buffer_output_manager.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -86,6 +86,12 @@ BufferOutputManager::flush()
_imp->child->flush();
}
+bool
+BufferOutputManager::want_to_flush() const
+{
+ return _imp->stdout_stream.anything_to_unbuffer() || _imp->stderr_stream.anything_to_unbuffer();
+}
+
void
BufferOutputManager::nothing_more_to_come()
{
diff --git a/paludis/buffer_output_manager.hh b/paludis/buffer_output_manager.hh
index 4f079dc..6d8f257 100644
--- a/paludis/buffer_output_manager.hh
+++ b/paludis/buffer_output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -44,6 +44,7 @@ namespace paludis
virtual void succeeded();
virtual void flush();
+ virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
virtual void message(const MessageType, const std::string &);
diff --git a/paludis/file_output_manager.cc b/paludis/file_output_manager.cc
index aa9eff8..f7a7f44 100644
--- a/paludis/file_output_manager.cc
+++ b/paludis/file_output_manager.cc
@@ -128,6 +128,12 @@ FileOutputManager::flush()
{
}
+bool
+FileOutputManager::want_to_flush() const
+{
+ return false;
+}
+
void
FileOutputManager::nothing_more_to_come()
{
diff --git a/paludis/file_output_manager.hh b/paludis/file_output_manager.hh
index 31e206c..9bb02f1 100644
--- a/paludis/file_output_manager.hh
+++ b/paludis/file_output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -48,6 +48,7 @@ namespace paludis
virtual void succeeded();
virtual void flush();
+ virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
virtual void message(const MessageType, const std::string &);
diff --git a/paludis/format_messages_output_manager.cc b/paludis/format_messages_output_manager.cc
index 0053e0d..b2e00f9 100644
--- a/paludis/format_messages_output_manager.cc
+++ b/paludis/format_messages_output_manager.cc
@@ -139,6 +139,12 @@ FormatMessagesOutputManager::flush()
_imp->child->flush();
}
+bool
+FormatMessagesOutputManager::want_to_flush() const
+{
+ return _imp->child->want_to_flush();
+}
+
void
FormatMessagesOutputManager::nothing_more_to_come()
{
diff --git a/paludis/format_messages_output_manager.hh b/paludis/format_messages_output_manager.hh
index 6aafba8..12b78dd 100644
--- a/paludis/format_messages_output_manager.hh
+++ b/paludis/format_messages_output_manager.hh
@@ -55,6 +55,7 @@ namespace paludis
virtual void succeeded();
virtual void flush();
+ virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
virtual void message(const MessageType, const std::string &);
diff --git a/paludis/forward_on_failure_output_manager.cc b/paludis/forward_on_failure_output_manager.cc
index fe16c76..d1b527c 100644
--- a/paludis/forward_on_failure_output_manager.cc
+++ b/paludis/forward_on_failure_output_manager.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -95,6 +95,12 @@ ForwardOnFailureOutputManager::flush()
{
}
+bool
+ForwardOnFailureOutputManager::want_to_flush() const
+{
+ return false;
+}
+
void
ForwardOnFailureOutputManager::nothing_more_to_come()
{
diff --git a/paludis/forward_on_failure_output_manager.hh b/paludis/forward_on_failure_output_manager.hh
index 1ac69b2..d3ccd06 100644
--- a/paludis/forward_on_failure_output_manager.hh
+++ b/paludis/forward_on_failure_output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -43,6 +43,7 @@ namespace paludis
virtual void succeeded();
virtual void flush();
+ virtual bool want_to_flush() const;
virtual void message(const MessageType, const std::string &);
virtual void nothing_more_to_come();
diff --git a/paludis/output_manager.cc b/paludis/output_manager.cc
index 7692dd8..212664d 100644
--- a/paludis/output_manager.cc
+++ b/paludis/output_manager.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,6 +20,8 @@
#include <paludis/output_manager.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/exception.hh>
+#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <ostream>
using namespace paludis;
@@ -30,3 +32,7 @@ OutputManager::~OutputManager()
{
}
+template class Sequence<std::tr1::shared_ptr<OutputManager> >;
+template class WrappedForwardIterator<Sequence<std::tr1::shared_ptr<OutputManager> >::ConstIteratorTag,
+ const std::tr1::shared_ptr<OutputManager> >;
+
diff --git a/paludis/output_manager.hh b/paludis/output_manager.hh
index 1edee95..5edfb31 100644
--- a/paludis/output_manager.hh
+++ b/paludis/output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -55,6 +55,14 @@ namespace paludis
virtual void flush() = 0;
/**
+ * Do we want to flush?
+ *
+ * Provides a way for clients to avoid having to call flush() with
+ * a prefixed header when there's no output waiting.
+ */
+ virtual bool want_to_flush() const = 0;
+
+ /**
* Called if an action succeeds. This can be used to, for example,
* unlink the files behind a to-disk logged output manager.
*
diff --git a/paludis/standard_output_manager.cc b/paludis/standard_output_manager.cc
index ef4fd24..1cbefe6 100644
--- a/paludis/standard_output_manager.cc
+++ b/paludis/standard_output_manager.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -54,6 +54,12 @@ StandardOutputManager::flush()
{
}
+bool
+StandardOutputManager::want_to_flush() const
+{
+ return false;
+}
+
void
StandardOutputManager::nothing_more_to_come()
{
diff --git a/paludis/standard_output_manager.hh b/paludis/standard_output_manager.hh
index f70cb77..b0e2be6 100644
--- a/paludis/standard_output_manager.hh
+++ b/paludis/standard_output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -41,6 +41,7 @@ namespace paludis
virtual void succeeded();
virtual void flush();
+ virtual bool want_to_flush() const;
virtual void message(const MessageType, const std::string &);
virtual void nothing_more_to_come();
diff --git a/paludis/tee_output_manager.cc b/paludis/tee_output_manager.cc
index 3021900..2894f79 100644
--- a/paludis/tee_output_manager.cc
+++ b/paludis/tee_output_manager.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,12 +20,14 @@
#include <paludis/tee_output_manager.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/tee_output_stream.hh>
-#include <paludis/util/sequence-impl.hh>
+#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/indirect_iterator-impl.hh>
#include <vector>
+#include <algorithm>
using namespace paludis;
@@ -111,6 +113,17 @@ TeeOutputManager::flush()
(*i)->flush();
}
+bool
+TeeOutputManager::want_to_flush() const
+{
+ return indirect_iterator(_imp->streams->end()) != std::find_if(
+ indirect_iterator(_imp->streams->begin()), indirect_iterator(_imp->streams->end()),
+ std::tr1::bind(&OutputManager::want_to_flush, std::tr1::placeholders::_1)) ||
+ indirect_iterator(_imp->messages_streams->end()) != std::find_if(
+ indirect_iterator(_imp->messages_streams->begin()), indirect_iterator(_imp->messages_streams->end()),
+ std::tr1::bind(&OutputManager::want_to_flush, std::tr1::placeholders::_1));
+}
+
void
TeeOutputManager::nothing_more_to_come()
{
diff --git a/paludis/tee_output_manager.hh b/paludis/tee_output_manager.hh
index 7bc59f1..776d689 100644
--- a/paludis/tee_output_manager.hh
+++ b/paludis/tee_output_manager.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2009 Ciaran McCreesh
+ * Copyright (c) 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -46,6 +46,7 @@ namespace paludis
virtual void succeeded();
virtual void flush();
+ virtual bool want_to_flush() const;
virtual void nothing_more_to_come();
virtual void message(const MessageType, const std::string &);