From 40ed51181d3ba2c9d18d8f165d2921eaa10a5350 Mon Sep 17 00:00:00 2001
From: Giovanni La Mura <giovanni.lamura@inaf.it>
Date: Tue, 9 Jan 2024 15:40:42 +0100
Subject: [PATCH] Remove recursive inclusions

---
 src/cluster/cluster.cpp       | 13 +++++++++++++
 src/cluster/np_cluster.cpp    |  2 ++
 src/include/Commons.h         |  6 ++----
 src/include/Configuration.h   |  4 ----
 src/include/List.h            |  3 ---
 src/include/clu_subs.h        | 10 ----------
 src/include/sph_subs.h        |  6 ------
 src/include/tra_subs.h        |  8 --------
 src/libnptm/Commons.cpp       |  1 +
 src/libnptm/Configuration.cpp | 10 ++++++++++
 src/libnptm/clu_subs.cpp      | 11 +++++++++++
 src/libnptm/sph_subs.cpp      |  7 +++++++
 src/libnptm/tra_subs.cpp      | 13 +++++++++++++
 src/sphere/np_sphere.cpp      |  3 ++-
 src/sphere/sphere.cpp         |  8 ++++++++
 src/trapping/frfme.cpp        | 18 ++++++++++++------
 src/trapping/lffft.cpp        | 19 ++++++++++++++-----
 17 files changed, 95 insertions(+), 47 deletions(-)

diff --git a/src/cluster/cluster.cpp b/src/cluster/cluster.cpp
index d37fff97..559375ff 100644
--- a/src/cluster/cluster.cpp
+++ b/src/cluster/cluster.cpp
@@ -1,10 +1,23 @@
+/*! \file cluster.cpp
+ */
 #include <cstdio>
 #include <fstream>
 #include <string>
 #include <complex>
+
 #ifndef INCLUDE_CONFIGURATION_H_
+#include <exception>
 #include "../include/Configuration.h"
 #endif
+
+#ifndef INCLUDE_COMMONS_H_
+#include "../include/Commons.h"
+#endif
+
+#ifndef INCLUDE_SPH_SUBS_H_
+#include "../include/sph_subs.h"
+#endif
+
 #ifndef INCLUDE_CLU_SUBS_H_
 #include "../include/clu_subs.h"
 #endif
diff --git a/src/cluster/np_cluster.cpp b/src/cluster/np_cluster.cpp
index e9a85e79..0af2b80f 100644
--- a/src/cluster/np_cluster.cpp
+++ b/src/cluster/np_cluster.cpp
@@ -2,7 +2,9 @@
  */
 
 #include <cstdio>
+#include <complex>
 #include <string>
+
 #ifndef INCLUDE_CONFIGURATION_H_
 #include "../include/Configuration.h"
 #endif
diff --git a/src/include/Commons.h b/src/include/Commons.h
index 7a45deaf..6ad2a011 100644
--- a/src/include/Commons.h
+++ b/src/include/Commons.h
@@ -14,10 +14,8 @@
  *
  */
 
-#ifndef INCLUDE_COMMONS_
-#define INCLUDE_COMMONS_
-
-#include <complex>
+#ifndef INCLUDE_COMMONS_H_
+#define INCLUDE_COMMONS_H_
 
 /*! \brief Representation of the FORTRAN C1 common blocks.
  *
diff --git a/src/include/Configuration.h b/src/include/Configuration.h
index c23ac692..a4cf7f44 100644
--- a/src/include/Configuration.h
+++ b/src/include/Configuration.h
@@ -4,10 +4,6 @@
 #ifndef INCLUDE_CONFIGURATION_H_
 #define INCLUDE_CONFIGURATION_H_
 
-#include <complex>
-#include <exception>
-#include <string>
-
 /**
  * \brief Exception for open file error handlers.
  */
diff --git a/src/include/List.h b/src/include/List.h
index 98fa3b12..0f9ebeab 100644
--- a/src/include/List.h
+++ b/src/include/List.h
@@ -4,9 +4,6 @@
 #ifndef INCLUDE_LIST_H_
 #define INCLUDE_LIST_H_
 
-#include <exception>
-#include <string>
-
 /**
  * \brief Exception for out of bounds List requests.
  */
diff --git a/src/include/clu_subs.h b/src/include/clu_subs.h
index 9351e6ea..9bc2f72a 100644
--- a/src/include/clu_subs.h
+++ b/src/include/clu_subs.h
@@ -12,19 +12,9 @@
  * output arguments passed by reference.
  */
 
