From cd8ea1c043f6a918d31d686ed2c4f1e989a9d27c Mon Sep 17 00:00:00 2001
From: Gerardo Tauriello <gerardo.tauriello@unibas.ch>
Date: Thu, 18 Feb 2016 11:51:13 +0100
Subject: [PATCH] Code cleanup: includes into io-subfolders, compile-warnings

---
 modules/gfx/tests/test_ent_pov_export.cc    |  2 +-
 modules/gui/src/data_viewer/data_viewer.cc  |  2 +-
 modules/gui/src/file_loader.hh              |  8 ++++----
 modules/gui/src/file_type_dialog.hh         |  8 ++++----
 modules/io/src/CMakeLists.txt               | 20 ++++++++++++++++----
 modules/io/src/mol/entity_io_sdf_handler.cc |  4 ++--
 modules/io/tests/test_exceptions.cc         |  2 +-
 modules/io/tests/test_io_crd.cc             |  2 +-
 modules/io/tests/test_io_dcd.cc             |  2 +-
 modules/io/tests/test_io_img.cc             |  2 +-
 modules/io/tests/test_io_pdb.cc             |  4 ++--
 modules/io/tests/test_io_sdf.cc             |  2 +-
 modules/io/tests/test_mae_standalone.cc     |  2 +-
 modules/io/tests/test_mmcif_reader.cc       |  6 +++---
 modules/io/tests/test_star_parser.cc        | 10 +++++-----
 15 files changed, 44 insertions(+), 32 deletions(-)

diff --git a/modules/gfx/tests/test_ent_pov_export.cc b/modules/gfx/tests/test_ent_pov_export.cc
index b5c409f96..c7730806a 100644
--- a/modules/gfx/tests/test_ent_pov_export.cc
+++ b/modules/gfx/tests/test_ent_pov_export.cc
@@ -22,7 +22,7 @@
  */
 
 #include <fstream>
-#include <ost/io/load_entity.hh>
+#include <ost/io/mol/load_entity.hh>
 #include <ost/gfx/scene.hh>
 #include <ost/gfx/entity.hh>
 
diff --git a/modules/gui/src/data_viewer/data_viewer.cc b/modules/gui/src/data_viewer/data_viewer.cc
index 0c157df37..5a75d5181 100644
--- a/modules/gui/src/data_viewer/data_viewer.cc
+++ b/modules/gui/src/data_viewer/data_viewer.cc
@@ -30,7 +30,7 @@
 //#include <sstream>
 
 
-//#include <ost/img/io/io_manager.hh>
+//#include <ost/io/io_manager.hh>
 #include <ost/message.hh>
 //#include <ost/img/alg/fft.hh>   
 #include <ost/img/alg/norm.hh>   
diff --git a/modules/gui/src/file_loader.hh b/modules/gui/src/file_loader.hh
index 23419b613..8e2e50758 100644
--- a/modules/gui/src/file_loader.hh
+++ b/modules/gui/src/file_loader.hh
@@ -26,11 +26,11 @@
 #include <ost/gui/module_config.hh>
 
 #include <ost/io/io_exception.hh>
-#include <ost/io/entity_io_handler.hh>
-#include <ost/io/sequence_io_handler.hh>
-#include <ost/io/surface_io_handler.hh>
+#include <ost/io/mol/entity_io_handler.hh>
+#include <ost/io/seq/sequence_io_handler.hh>
+#include <ost/io/mol/surface_io_handler.hh>
 #if OST_IMG_ENABLED
-#include <ost/io/map_io_handler.hh>
+#  include <ost/io/img/map_io_handler.hh>
 #endif
 
 #include <QString>
diff --git a/modules/gui/src/file_type_dialog.hh b/modules/gui/src/file_type_dialog.hh
index 4cd7746af..f1fe6ce5e 100644
--- a/modules/gui/src/file_type_dialog.hh
+++ b/modules/gui/src/file_type_dialog.hh
@@ -27,11 +27,11 @@
 
 
 
-#include <ost/io/entity_io_handler.hh>
-#include <ost/io/sequence_io_handler.hh>
-#include <ost/io/surface_io_handler.hh>
+#include <ost/io/mol/entity_io_handler.hh>
+#include <ost/io/seq/sequence_io_handler.hh>
+#include <ost/io/mol/surface_io_handler.hh>
 #if OST_IMG_ENABLED
