From 07c6de6ffd18984c47b59c7d1dff4bab93350f2d Mon Sep 17 00:00:00 2001
From: Manuel Grizonnet <manuel.grizonnet@gmail.com>
Date: Wed, 14 Oct 2009 13:51:57 +0200
Subject: [PATCH] ENH: add parameter to OTBconfigfile

---
 CMake/GenerateConfigProperties.cpp | 102 ++++++++++-------------------
 CMakeLists.txt                     |   2 +-
 2 files changed, 35 insertions(+), 69 deletions(-)

diff --git a/CMake/GenerateConfigProperties.cpp b/CMake/GenerateConfigProperties.cpp
index a9aba0dd6c..239a5737a5 100644
--- a/CMake/GenerateConfigProperties.cpp
+++ b/CMake/GenerateConfigProperties.cpp
@@ -22,6 +22,7 @@ PURPOSE.  See the above copyright notices for more information.
 #include <fstream>
 #include <string>
 #include <iostream>
+#include <vector>
 
 /**
  * @brief main application for generating the otb.conf file.
@@ -32,87 +33,52 @@ PURPOSE.  See the above copyright notices for more information.
  */
 int main(int argc, char* argv[])
 {
-   if (argc != 3)
-   {
-      exit(1);
-   }
+   const unsigned int nbParameters = 3;
+//    if (argc != 5)
+//    {
+//       exit(1);
+//    }
 
-   std::ofstream os(argv[1]);
+   std::ofstream os(argv[1]); 
    if (!os)
    {
       exit(1);
    }
-    /*
-   // Get the version.  This is now passed in from the make file.
-   std::string versionString = "Version ";
-   versionString += argv[2];
-   std::string versionNumber = argv[2];
-   std::string majorVersion;
-   std::string minorVersion = "0";
-   std::string releaseVersion = "0";
-   std::string::size_type pos1 = std::string::npos;
-   std::string::size_type pos2 = std::string::npos;
 
-   pos1 = versionNumber.find(".", 0);
-   if(pos1 != std::string::npos)
+   std::vector <std::string>  paramVector;
+   
+   /* write available parameters to a vector */
+   for (unsigned int i=0;i<nbParameters;++i)
    {
-      majorVersion = std::string(versionNumber.begin(),
-                                 versionNumber.begin()+pos1);
-      pos2 = versionNumber.find(".", pos1+1);
-      if(pos2 != std::string::npos)
-      {
-         minorVersion = std::string(versionNumber.begin()+pos1+1,
-                                    versionNumber.begin()+pos2);
-         releaseVersion = std::string(versionNumber.begin()+pos2+1,
-                                      versionNumber.end());
-      }
+     if ( argc >= ( i+3 ) )
+     {
+       /** Get the default parameter (from cmake)*/
+       paramVector.push_back( argv[i+2] );
+     }
+     else
+     {
+       /** Set param="" if the parameter is not available*/
+       paramVector.push_back("");
+     }
    }
-   else
-   {
-      majorVersion = versionNumber;
-   }
-   // Get the build date in the format of (yyyymmdd).
-   char s[11];
-   s[10] = '\0';
-   time_t t;
-   time(&t);
-   tm* lt = localtime(&t);
-   strftime(s, 11, "(%Y%m%d)", lt);
-   std::string date = s;
-
-   // Write the header file.
-   os << "// Auto generated by version-config - DO NOT EDIT\n"
-      << "#ifndef ossimVersion_HEADER\n"
-      << "#define ossimVersion_HEADER\n"
-      << "\n"
-      << "#include <ossim/ossimConfig.h>\n"
-      << "\n"
-      << "#ifndef OSSIM_VERSION\n"
-      << "#  define OSSIM_VERSION " << "\"" << versionString << "\"\n"
-      << "#  define OSSIM_VERSION_NUMBER " << "\"" << versionNumber << "\"\n"
-      << "#  define OSSIM_MAJOR_VERSION_NUMBER " << majorVersion << "\n"
-      << "#  define OSSIM_MINOR_VERSION_NUMBER " << minorVersion << "\n"
-      << "#  define OSSIM_RELEASE_NUMBER " << releaseVersion << "\n"
-      << "#endif\n"
-      << "\n"
-      << "// date format = (yyyymmdd)\n"
-      << "#ifndef OSSIM_BUILD_DATE\n"
-      << "#  define OSSIM_BUILD_DATE " << "\"" << date << "\"\n"
-      << "#endif\n"
-      << "\n"
-      << "#endif /* End of #ifndef ossimVersion_HEADER "
-      << std::endl;
-   */
-   std::string language(argv[2]);
-
+   
+//    std::string language(argv[2]);
+//    std::string activateStreaming(argv[3]);
+//    std::string sizeStreaming(argv[4]);
 
    os << "#Auto generated by config-properties \n"
-      << "#Language \n"
       << "OTB_LANG="
-      <<  language
+      <<  paramVector[0]
+      << "\n"
+      << "OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING="
+      <<  paramVector[1]
+      << "\n"
+      << "OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING="
+      <<  paramVector[2]
       << "\n"
-      << "# end of config file properties generation"
+      << "#End of config file properties generation"
       << std::endl;
+   
    os.close();
 
    std::cout << "wrote file: " << argv[1] << std::endl;
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e5d371b915..265aa8e3ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1136,5 +1136,5 @@ ADD_CUSTOM_COMMAND(
           TARGET GenerateConfigProperties
           POST_BUILD
           COMMAND GenerateConfigProperties
-          ARGS "${otbconfigfile_DEFAULT}" "${OTB_LANG}"
+          ARGS "${otbconfigfile_DEFAULT}" "${OTB_LANG}" "${OTB_STREAM_IMAGE_SIZE_TO_ACTIVATE_STREAMING}" "${OTB_STREAM_MAX_SIZE_BUFFER_FOR_STREAMING}"
           COMMENT "Generating ${otbconfigfile_DEFAULT}" )
-- 
GitLab