From 8c25bb88da272ec4a71ced949f83dc56c0a3977d Mon Sep 17 00:00:00 2001
From: Antoine Regimbeau <antoine.regimbeau@c-s.fr>
Date: Tue, 6 Feb 2018 16:13:07 +0100
Subject: [PATCH] TEST : still adding trace

---
 Modules/Core/Common/src/otbFilterWatcherBase.cxx          | 1 +
 .../Core/Common/src/otbStandardOneLineFilterWatcher.cxx   | 3 +++
 Modules/Core/ImageBase/include/otbImage.h                 | 4 +++-
 Modules/Core/ImageBase/include/otbImage.txx               | 5 +++++
 Modules/Core/ImageBase/include/otbVectorImage.h           | 4 +++-
 Modules/Core/ImageBase/include/otbVectorImage.txx         | 4 ++++
 .../include/otbWrapperAddProcessToWatchEvent.h            | 8 ++++++--
 .../ApplicationEngine/src/otbWrapperApplication.cxx       | 2 ++
 8 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/Modules/Core/Common/src/otbFilterWatcherBase.cxx b/Modules/Core/Common/src/otbFilterWatcherBase.cxx
index 2e4f9644bb..bbb564b02c 100644
--- a/Modules/Core/Common/src/otbFilterWatcherBase.cxx
+++ b/Modules/Core/Common/src/otbFilterWatcherBase.cxx
@@ -159,6 +159,7 @@ FilterWatcherBase
 FilterWatcherBase
 ::~FilterWatcherBase()
 {
+  std::cout<<"A FilterWatcherBase is deleted... Description was "<<m_Comment<<std::endl;
   // Remove any observers we have on the old process object
   if (m_Process)
     {
diff --git a/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx b/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx
index 77e350402f..84c67d05c9 100644
--- a/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx
+++ b/Modules/Core/Common/src/otbStandardOneLineFilterWatcher.cxx
@@ -29,6 +29,7 @@ StandardOneLineFilterWatcher
   : m_StarsCount(50),
     m_CurrentNbStars(-1)
 {
+  std::cout<<"A StandardOneLineFilterWatcher is created (default)"<<std::endl;
 }
 
 StandardOneLineFilterWatcher
@@ -38,6 +39,7 @@ StandardOneLineFilterWatcher
     m_StarsCount(50),
     m_CurrentNbStars(-1)
 {
+  std::cout<<"A StandardOneLineFilterWatcher is created with description "<<comment<<std::endl;
 }
 
 StandardOneLineFilterWatcher
@@ -47,6 +49,7 @@ StandardOneLineFilterWatcher
     m_StarsCount(50),
     m_CurrentNbStars(-1)
 {
+    std::cout<<"A StandardOneLineFilterWatcher is created with description "<<comment<<std::endl;
 }
 
 void
diff --git a/Modules/Core/ImageBase/include/otbImage.h b/Modules/Core/ImageBase/include/otbImage.h
index 53462952af..4eb2ec9388 100644
--- a/Modules/Core/ImageBase/include/otbImage.h
+++ b/Modules/Core/ImageBase/include/otbImage.h
@@ -179,7 +179,7 @@ public:
 //   {
 //     return AccessorType();
 //   }
-
+  static int m_Instance;
   /** Return the NeighborhoodAccessor functor */
   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
   {
@@ -254,6 +254,8 @@ protected:
   Image();
   ~Image() ITK_OVERRIDE {
     std::cout<<"An image is deleted"<<std::endl;
+    m_Instance--;
+    std::cout<<m_Instance<<" image(s) still live(s)"<<std::endl;
   }
 
 private:
diff --git a/Modules/Core/ImageBase/include/otbImage.txx b/Modules/Core/ImageBase/include/otbImage.txx
index 01b6fc3669..6127e6b48d 100644
--- a/Modules/Core/ImageBase/include/otbImage.txx
+++ b/Modules/Core/ImageBase/include/otbImage.txx
@@ -29,10 +29,15 @@
 namespace otb
 {
 
+template <class TPixel, unsigned int VImageDimension>
+int Image<TPixel, VImageDimension>::m_Instance = 0;
+
 template <class TPixel, unsigned int VImageDimension>
 Image<TPixel, VImageDimension>::Image()
 {
   std::cout<<"An image is created"<<std::endl;
+  m_Instance++;
+  std::cout<<m_Instance<<" image(s) live(s)"<<std::endl;
 }
 
 template <class TPixel, unsigned int VImageDimension>
diff --git a/Modules/Core/ImageBase/include/otbVectorImage.h b/Modules/Core/ImageBase/include/otbVectorImage.h
index 9e948ec5c9..edd3b267c9 100644
--- a/Modules/Core/ImageBase/include/otbVectorImage.h
+++ b/Modules/Core/ImageBase/include/otbVectorImage.h
@@ -179,7 +179,7 @@ public:
 //   {
 //     return AccessorType( this->GetNumberOfComponentsPerPixel() );
 //   }
-
+  static int m_Instance;
   /** Return the NeighborhoodAccessor functor */
   NeighborhoodAccessorFunctorType GetNeighborhoodAccessor()
   {
@@ -196,6 +196,8 @@ protected:
   VectorImage();
   ~VectorImage() ITK_OVERRIDE {
     std::cout<<"A vector image is deleted"<<std::endl;
+    m_Instance--;
+    std::cout<<m_Instance<<" vector image(s) still live(s)"<<std::endl;
   }
 
 private:
diff --git a/Modules/Core/ImageBase/include/otbVectorImage.txx b/Modules/Core/ImageBase/include/otbVectorImage.txx
index 83c3f0f6e7..0d95d4c6e9 100644
--- a/Modules/Core/ImageBase/include/otbVectorImage.txx
+++ b/Modules/Core/ImageBase/include/otbVectorImage.txx
@@ -29,11 +29,15 @@
 
 namespace otb
 {
+template <class TPixel, unsigned int VImageDimension>
+int VectorImage<TPixel, VImageDimension>::m_Instance = 0;
 
 template <class TPixel, unsigned int VImageDimension>
 VectorImage<TPixel, VImageDimension>::VectorImage()
 {
   std::cout<<"A vector image is created"<<std::endl;
+  m_Instance++;
+  std::cout<<m_Instance<<" vector image(s) live(s)"<<std::endl;
 }
 
 template <class TPixel, unsigned int VImageDimension>
diff --git a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h
index 3cf9114c81..129e1e74ea 100644
--- a/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h
+++ b/Modules/Wrappers/ApplicationEngine/include/otbWrapperAddProcessToWatchEvent.h
@@ -44,9 +44,13 @@ public:
   typedef AddProcessToWatchEvent Self;
   typedef itk::EventObject       Superclass;
 
-  AddProcessToWatchEvent(){}
+  AddProcessToWatchEvent(){
+    std::cout<<"A new AddProcessToWatchEvent is created"<<std::endl;
+  }
   AddProcessToWatchEvent(const Self& s) :itk::EventObject(s){};
-  ~AddProcessToWatchEvent() ITK_OVERRIDE {}
+  ~AddProcessToWatchEvent() ITK_OVERRIDE {
+    std::cout<<"The AddProcessToWatchEvent is deleted... Description was : "<<m_ProcessDescription<<std::endl;
+  }
 
   /** Set/Get the process to watch */
   virtual void SetProcess(itk::ProcessObject * process)
diff --git a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
index 988f9f7243..89fca70c59 100644
--- a/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
+++ b/Modules/Wrappers/ApplicationEngine/src/otbWrapperApplication.cxx
@@ -410,6 +410,7 @@ int Application::Execute()
 
 int Application::ExecuteAndWriteOutput()
 {
+  std::cout<<"Executing..."<<std::endl;
   m_Chrono.Restart();
 
   int status = this->Execute();
@@ -465,6 +466,7 @@ int Application::ExecuteAndWriteOutput()
               }
             std::ostringstream progressId;
             progressId << "Writing " << outputParam->GetFileName() << "...";
+            std::cout<<"Add Process and write"<<std::endl;
             AddProcess(outputParam->GetWriter(), progressId.str());
             outputParam->Write();
             }
-- 
GitLab