-#include <ost/io/map_io_handler.hh>
+#include <ost/io/img/map_io_handler.hh>
 #endif
 
 #include <QDialog>
diff --git a/modules/io/src/CMakeLists.txt b/modules/io/src/CMakeLists.txt
index 58470a331..13d6e3c6a 100644
--- a/modules/io/src/CMakeLists.txt
+++ b/modules/io/src/CMakeLists.txt
@@ -38,12 +38,18 @@ if (ENABLE_IMG)
   foreach(fname ${OST_IO_IMG_SOURCES})
     set(OST_IO_SOURCES ${OST_IO_SOURCES} img/${fname})
   endforeach(fname ${OST_IO_IMG_SOURCES})
-
-  foreach(fname ${OST_IO_IMG_HEADERS})
-    set(OST_IO_HEADERS ${OST_IO_HEADERS} img/${fname})
-  endforeach(fname ${OST_IO_IMG_HEADERS})
 endif()
 
+####################################
+# Add headers in subfolders (additionally) to OST_IO_HEADERS.
+# In the end, we will have two copies (!) of each header in the subfolders.
+# One copy in ost/io/<SUB> and one in ost/io.
+
+# As it's silly to have duplicate headers, this behavior might be removed in the
+# future. So please always include the headers in the subfolders.
+# (e.g. use "#include <ost/io/mol/load_entity.hh>"
+#       instead of #include <ost/io/load_entity.hh>)
+# For compatibility reasons, we keep it for now (dates back to 2010).
 foreach(fname ${OST_IO_MOL_HEADERS})
   set(OST_IO_HEADERS ${OST_IO_HEADERS} mol/${fname})
 endforeach(fname ${OST_IO_MOL_HEADERS})
@@ -52,6 +58,12 @@ foreach(fname ${OST_IO_SEQ_HEADERS})
   set(OST_IO_HEADERS ${OST_IO_HEADERS} seq/${fname})
 endforeach(fname ${OST_IO_SEQ_HEADERS})
 
+if (ENABLE_IMG)
+  foreach(fname ${OST_IO_IMG_HEADERS})
+    set(OST_IO_HEADERS ${OST_IO_HEADERS} img/${fname})
+  endforeach(fname ${OST_IO_IMG_HEADERS})
+endif()
+####################################
 
 set(OST_IO_DEPENDENCIES ost_base;ost_conop;ost_seq)
 if (ENABLE_IMG)
diff --git a/modules/io/src/mol/entity_io_sdf_handler.cc b/modules/io/src/mol/entity_io_sdf_handler.cc
index 31ba544b0..e99933ec3 100644
--- a/modules/io/src/mol/entity_io_sdf_handler.cc
+++ b/modules/io/src/mol/entity_io_sdf_handler.cc
@@ -21,8 +21,8 @@
  */
 
 #include <ost/log.hh>
-#include <ost/io/sdf_writer.hh>
-#include <ost/io/sdf_reader.hh>
+#include <ost/io/mol/sdf_writer.hh>
+#include <ost/io/mol/sdf_reader.hh>
 
 #include "entity_io_sdf_handler.hh"
 
diff --git a/modules/io/tests/test_exceptions.cc b/modules/io/tests/test_exceptions.cc
index 2ed51ce3e..27d9ea661 100644
--- a/modules/io/tests/test_exceptions.cc
+++ b/modules/io/tests/test_exceptions.cc
@@ -25,7 +25,7 @@
 #include <boost/test/unit_test.hpp>
 #include <boost/test/auto_unit_test.hpp>
 
-#include <ost/io/load_map.hh>
+#include <ost/io/img/load_map.hh>
 #include <ost/img/image.hh>
 #include <ost/io/io_exception.hh>
 
diff --git a/modules/io/tests/test_io_crd.cc b/modules/io/tests/test_io_crd.cc
index b317e936b..4cde64f32 100644
--- a/modules/io/tests/test_io_crd.cc
+++ b/modules/io/tests/test_io_crd.cc
@@ -23,7 +23,7 @@
 #include <ost/test_utils/compare_files.hh>
 #include <ost/mol/mol.hh>
 #include <ost/io/mol/entity_io_crd_handler.hh>
