From ae1cca7e4d0db4bc5999bc0fe00c6c8d76a97ce9 Mon Sep 17 00:00:00 2001
From: ctraizet <cedric.traizet@c-s.fr>
Date: Wed, 6 Mar 2019 13:53:47 +0100
Subject: [PATCH] STYLE: run clang-format on the python logger classes

---
 Modules/Core/Common/src/otbLogger.cxx         |  3 +-
 .../SWIG/src/otbWrapperSWIGIncludes.h         | 14 +--
 .../python/otbCallbackProgressReporter.cxx    | 90 +++++++------------
 .../src/python/otbCallbackProgressReporter.h  | 27 +++---
 .../SWIG/src/python/otbLogOutputCallback.h    | 18 ++--
 .../src/python/otbProgressReporterManager.cxx | 20 ++---
 .../src/python/otbProgressReporterManager.h   | 36 ++++----
 .../SWIG/src/python/otbPythonLogOutput.cxx    |  6 +-
 .../SWIG/src/python/otbPythonLogOutput.h      | 24 ++---
 9 files changed, 102 insertions(+), 136 deletions(-)

diff --git a/Modules/Core/Common/src/otbLogger.cxx b/Modules/Core/Common/src/otbLogger.cxx
index 84aa243ced..95e107e909 100644
--- a/Modules/Core/Common/src/otbLogger.cxx
+++ b/Modules/Core/Common/src/otbLogger.cxx
@@ -47,8 +47,7 @@ Logger * Logger::CreateInstance()
   Logger * logger = new Logger;
 
   // By default redirect logs to std::cout
-  itk::StdStreamLogOutput::Pointer defaultOutput = 
-      itk::StdStreamLogOutput::New();
+  itk::StdStreamLogOutput::Pointer defaultOutput = itk::StdStreamLogOutput::New();
   defaultOutput->SetStream(std::cout);
   logger->AddLogOutput(defaultOutput);
 
diff --git a/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h b/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h
index ffbbbd6409..bd694359e6 100644
--- a/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h
+++ b/Modules/Wrappers/SWIG/src/otbWrapperSWIGIncludes.h
@@ -43,12 +43,12 @@ typedef otb::Wrapper::ComplexInputImageParameter         ComplexInputImageParame
 
 typedef otb::Wrapper::ImageBaseType                      ImageBaseType;
 
-typedef otb::Logger                                      Logger;
-typedef otb::Logger::Pointer                             Logger_Pointer;
-typedef otb::LogOutputCallback                           LogOutputCallback;
-typedef otb::PythonLogOutput                             PythonLogOutput;
-typedef otb::PythonLogOutput::Pointer                    PythonLogOutput_Pointer;
-typedef otb::ProgressReporterManager                     ProgressReporterManager;
-typedef otb::ProgressReporterManager::Pointer            ProgressReporterManager_Pointer;
+typedef otb::Logger                           Logger;
+typedef otb::Logger::Pointer                  Logger_Pointer;
+typedef otb::LogOutputCallback                LogOutputCallback;
+typedef otb::PythonLogOutput                  PythonLogOutput;
+typedef otb::PythonLogOutput::Pointer         PythonLogOutput_Pointer;
+typedef otb::ProgressReporterManager          ProgressReporterManager;
+typedef otb::ProgressReporterManager::Pointer ProgressReporterManager_Pointer;
 
 #endif