-#ifndef INCLUDE_COMMONS_H_
-#include "Commons.h"
-#endif
-
-#ifndef INCLUDE_SPH_SUBS_H_
-#include "../include/sph_subs.h"
-#endif
-
 #ifndef INCLUDE_CLU_SUBS_H_
 #define INCLUDE_CLU_SUBS_H_
 
-#include <complex>
-
 /*! \brief C++ porting of APC
  *
  * \param zpv: `double ****`
diff --git a/src/include/sph_subs.h b/src/include/sph_subs.h
index e698cfdb..8adc50d0 100644
--- a/src/include/sph_subs.h
+++ b/src/include/sph_subs.h
@@ -11,15 +11,9 @@
  * output arguments passed by reference.
  */
 
-#ifndef INCLUDE_COMMONS_H_
-#include "Commons.h"
-#endif
-
 #ifndef INCLUDE_SPH_SUBS_H_
 #define INCLUDE_SPH_SUBS_H_
 
-#include <complex>
-
 /*! \brief Compute the asymmetry-corrected scattering cross-section.
  *
  * This function computes the product between the geometrical asymmetry parameter and
diff --git a/src/include/tra_subs.h b/src/include/tra_subs.h
index 1478812e..33d9781b 100644
--- a/src/include/tra_subs.h
+++ b/src/include/tra_subs.h
@@ -16,14 +16,6 @@
 #define INCLUDE_TRA_SUBS_H_
 #endif
 
-#ifndef INCLUDE_SPH_SUBS_H_
-#include "../include/sph_subs.h"
-#endif
-
-#include <fstream>
-#include <cmath>
-#include <complex>
-
 // Structures for TRAPPING
 /*! \brief CIL data structure.
  *
diff --git a/src/libnptm/Commons.cpp b/src/libnptm/Commons.cpp
index 6717bac3..8031eaad 100644
--- a/src/libnptm/Commons.cpp
+++ b/src/libnptm/Commons.cpp
@@ -10,6 +10,7 @@
  *	to the configuration objects. These, on their turn, need to
  *	expose methods to access the relevant data in read-only mode.
  */
+#include <complex>
 
 #ifndef INCLUDE_COMMONS_H
 #include "../include/Commons.h"
diff --git a/src/libnptm/Configuration.cpp b/src/libnptm/Configuration.cpp
index 9dff8f8f..12524367 100644
--- a/src/libnptm/Configuration.cpp
+++ b/src/libnptm/Configuration.cpp
@@ -2,13 +2,23 @@
  */
 
 #include <cmath>
+#include <complex>
 #include <cstdio>
 #include <fstream>
 #include <regex>
 #include <string>
+
+#ifndef INCLUDE_LIST_H_
 #include "../include/List.h"
+#endif
+
+#ifndef INCLUDE_PARSERS_H_
 #include "../include/Parsers.h"
+#endif
+
+#ifndef INCLUDE_CONFIGURATION_H_
 #include "../include/Configuration.h"
+#endif
 
 using namespace std;
 
diff --git a/src/libnptm/clu_subs.cpp b/src/libnptm/clu_subs.cpp
index b1fb2d3d..b516e576 100644
--- a/src/libnptm/clu_subs.cpp
+++ b/src/libnptm/clu_subs.cpp
@@ -2,8 +2,19 @@
  *
  * \brief C++ implementation of CLUSTER subroutines.
  */
+#include <complex>
 
+#ifndef INCLUDE_COMMONS_H_
+#include "../include/Commons.h"
+#endif
+
+#ifndef INCLUDE_SPH_SUBS_H_
+#include "../include/sph_subs.h"
+#endif
+
+#ifndef INCLUDE_CLU_SUBS_H_
 #include "../include/clu_subs.h"
+#endif
 
 using namespace std;
 
diff --git a/src/libnptm/sph_subs.cpp b/src/libnptm/sph_subs.cpp
index 02c2d5a9..99aa4d7f 100644
--- a/src/libnptm/sph_subs.cpp
+++ b/src/libnptm/sph_subs.cpp
@@ -2,8 +2,15 @@
  *
  * \brief C++ implementation of SPHERE subroutines.
  */
+#include <complex>
 
+#ifndef INCLUDE_COMMONS_H_
+#include "../include/Commons.h"
+#endif
+
+#ifndef INCLUDE_SPH_SUBS_H_
 #include "../include/sph_subs.h"
