]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Some minor cleanups of LogStream. 5064/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Tue, 12 Sep 2017 12:37:58 +0000 (06:37 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Tue, 12 Sep 2017 12:37:58 +0000 (06:37 -0600)
In particular, move some functions into the .cc file -- surely, these
functions do not need to be 'inline' in the header file.

include/deal.II/base/logstream.h
source/base/logstream.cc

index 8ac934ed9150da2f6fc79bee56dfb67001d07235..a5eb65d40fe74c1aa34ab2a87ef98dd51211f729 100644 (file)
@@ -95,8 +95,8 @@ public:
    * <code>continue</code>, <code>break</code>, <code>return</code>,
    * <code>throw</code>, or by simply reaching the closing brace. In all of
    * these cases, it is not necessary to remember to pop the prefix manually
-   * using LogStream::pop. In this, it works just like the better known
-   * Threads::Mutex::ScopedLock class.
+   * using LogStream::pop(). In this, it works just like the better known
+   * std::unique_ptr and Threads::Mutex::ScopedLock classes.
    */
   class Prefix
   {
@@ -120,6 +120,10 @@ public:
     ~Prefix ();
 
   private:
+    /**
+     * A pointer to the LogStream object to which the prefix is
+     * applied.
+     */
     SmartPointer<LogStream,LogStream::Prefix> stream;
   };
 
@@ -367,44 +371,6 @@ LogStream &operator<< (LogStream &log, const T &t)
 }
 
 
-inline
-std::ostringstream &
-LogStream::get_stream()
-{
-  // see if we have already created this stream. if not, do so and
-  // set the default flags (why we set these flags is lost to
-  // history, but this is what we need to keep several hundred tests
-  // from producing different output)
-  //
-  // note that in all of this we need not worry about thread-safety
-  // because we operate on a thread-local object and by definition
-  // there can only be one access at a time
-  if (outstreams.get().get() == nullptr)
-    {
-      outstreams.get().reset (new std::ostringstream);
-      outstreams.get()->setf(std::ios::showpoint | std::ios::left);
-    }
-
-  // then return the stream
-  return *outstreams.get();
-}
-
-
-
-inline
-LogStream::Prefix::Prefix(const std::string &text, LogStream &s)
-  :
-  stream(&s)
-{
-  stream->push(text);
-}
-
-
-inline
-LogStream::Prefix::~Prefix()
-{
-  stream->pop();
-}
 
 
 /**
@@ -415,14 +381,6 @@ LogStream::Prefix::~Prefix()
 extern LogStream deallog;
 
 
-inline
-LogStream::Prefix::Prefix(const std::string &text)
-  :
-  stream(&deallog)
-{
-  stream->push(text);
-}
-
 
 DEAL_II_NAMESPACE_CLOSE
 
index 3684c9de760ee0b205e009730d2bd043b339b654..eea5f82edd1aae7f3a6363120874557679eb0a7b 100644 (file)
@@ -36,6 +36,34 @@ namespace
 LogStream deallog;
 
 
+
+
+LogStream::Prefix::Prefix(const std::string &text)
+  :
+  stream(&deallog)
+{
+  stream->push(text);
+}
+
+
+
+LogStream::Prefix::Prefix(const std::string &text,
+                          LogStream &s)
+  :
+  stream(&s)
+{
+  stream->push(text);
+}
+
+
+
+LogStream::Prefix::~Prefix()
+{
+  stream->pop();
+}
+
+
+
 LogStream::LogStream()
   :
   std_out(&std::cout),
@@ -49,6 +77,7 @@ LogStream::LogStream()
 }
 
 
+
 LogStream::~LogStream()
 {
   // if there was anything left in the stream that is current to this
@@ -200,6 +229,30 @@ LogStream::get_console()
 }
 
 
+
+std::ostringstream &
+LogStream::get_stream()
+{
+  // see if we have already created this stream. if not, do so and
+  // set the default flags (why we set these flags is lost to
+  // history, but this is what we need to keep several hundred tests
+  // from producing different output)
+  //
+  // note that in all of this we need not worry about thread-safety
+  // because we operate on a thread-local object and by definition
+  // there can only be one access at a time
+  if (outstreams.get().get() == nullptr)
+    {
+      outstreams.get().reset (new std::ostringstream);
+      outstreams.get()->setf(std::ios::showpoint | std::ios::left);
+    }
+
+  // then return the stream
+  return *outstreams.get();
+}
+
+
+
 std::ostream &
 LogStream::get_file_stream()
 {
@@ -210,6 +263,7 @@ LogStream::get_file_stream()
 }
 
 
+
 bool
 LogStream::has_file() const
 {
@@ -217,6 +271,7 @@ LogStream::has_file() const
 }
 
 
+
 const std::string &
 LogStream::get_prefix() const
 {
@@ -229,6 +284,7 @@ LogStream::get_prefix() const
 }
 
 
+
 void
 LogStream::push (const std::string &text)
 {
@@ -242,6 +298,7 @@ LogStream::push (const std::string &text)
 }
 
 
+
 void LogStream::pop ()
 {
   if (get_prefixes().size() > 0)
@@ -249,6 +306,7 @@ void LogStream::pop ()
 }
 
 
+
 std::ios::fmtflags
 LogStream::flags(const std::ios::fmtflags f)
 {
@@ -256,6 +314,7 @@ LogStream::flags(const std::ios::fmtflags f)
 }
 
 
+
 std::streamsize
 LogStream::precision (const std::streamsize prec)
 {
@@ -263,6 +322,7 @@ LogStream::precision (const std::streamsize prec)
 }
 
 
+
 std::streamsize
 LogStream::width (const std::streamsize wide)
 {
@@ -270,6 +330,7 @@ LogStream::width (const std::streamsize wide)
 }
 
 
+
 unsigned int
 LogStream::depth_console (const unsigned int n)
 {
@@ -280,6 +341,7 @@ LogStream::depth_console (const unsigned int n)
 }
 
 
+
 unsigned int
 LogStream::depth_file (const unsigned int n)
 {
@@ -290,6 +352,7 @@ LogStream::depth_file (const unsigned int n)
 }
 
 
+
 bool
 LogStream::log_thread_id (const bool flag)
 {
@@ -299,6 +362,8 @@ LogStream::log_thread_id (const bool flag)
   return h;
 }
 
+
+
 std::stack<std::string> &
 LogStream::get_prefixes() const
 {
@@ -332,6 +397,7 @@ LogStream::get_prefixes() const
 }
 
 
+
 void
 LogStream::print_line_head()
 {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.