diff --git a/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.cxx b/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.cxx
index 02f3ec61d9..438bc2ce90 100644
--- a/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.cxx
+++ b/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.cxx
@@ -24,104 +24,78 @@
 namespace otb
 {
 
-CallbackProgressReporter
-::CallbackProgressReporter()
+CallbackProgressReporter::CallbackProgressReporter()
 {
 }
 
-CallbackProgressReporter
-::CallbackProgressReporter(itk::ProcessObject* process,
-                        const char *comment)
-  : FilterWatcherBase(process, comment),
-    m_StarsCount(50),
-    m_CurrentNbStars(-1)
+CallbackProgressReporter::CallbackProgressReporter(itk::ProcessObject* process, const char* comment)
+  : FilterWatcherBase(process, comment), m_StarsCount(50), m_CurrentNbStars(-1)
 {
 }
 
-CallbackProgressReporter
-::CallbackProgressReporter(itk::ProcessObject* process,
-                        const std::string& comment)
-  : FilterWatcherBase(process, comment.c_str()),
-    m_StarsCount(50),
-    m_CurrentNbStars(-1)
+CallbackProgressReporter::CallbackProgressReporter(itk::ProcessObject* process, const std::string& comment)
+  : FilterWatcherBase(process, comment.c_str()), m_StarsCount(50), m_CurrentNbStars(-1)
 {
 }
 
-void
-CallbackProgressReporter
-::ShowProgress()
+void CallbackProgressReporter::ShowProgress()
 {
   if (m_Process)
-    {
+  {
     int progressPercent = static_cast<int>(m_Process->GetProgress() * 100);
-    int nbStars = static_cast<int>(m_Process->GetProgress() * m_StarsCount);
-    int nbBlanks = m_StarsCount - nbStars;
+    int nbStars         = static_cast<int>(m_Process->GetProgress() * m_StarsCount);
+    int nbBlanks        = m_StarsCount - nbStars;
 
     if (nbBlanks < 0)
-      {
+    {
       nbBlanks = 0;
-      }
-      
+    }
+
     if (nbStars > m_StarsCount)
-      {
+    {
       nbStars = m_StarsCount;
-      }
+    }
 
     if (progressPercent > 100)
-      {
+    {
       progressPercent = 100;
-      }
-      
+    }
+
     if (nbStars > m_CurrentNbStars)
-      {
+    {
       std::string stars(nbStars, '*');
       std::string blanks(nbBlanks, ' ');
-      
+
       if (m_Callback->Isatty())
-        {
-        m_Callback->Call("\r"
-                          +m_Comment
-                          +": "
-                          +std::to_string(progressPercent)
-                          +"% ["
-                          +stars
-                          +blanks
-                          +"]");
+      {
+        m_Callback->Call("\r" + m_Comment + ": " + std::to_string(progressPercent) + "% [" + stars + blanks + "]");
         m_Callback->Flush();
-        }
+      }
       else
-        {
-        m_Buffer= "\r"+m_Comment+": "+std::to_string(progressPercent)
-                      +"% ["+stars+blanks+"]";
-        }
+      {
+        m_Buffer = "\r" + m_Comment + ": " + std::to_string(progressPercent) + "% [" + stars + blanks + "]";
       }
+    }
 
     m_CurrentNbStars = nbStars;
-    }
+  }
 }
 
-void
-CallbackProgressReporter
-::StartFilter()
+void CallbackProgressReporter::StartFilter()
 {
   m_Stopwatch.Start();
 }
 
-void
-CallbackProgressReporter
-::EndFilter()
+void CallbackProgressReporter::EndFilter()
 {
   m_Stopwatch.Stop();
-  
+
   if (m_Process && !(m_Callback->Isatty()))
-    {
+  {
     m_Callback->Call(m_Buffer);
     m_Buffer = std::string("");
-    }
+  }
 
-  m_Callback->Call(" ("
-                    +m_Stopwatch.GetElapsedHumanReadableTime()
-                    +")\n");
+  m_Callback->Call(" (" + m_Stopwatch.GetElapsedHumanReadableTime() + ")\n");
 }
-
 }
diff --git a/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.h b/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.h
index d94f7e1a87..8bc629b32a 100644
--- a/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.h
+++ b/Modules/Wrappers/SWIG/src/python/otbCallbackProgressReporter.h
@@ -34,17 +34,15 @@ namespace otb
  *  the LogOutputCallback. The LogOutputCallback is also used to determine
  *  if the output is interactive.
  */
- 
+
 class CallbackProgressReporter : public FilterWatcherBase
 {
 public:
   /** Constructor. Takes a ProcessObject to monitor and an optional
    * comment string that is prepended to each event message. */
-  CallbackProgressReporter(itk::ProcessObject* process,
-                        const char *comment = "");
+  CallbackProgressReporter(itk::ProcessObject* process, const char* comment = "");
 
-  CallbackProgressReporter(itk::ProcessObject* process,
-                        const std::string& comment = "");
+  CallbackProgressReporter(itk::ProcessObject* process, const std::string& comment = "");
 
   /** Default constructor */
   CallbackProgressReporter();
@@ -53,13 +51,13 @@ public:
   virtual ~CallbackProgressReporter() = default;
 
   typedef LogOutputCallback CallbackType;
-  
+
   /** Set the callback method */
-  void SetCallback(CallbackType * callback)
-    {
+  void SetCallback(CallbackType* callback)
+  {
     m_Callback = callback;
-    }
-  
+  }
+
 protected:
   /** Callback method to show the ProgressEvent */
   virtual void ShowProgress() override;
@@ -71,19 +69,18 @@ protected:
   virtual void EndFilter() override;
 
 private:
-
   /** Total number of stars in the progress bar */
   int m_StarsCount;
 
   /** Current number of stars in the progress bar */
   int m_CurrentNbStars;
-  
+
   /** The Callback used for printing */
-  CallbackType * m_Callback; 
-  
+  CallbackType* m_Callback;
+
   /** buffer used when sys.stdout.isatty() == false */
   std::string m_Buffer;
 };
 }
 