+#endif
 
 using namespace std;
 
diff --git a/src/libnptm/tra_subs.cpp b/src/libnptm/tra_subs.cpp
index 73d38098..13a5aa9a 100644
--- a/src/libnptm/tra_subs.cpp
+++ b/src/libnptm/tra_subs.cpp
@@ -2,8 +2,21 @@
  *
  * \brief C++ implementation of TRAPPING subroutines.
  */
+#include <cmath>
+#include <complex>
+#include <fstream>
 
+#ifndef INCLUDE_COMMONS_H_
+#include "../include/Commons.h"
+#endif
+
+#ifndef INCLUDE_SPH_SUBS_H_
+#include "../include/sph_subs.h"
+#endif
+
+#ifndef INCLUDE_TRA_SUBS_H_
 #include "../include/tra_subs.h"
+#endif
 
 using namespace std;
 
diff --git a/src/sphere/np_sphere.cpp b/src/sphere/np_sphere.cpp
index 9449ace4..1846b369 100644
--- a/src/sphere/np_sphere.cpp
+++ b/src/sphere/np_sphere.cpp
@@ -1,8 +1,9 @@
 /*! \file np_sphere.cpp
  */
-
+#include <complex>
 #include <cstdio>
 #include <string>
+
 #ifndef INCLUDE_CONFIGURATION_H_
 #include "../include/Configuration.h"
 #endif
diff --git a/src/sphere/sphere.cpp b/src/sphere/sphere.cpp
index 4c4892f9..897643be 100644
--- a/src/sphere/sphere.cpp
+++ b/src/sphere/sphere.cpp
@@ -1,10 +1,18 @@
+/*! \file sphere.cpp
+ */
 #include <cstdio>
 #include <fstream>
 #include <string>
 #include <complex>
+
 #ifndef INCLUDE_CONFIGURATION_H_
 #include "../include/Configuration.h"
 #endif
+
+#ifndef INCLUDE_COMMONS_H_
+#include "../include/Commons.h"
+#endif
+
 #ifndef INCLUDE_SPH_SUBS_H_
 #include "../include/sph_subs.h"
 #endif
diff --git a/src/trapping/frfme.cpp b/src/trapping/frfme.cpp
index c0084283..bf5ab5aa 100644
--- a/src/trapping/frfme.cpp
+++ b/src/trapping/frfme.cpp
@@ -1,17 +1,23 @@
 /*! \file frfme.cpp
- *
- * \brief C++ implementation of FRFME.
  */
-
+#include <complex>
 #include <cstdio>
+#include <fstream>
 #include <regex>
 #include <string>
+
 #ifndef INCLUDE_PARSERS_H_
 #include "../include/Parsers.h"
 #endif
-//#ifndef INCLUDE_SPH_SUBS_H_
-//#include "../include/sph_subs.h"
-//#endif
+
+#ifndef INCLUDE_COMMONS_H_
+#include "../include/Commons.h"
+#endif
+
+#ifndef INCLUDE_SPH_SUBS_H_
+#include "../include/sph_subs.h"
+#endif
+
 #ifndef INCLUDE_TRA_SUBS_H_
 #include "../include/tra_subs.h"
 #endif
diff --git a/src/trapping/lffft.cpp b/src/trapping/lffft.cpp
index 20bb1aeb..98bfd19c 100644
--- a/src/trapping/lffft.cpp
+++ b/src/trapping/lffft.cpp
@@ -1,21 +1,30 @@
+/*! \file lffft.cpp
+ */
+#include <complex>
 #include <cstdio>
 #include <fstream>
 #include <regex>
 #include <string>
-#include <complex>
+
 #ifndef INCLUDE_PARSERS_H_
 #include "../include/Parsers.h"
 #endif
-//#ifndef INCLUDE_SPH_SUBS_H_
-//#include "../include/sph_subs.h"
-//#endif
+
+#ifndef INCLUDE_COMMONS_H_
+#include "../include/Commons.h"
+#endif
+
+#ifndef INCLUDE_SPH_SUBS_H_
+#include "../include/sph_subs.h"
+#endif
+
 #ifndef INCLUDE_TRA_SUBS_H_
 #include "../include/tra_subs.h"
 #endif
 
 using namespace std;
 
-/*! \brief C++ implementation of FRFME
+/*! \brief C++ implementation of LFFFT
  *
  *  \param data_file: `string` Name of the input data file.
  *  \param output_path: `string` Directory to write the output files in.
-- 
GitLab