-#include <ost/io/save_entity.hh>
+#include <ost/io/mol/save_entity.hh>
 
 using namespace ost;
 using namespace ost::io;
diff --git a/modules/io/tests/test_io_dcd.cc b/modules/io/tests/test_io_dcd.cc
index 016555e69..fb95e6e83 100644
--- a/modules/io/tests/test_io_dcd.cc
+++ b/modules/io/tests/test_io_dcd.cc
@@ -74,7 +74,7 @@ BOOST_AUTO_TEST_CASE(test_io_dcd_charmm_frames)
   SaveCHARMMTraj(cg,"test_io_dcd_out.pdb","test_io_dcd_out.dcd");
   mol::CoordGroupHandle cg2=LoadCHARMMTraj(eh,"test_io_dcd_out.dcd");
   BOOST_CHECK_EQUAL(cg2.GetAtomCount(),natoms);
-  BOOST_CHECK_EQUAL(cg2.GetFrameCount(),1);
+  BOOST_CHECK_EQUAL(cg2.GetFrameCount(),uint(1));
 
   mol::CoordFramePtr cf2 = cg2.GetFrame(0);
   BOOST_CHECK(geom::Distance(cf2->GetCellSize(),cell_size)<1e-6);
diff --git a/modules/io/tests/test_io_img.cc b/modules/io/tests/test_io_img.cc
index 78093264b..411201a97 100644
--- a/modules/io/tests/test_io_img.cc
+++ b/modules/io/tests/test_io_img.cc
@@ -21,7 +21,7 @@
 #include <boost/test/auto_unit_test.hpp>
 
 #include <map>
-#include <ost/io/load_map.hh>
+#include <ost/io/img/load_map.hh>
 #include <ost/img/image_factory.hh>
 #include <ost/img/alg/randomize.hh>
 #include  <ost/io/img/map_io_df3_handler.hh>
diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc
index 7d33d8bce..ff4d3a8db 100644
--- a/modules/io/tests/test_io_pdb.cc
+++ b/modules/io/tests/test_io_pdb.cc
@@ -32,8 +32,8 @@ using boost::unit_test_framework::test_suite;
 #include <ost/conop/heuristic.hh>
 
 #include <ost/io/mol/entity_io_pdb_handler.hh>
-#include <ost/io/pdb_reader.hh>
-#include <ost/io/pdb_writer.hh>
+#include <ost/io/mol/pdb_reader.hh>
+#include <ost/io/mol/pdb_writer.hh>
 #include <ost/log.hh>
 
 #include <ost/io/io_exception.hh>
diff --git a/modules/io/tests/test_io_sdf.cc b/modules/io/tests/test_io_sdf.cc
index 289bdfea3..c90b80b30 100644
--- a/modules/io/tests/test_io_sdf.cc
+++ b/modules/io/tests/test_io_sdf.cc
@@ -27,7 +27,7 @@ using boost::unit_test_framework::test_suite;
 #include <ost/test_utils/compare_files.hh>
 #include <ost/mol/mol.hh>
 #include <ost/io/mol/entity_io_sdf_handler.hh>
-#include <ost/io/save_entity.hh>
+#include <ost/io/mol/save_entity.hh>
 #include <ost/io/io_exception.hh>
 
 using namespace ost;
diff --git a/modules/io/tests/test_mae_standalone.cc b/modules/io/tests/test_mae_standalone.cc
index 10395fb69..48d19c3da 100644
--- a/modules/io/tests/test_mae_standalone.cc
+++ b/modules/io/tests/test_mae_standalone.cc
@@ -1,6 +1,6 @@
 #include <ost/log.hh>
 #include <ost/conop/conop.hh>
-#include <ost/io/entity_io_mae_handler.hh>
+#include <ost/io/mol/entity_io_mae_handler.hh>
 
 using namespace ost;
 