-#endif //otbCallbackProgressReporter_h
+#endif // otbCallbackProgressReporter_h
diff --git a/Modules/Wrappers/SWIG/src/python/otbLogOutputCallback.h b/Modules/Wrappers/SWIG/src/python/otbLogOutputCallback.h
index 5548c67f0c..41b98e0611 100644
--- a/Modules/Wrappers/SWIG/src/python/otbLogOutputCallback.h
+++ b/Modules/Wrappers/SWIG/src/python/otbLogOutputCallback.h
@@ -33,27 +33,29 @@ namespace otb
  *  class PythonLogOutputCallback, that uses Swig directors to override these
  *  methods.
  */
- 
+
 class LogOutputCallback
 {
 public:
   /** Constructor */
   LogOutputCallback() = default;
-  
+
   /** Destructor */
   virtual ~LogOutputCallback() = default;
 
   /** Write a string to a buffer */
-  virtual void Call(std::string const &) {};
-  
+  virtual void Call(std::string const&){};
+
   /** Flush the buffer */
-  virtual void Flush() {};
-  
+  virtual void Flush(){};
+
   /** Determine if the bufer is interactive */
-  virtual bool Isatty() {return false;};
+  virtual bool Isatty()
+  {
+    return false;
+  };
 };
 
 } // namespace otb
 
 #endif // otbPythonLogOutputCallback_h
-
diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx
index afbeb3ca04..89ea154a43 100644
--- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx
+++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.cxx
@@ -23,27 +23,23 @@
 
 namespace otb
 {
-  
-ProgressReporterManager
-::ProgressReporterManager()
+
+ProgressReporterManager::ProgressReporterManager()
 {
   // Add the callback to be added when a AddProcessToWatch event is invoked
   m_AddProcessCommand = AddProcessCommandType::New();
   m_AddProcessCommand->SetCallbackFunction(this, &ProgressReporterManager::LinkWatchers);
 }
 
-void ProgressReporterManager::LinkWatchers(itk::Object * itkNotUsed(caller), const itk::EventObject & event)
+void ProgressReporterManager::LinkWatchers(itk::Object* itkNotUsed(caller), const itk::EventObject& event)
 {
-  if (typeid(otb::Wrapper::AddProcessToWatchEvent) == typeid( event ))
-    {
-    const Wrapper::AddProcessToWatchEvent* eventToWatch = dynamic_cast<const Wrapper::AddProcessToWatchEvent*> (&event);
+  if (typeid(otb::Wrapper::AddProcessToWatchEvent) == typeid(event))
+  {
+    const Wrapper::AddProcessToWatchEvent* eventToWatch = dynamic_cast<const Wrapper::AddProcessToWatchEvent*>(&event);
 
-    CallbackProgressReporter * watch = new CallbackProgressReporter(eventToWatch->GetProcess(),
-                                                                              eventToWatch->GetProcessDescription());
+    CallbackProgressReporter* watch = new CallbackProgressReporter(eventToWatch->GetProcess(), eventToWatch->GetProcessDescription());
     watch->SetCallback(m_Callback);
     m_WatcherList.push_back(watch);
-    }
+  }
 }
-
-
 }
diff --git a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h
index 588846c8a4..e1aaf0d1f8 100644
--- a/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h
+++ b/Modules/Wrappers/SWIG/src/python/otbProgressReporterManager.h
@@ -41,37 +41,36 @@ class ProgressReporterManager : public itk::Object
 {
 public:
   /** Standard class typedefs. */
-  typedef ProgressReporterManager Self;
-  typedef itk::Object Superclass;
-  typedef itk::SmartPointer<Self> Pointer;
+  typedef ProgressReporterManager       Self;
+  typedef itk::Object                   Superclass;
+  typedef itk::SmartPointer<Self>       Pointer;
   typedef itk::SmartPointer<const Self> ConstPointer;
-  
+
   itkTypeMacro(ProgressReporterManager, itk::Object);
 
   itkNewMacro(ProgressReporterManager);
 
   typedef LogOutputCallback CallbackType;
   /** Command Member */
-  typedef itk::MemberCommand< Self >        AddProcessCommandType;
+  typedef itk::MemberCommand<Self> AddProcessCommandType;
 
   /** Filter watcher list type */
-  typedef std::vector<CallbackProgressReporter *> WatcherListType;
-  
+  typedef std::vector<CallbackProgressReporter*> WatcherListType;
+
   /** Set the logger callback function */
-  void SetLogOutputCallback(CallbackType * callback)
+  void SetLogOutputCallback(CallbackType* callback)
   {
     m_Callback = callback;
     this->Modified();
   }
-  
+
   /** Getter to AddProcessCommand */
   AddProcessCommandType* GetAddProcessCommand()
   {
     return m_AddProcessCommand.GetPointer();
   }
-  
-protected:
 
+protected:
   /** Default constructor */
   ProgressReporterManager();
 
@@ -79,19 +78,18 @@ protected:
   virtual ~ProgressReporterManager() = default;
 
   /** Load the watchers for internal progress and writing progress report. */
-  void LinkWatchers(itk::Object * caller, const itk::EventObject & event);
+  void LinkWatchers(itk::Object* caller, const itk::EventObject& event);
 
 private:
   /** The LogOutputCallback used for printing */
-  CallbackType * m_Callback; 
-  
+  CallbackType* m_Callback;
+
   /** Command associated to the LinkWatchers command */
-  AddProcessCommandType::Pointer    m_AddProcessCommand;
-  
+  AddProcessCommandType::Pointer m_AddProcessCommand;
+
   /** container storing all the watchers (CallbackProgressReporter) */
-  WatcherListType                   m_WatcherList;
+  WatcherListType m_WatcherList;
 };
-
 }
 
-#endif //otbProgressReporterManager_h
+#endif // otbProgressReporterManager_h
diff --git a/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.cxx b/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.cxx
index 1cd99e63fc..d8f703c4b8 100644
--- a/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.cxx
+++ b/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.cxx
@@ -32,17 +32,17 @@ void PythonLogOutput::Write(double timestamp)
   m_Callback->Call(std::to_string(timestamp));
 }
 
-void PythonLogOutput::Write(std::string const & content)
+void PythonLogOutput::Write(std::string const& content)
 {
   m_Callback->Call(content);
 }
 
-void PythonLogOutput::Write(std::string const & content, double timestamp)
+void PythonLogOutput::Write(std::string const& content, double timestamp)
 {
   m_Callback->Call(std::to_string(timestamp) + " : " + content);
 }
 
-void PythonLogOutput::PrintSelf(std::ostream & os, itk::Indent indent) const
+void PythonLogOutput::PrintSelf(std::ostream& os, itk::Indent indent) const
 {
   Superclass::PrintSelf(os, indent);
 }
diff --git a/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.h b/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.h
index 57cc5ce3ad..17b2f3eee7 100644
--- a/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.h
+++ b/Modules/Wrappers/SWIG/src/python/otbPythonLogOutput.h
@@ -35,10 +35,10 @@ namespace otb
 class PythonLogOutput : public itk::LogOutput
 {
 public:
-  typedef PythonLogOutput         Self;
-  typedef itk::LogOutput                  Superclass;
-  typedef itk::SmartPointer< Self >       Pointer;
-  typedef itk::SmartPointer< const Self > ConstPointer;
+  typedef PythonLogOutput               Self;
+  typedef itk::LogOutput                Superclass;
+  typedef itk::SmartPointer<Self>       Pointer;
+  typedef itk::SmartPointer<const Self> ConstPointer;
 
   typedef LogOutputCallback CallbackType;
   itkTypeMacro(PythonLogOutput, itk::LogOutput);
@@ -46,12 +46,12 @@ public:
   itkNewMacro(PythonLogOutput);
 
   /** Set the callback method */
-  void SetCallback(CallbackType * callback)
-    {
+  void SetCallback(CallbackType* callback)
+  {
     m_Callback = callback;
     this->Modified();
-    }
-  
+  }
+
   /** flush a buffer */
   virtual void Flush() override;
 
@@ -59,10 +59,10 @@ public:
   virtual void Write(double timestamp) override;
 
   /** Write to a buffer */
-  virtual void Write(std::string const & content) override;
+  virtual void Write(std::string const& content) override;
 
   /** Write to a buffer */
-  virtual void Write(std::string const & content, double timestamp) override;
+  virtual void Write(std::string const& content, double timestamp) override;
 
 protected:
   /** Constructor */
@@ -71,10 +71,10 @@ protected:
   /** Destructor */
   virtual ~PythonLogOutput() override = default;
 
-  virtual void PrintSelf(std::ostream & os, itk::Indent indent) const override;
+  virtual void PrintSelf(std::ostream& os, itk::Indent indent) const override;
 
 private:
-  CallbackType * m_Callback; 
+  CallbackType* m_Callback;
 };
 
 } // namespace otb
-- 
GitLab