diff --git a/modules/io/tests/test_mmcif_reader.cc b/modules/io/tests/test_mmcif_reader.cc
index 3a1906df9..40f81cd8c 100644
--- a/modules/io/tests/test_mmcif_reader.cc
+++ b/modules/io/tests/test_mmcif_reader.cc
@@ -644,14 +644,14 @@ BOOST_AUTO_TEST_CASE(mmcif_struct_ref)
   MMCifReader mmcif_p(s, eh, profile);
   mmcif_p.Parse();
   MMCifInfoStructRefs refs=mmcif_p.GetInfo().GetStructRefs();
-  BOOST_CHECK_EQUAL(refs.size(), 1);
+  BOOST_CHECK_EQUAL(refs.size(), size_t(1));
   MMCifInfoStructRefPtr sr1=refs[0];
   BOOST_CHECK_EQUAL(sr1->GetDBName(), "UNP");
   BOOST_CHECK_EQUAL(sr1->GetDBID(), "BLA2_BACCE");
   BOOST_CHECK_EQUAL(sr1->GetDBAccess(), "P04190");
   BOOST_CHECK_EQUAL(sr1->GetID(), "1");
   MMCifInfoStructRefSeqs seqs=sr1->GetAlignedSeqs();
-  BOOST_CHECK_EQUAL(seqs.size(), 2);
+  BOOST_CHECK_EQUAL(seqs.size(), size_t(2));
   BOOST_CHECK_EQUAL(seqs[0]->GetID(), "1");
   BOOST_CHECK_EQUAL(seqs[0]->GetChainName(), "A");
   BOOST_CHECK_EQUAL(seqs[0]->GetSeqBegin(), 1);
@@ -665,7 +665,7 @@ BOOST_AUTO_TEST_CASE(mmcif_struct_ref)
   BOOST_CHECK_EQUAL(seqs[1]->GetDBBegin(), 31);
   BOOST_CHECK_EQUAL(seqs[1]->GetDBEnd(), 49);
   MMCifInfoStructRefSeqDifs diffs=seqs[0]->GetDifs();
-  BOOST_CHECK_EQUAL(diffs.size(), 1);
+  BOOST_CHECK_EQUAL(diffs.size(), size_t(1));
   BOOST_CHECK_EQUAL(diffs[0]->GetSeqRNum(), 91);
   BOOST_CHECK_EQUAL(diffs[0]->GetDetails(), "ENGINEERED MUTATION");
 }
diff --git a/modules/io/tests/test_star_parser.cc b/modules/io/tests/test_star_parser.cc
index 4d6118078..40cdf674f 100644
--- a/modules/io/tests/test_star_parser.cc
+++ b/modules/io/tests/test_star_parser.cc
@@ -137,19 +137,19 @@ public:
     BOOST_CHECK_EQUAL(columns[0].size(), static_cast<size_t>(1));
     ++cur_char_;
     BOOST_CHECK_EQUAL(columns[1][0], cur_char_);
-    BOOST_CHECK_EQUAL(columns[1].size(), 1);
+    BOOST_CHECK_EQUAL(columns[1].size(), static_cast<size_t>(1));
     ++cur_char_;
     BOOST_CHECK_EQUAL(columns[2][0], cur_char_);
-    BOOST_CHECK_EQUAL(columns[2].size(), 1);    
+    BOOST_CHECK_EQUAL(columns[2].size(), static_cast<size_t>(1));    
     ++cur_char_;
     BOOST_CHECK_EQUAL(columns[3][0], cur_char_);
-    BOOST_CHECK_EQUAL(columns[3].size(), 1);    
+    BOOST_CHECK_EQUAL(columns[3].size(), static_cast<size_t>(1));    
     ++cur_char_;
     BOOST_CHECK_EQUAL(columns[4][0], cur_char_);
-    BOOST_CHECK_EQUAL(columns[4].size(), 1);    
+    BOOST_CHECK_EQUAL(columns[4].size(), static_cast<size_t>(1));    
     ++cur_char_;
     BOOST_CHECK_EQUAL(columns[5][0], cur_char_);
-    BOOST_CHECK_EQUAL(columns[5].size(), 1);
+    BOOST_CHECK_EQUAL(columns[5].size(), static_cast<size_t>(1));
     ++cur_char_;
   }
   
-- 
GitLab