]> Creatis software - bbtk.git/commitdiff
Merge branch 'refs/heads/bbpCreator'
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Tue, 9 Jul 2013 21:20:40 +0000 (23:20 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Tue, 9 Jul 2013 21:20:40 +0000 (23:20 +0200)
kernel/appli/CMakeLists.txt
kernel/appli/bbpConfigurator/CMakeLists.txt [new file with mode: 0644]
kernel/appli/bbpConfigurator/bbpConfigurator.cpp [new file with mode: 0644]
kernel/cmake/BBTKConfigurePackagePaths.cmake
kernel/cmake/BBTKConfigurePackage_bbs.cmake
kernel/cmake/BBTKConfigurePackage_src.cmake
kernel/cmake/BBTKCreatePackageIncludeScript.cmake
kernel/cmake/BBTKKernelConfig.cmake
kernel/cmake/BBTKSetDeducedPaths.cmake
kernel/src/bbtkBBPInterpreter.cxx [new file with mode: 0644]
kernel/src/bbtkBBPInterpreter.h [new file with mode: 0644]

index b8718fe0f3c7121c9fbc56316450ba091aa7ab7c..009a0115a1bb8d1a0b717570a5633ab3fe7e85b3 100644 (file)
@@ -68,4 +68,7 @@ ADD_SUBDIRECTORY(bbPostInstallPackage)
 
 ADD_SUBDIRECTORY(bbPlugPackage)
 
+#Automatic bbp generator
+ADD_SUBDIRECTORY(bbpConfigurator)
+
 
diff --git a/kernel/appli/bbpConfigurator/CMakeLists.txt b/kernel/appli/bbpConfigurator/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0cb04b6
--- /dev/null
@@ -0,0 +1,42 @@
+ # ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ #                        pour la SantÈ)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ #  This software is governed by the CeCILL-B license under French law and
+ #  abiding by the rules of distribution of free software. You can  use,
+ #  modify and/ or redistribute the software under the terms of the CeCILL-B
+ #  license as circulated by CEA, CNRS and INRIA at the following URL
+ #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ #  or in the file LICENSE.txt.
+ #
+ #  As a counterpart to the access to the source code and  rights to copy,
+ #  modify and redistribute granted by the license, users are provided only
+ #  with a limited warranty  and the software's author,  the holder of the
+ #  economic rights,  and the successive licensors  have only  limited
+ #  liability.
+ #
+ #  The fact that you are presently reading this means that you have had
+ #  knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
+
+
+
+SET(
+  SOURCES
+  bbpConfigurator
+)
+
+ADD_EXECUTABLE(
+  bbpConfigurator
+  ${SOURCES}
+)
+  
+TARGET_LINK_LIBRARIES(
+  bbpConfigurator bbtk
+)
+INSTALL_TARGETS(/bin/ bbpConfigurator)
diff --git a/kernel/appli/bbpConfigurator/bbpConfigurator.cpp b/kernel/appli/bbpConfigurator/bbpConfigurator.cpp
new file mode 100644 (file)
index 0000000..fdabc26
--- /dev/null
@@ -0,0 +1,342 @@
+/*
+ # ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ #                        pour la SantÈ)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ #  This software is governed by the CeCILL-B license under French law and
+ #  abiding by the rules of distribution of free software. You can  use,
+ #  modify and/ or redistribute the software under the terms of the CeCILL-B
+ #  license as circulated by CEA, CNRS and INRIA at the following URL
+ #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ #  or in the file LICENSE.txt.
+ #
+ #  As a counterpart to the access to the source code and  rights to copy,
+ #  modify and redistribute granted by the license, users are provided only
+ #  with a limited warranty  and the software's author,  the holder of the
+ #  economic rights,  and the successive licensors  have only  limited
+ #  liability.
+ #
+ #  The fact that you are presently reading this means that you have had
+ #  knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
+#include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <vector>
+#include <set>
+#include <map>
+#include <algorithm>
+#include "boost/filesystem.hpp"
+#include "bbtkBBPInterpreter.h"
+
+namespace bf = boost::filesystem;
+
+typedef std::vector<std::vector<int> > Graph;
+
+typedef std::set<std::string> Dependencies;
+typedef std::vector<Dependencies> DependenciesVector;
+typedef std::vector<std::string> BoxesVector;
+
+std::vector<bf::path> getFileList(const std::string& path);
+
+bool isCycle(const Graph& g);
+bool checkCycle(const Graph& g, const int& i, std::vector<bool>& v);
+
+void setPriorities(const Graph& g, std::vector<int>& p);
+void setPriority(const Graph& g, const int i, std::vector<int>& p);
+
+int main(int argc, char **argv)
+{
+  // Check arguments
+  if (argc != 4)
+  {
+    std::cout << "bbpConfigurator usage: bbConfigurator <path_to_bbs> <package_name> <output_path>" << std::endl;
+    return 1;
+  }
+
+  std::string path_bbs(argv[1]);
+  std::string package_name(argv[2]);
+  std::string path_out(argv[3]);
+  
+  std::cout << "bbpConfigurator launched with bbs path: '" << path_bbs <<
+      "', package: '" << package_name <<
+      "', output path: '" << path_out << "'." << std::endl;
+
+  // Get bbs files in path_bbs
+  std::vector<bf::path> files = getFileList(path_bbs);
+  if(files.size() == 0)
+  {
+    std::cout << "bbpConfigurator: No files to check in bbs path. "
+        "An empty bbp will be created for the package '" << package_name << "'." << std::endl;
+
+    // Write results to bbp file
+    #ifdef WIN32
+      std::string fname = path_out + "\\" + package_name + ".bbp";
+    #else
+      std::string fname = path_out + "/" + package_name + ".bbp";
+    #endif
+
+      std::ofstream out(fname.c_str());
+      out << "#-----------------------------------------" << std::endl;
+      out << "# Include script for bbtk package '" << package_name << "'" << std::endl;
+      out << "# Automatically generated by bbpConfigurator" << std::endl;
+      out << "#-----------------------------------------" << std::endl;
+      out << "load "<< package_name << std::endl;
+      out << "#-----------------------------------------" << std::endl;
+      out << "package "<< package_name << std::endl;
+      out << "#-----------------------------------------" << std::endl;
+      out << "endpackage" << std::endl;
+      out << "#-- EOF ----------------------------------" << std::endl;
+
+      out.close();
+
+
+    return 0;
+  }
+
+
+  // Order files by dependencies
+  //  Get DependenciesVector and Box Names
+  DependenciesVector deps;
+  BoxesVector boxs;
+
+
+  for (int i = 0; i < (int)files.size(); ++i) {
+    bbtk::BBPInterpreter::Pointer I = bbtk::BBPInterpreter::New();
+    I->InterpretFile(files[i].string());
+    boxs.push_back( ((bbtk::BBPInterpreter*)(I.get()))->boxName );
+    deps.push_back( ((bbtk::BBPInterpreter*)(I.get()))->dependencies );
+
+    //print box name and dependencies
+//    std::cout << ((bbtk::BBPInterpreter*)(I.get()))->boxName << ": ";
+//    for(
+//      Dependencies::iterator it = ((bbtk::BBPInterpreter*)(I.get()))->dependencies.begin();
+//      it != ((bbtk::BBPInterpreter*)(I.get()))->dependencies.end();
+//      it++) {
+//      std::cout << *it << ", ";
+//    }
+//    std::cout << std::endl;
+
+  }
+
+  // Only keep dependencies from package
+  Dependencies boxNamesSet(boxs.begin(), boxs.end());
+
+  //std::cout << "after: " << std::endl;
+  for (DependenciesVector::iterator it = deps.begin(); it != deps.end(); it++) {
+    BoxesVector tmp;
+    std::set_intersection(it->begin(), it->end(), boxNamesSet.begin(), boxNamesSet.end(),std::back_inserter(tmp));
+    Dependencies tmp1(tmp.begin(),tmp.end());
+    it->swap( tmp1 );
+    //print clean dependencies
+//    for(
+//      Dependencies::iterator it1 = it->begin();
+//      it1 != it->end();
+//      it1++) {
+//      std::cout << *it1 << ", ";
+//    }
+//    std::cout << std::endl;
+
+  }
+
+  // Create dependencies graph
+  std::vector<std::vector<int> > g(boxs.size(), std::vector<int>());
+  std::map<std::string, int> idxs;
+
+
+  for (int i = 0; i < (int)boxs.size(); ++i)
+  {
+    idxs[boxs[i]] = i;
+  }
+
+  int boxit = 0;
+  for (DependenciesVector::iterator dit = deps.begin(); dit != deps.end(); dit++, boxit++)
+  {
+    for (Dependencies::iterator ddit = dit->begin(); ddit != dit->end(); ddit++)
+    {
+      g[boxit].push_back(idxs[*ddit]);
+    }
+  }
+
+  // Check there are no cycles in graph
+  if(isCycle(g))
+  {
+    std::cout << "bbpConfigurator: There are dependency cycles, please check your scripts in '" <<
+        path_bbs << "'. No bbp file created." << std::endl;
+    return 2;
+  }
+  else
+  {
+    std::cout << "bbpConfigurator: No cycles detected in dependency graph." << std::endl;
+    std::vector<int> priorities(boxs.size(), -1);
+    setPriorities(g, priorities);
+//    for (int i = 0; i < (int)priorities.size(); i++)
+//    {
+//      std::cout << priorities[i] << " ";
+//    }
+//    std::cout << std::endl;
+
+    // Write results to bbp file
+  #ifdef WIN32
+    std::string fname = path_out + "\\" + package_name + ".bbp";
+  #else
+    std::string fname = path_out + "/" + package_name + ".bbp";
+  #endif
+
+    std::ofstream out(fname.c_str());
+    out << "#-----------------------------------------" << std::endl;
+    out << "# Include script for bbtk package '" << package_name << "'" << std::endl;
+    out << "# Automatically generated by bbpConfigurator" << std::endl;
+    out << "#-----------------------------------------" << std::endl;
+    out << "load "<< package_name << std::endl;
+    out << "#-----------------------------------------" << std::endl;
+    out << "package "<< package_name << std::endl;
+    out << "#-----------------------------------------" << std::endl;
+
+    //each bbs file ordered.
+    //include [package_name]/boxes/[file_bbs]
+    //#-----------------------------------------
+
+  //  for (int i = 0; i < (int)files.size(); ++i) {
+  //    out << "include " << package_name << "/boxes/" << files[i].filename().string() << std::endl;
+  //    out << "#-----------------------------------------" << std::endl;
+  //  }
+
+    // find max priority level
+    int mx_priority = 0;
+    for (int i = 0; i < (int)priorities.size(); i++)
+      mx_priority = std::max(mx_priority, priorities[i]);
+
+    // for each priority level print scripts in that level.
+    for (int i = 0; i <= mx_priority; i++)
+    {
+      for (int j = 0; j < (int)priorities.size(); j++)
+      {
+        if(priorities[j] == i)
+        {
+          out << "include " << package_name << "/boxes/" << files[j].filename().string() << std::endl;
+          out << "#-----------------------------------------" << std::endl;
+        }
+      }
+    }
+    out << "endpackage" << std::endl;
+    out << "#-- EOF ----------------------------------" << std::endl;
+  
+    out.close();
+
+    std::cout << "bbpConfigurator: bbp file created at '" << fname << "'." << std::endl;
+  }
+  return 0;
+}
+//==========================================================================
+
+// extract of the tarjan's algorithm for strongly connected components
+bool isCycle(const Graph& g)
+{
+  for (int it = 0; it < (int)g.size(); ++it) {
+    std::vector<bool> visited (g.size(), false);
+    if (checkCycle(g, it, visited))
+    {
+      //std::cout << "At " << it << std::endl;
+      return true;
+    }
+  }
+  return false;
+}
+
+//==========================================================================
+
+// dfs search to check cycles.
+bool checkCycle(const Graph& g, const int& i, std::vector<bool>& v)
+{
+
+  v[i] = true;
+  for(int dit = 0; dit < (int)g[i].size(); dit++)
+  {
+    int d = g[i][dit];
+    if(d < 0 || d >= (int)g.size() || v[d])
+    {
+      //std::cout << "Checking " << i << " dependency " << dit << "=" << d << std::endl;
+      return true;
+    }
+    if(checkCycle(g,d,v))
+      return true;
+  }
+  v[i] = false;
+  return false;
+}
+
+//==========================================================================
+
+// find precedence in graph. 0 are the boxes that have no deps, 1 boxes that have deps from 0 or less, 2 boxes that have deps from 1 or less, etc.
+void setPriorities(const Graph& g, std::vector<int>& p)
+{
+  for(int i = 0; i < (int)g.size(); i++)
+  {
+    if(p[i] == -1)
+      setPriority(g, i, p);
+  }
+}
+
+//==========================================================================
+
+// dfs search to find dependencies
+void setPriority(const Graph& g, const int i, std::vector<int>& p)
+{
+  int pi = -1;
+  for(int j = 0; j < (int)g[i].size(); j++)
+  {
+    setPriority(g, g[i][j], p);
+    pi = std::max(pi, p[g[i][j]]);
+  }
+  p[i]=pi+1;
+}
+
+//==========================================================================
+
+std::vector<bf::path> getFileList(const std::string& path)
+{
+  std::vector<bf::path> files;
+
+  bf::path pth(path.c_str());
+  if(bf::exists(pth) && bf::is_directory(pth))
+  {
+    bf::directory_iterator end_itr;
+    for(bf::directory_iterator itr(pth); itr != end_itr; ++itr)
+    {
+      if(!is_directory(itr->status()))
+      {
+        std::string nm(itr->path().filename().string());
+        if(nm.substr(nm.size()-4) == ".bbs")
+        {
+          //std::cout << itr->path().filename().string() << std::endl;
+          files.push_back(itr->path());
+        }
+      }
+    }
+  }
+  else
+  {
+    std::cout<< "bbpConfigurator: The path to the bbs's doesn't exist or is not a folder. ('" << path << "')" << std::endl;
+    return files;
+  }
+
+  // Order files by name
+  for (int i = 0; i < (int)files.size()-1; ++i) {
+    for (int j = i+1; j < (int)files.size(); ++j) {
+      if(files[j].filename().string() < files[i].filename().string())
+      {
+        bf::path tmp = files[i];
+        files[i] = files[j];
+        files[j] = tmp;
+      }
+    }
+  }
+
+  return files;
+}
index 27352efe28581632688a5951796e147367e980d7..634a2a7bbbe86874a981a0628365395583a8f54d 100644 (file)
@@ -47,6 +47,7 @@ IF(WIN32)
   SET(BBTK_BBS2CPP "${BBTK_BIN_PATH}/bbs2cpp")
   SET(BBTK_BBC "${BBTK_BIN_PATH}/bbc")
   SET(BBTK_BBFY "${BBTK_BIN_PATH}/bbfy")
+  SET(BBTK_BBPCONFIGURATOR "${BBTK_BIN_PATH}/bbpConfigurator")
   SET(BBTK_BBDOC "${BBTK_BIN_PATH}/bbdoc")
   
 ELSE(WIN32)
@@ -57,6 +58,7 @@ ELSE(WIN32)
   SET(BBTK_BBS2CPP "${BBTK_BIN_PATH}/bbs2cpp")
   SET(BBTK_BBC "${BBTK_BIN_PATH}/bbc")
   SET(BBTK_BBFY "${BBTK_BIN_PATH}/bbfy")
+  SET(BBTK_BBPCONFIGURATOR "${BBTK_BIN_PATH}/bbpConfigurator")
   SET(BBTK_BBDOC "${BBTK_BIN_PATH}/bbdoc")  
 ENDIF(WIN32)
 
index c7d7253f8d132172ec33db195b4cf6670b025445..bd5d496151c9bc5d92a2e01eddbab09f2ba97b5e 100644 (file)
@@ -27,6 +27,7 @@
 
 #----------------------------------------------------------------------------
 IF(${BBTK_PACKAGE_NAME}_INCLUDE_ALL_BBS_BOXES) 
+
   FILE(GLOB 
     ${BBTK_PACKAGE_NAME}_BBS_BOXES 
     RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
index 55036d4de135ecadb966151584538846be4b2ad6..aea7925dcc308cd2b3a04b36ed9790cd1bfe554d 100644 (file)
@@ -89,6 +89,8 @@ ENDIF(NOT PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
 #----------------------------------------------------------------------------
 
 
+
+
 #----------------------------------------------------------------------------
 #----------------------------------------------------------------------------
 # bbfy
@@ -98,6 +100,8 @@ ENDIF(NOT PROJECT_BINARY_DIR STREQUAL ${PROJECT_SOURCE_DIR})
 IF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML) 
   FILE(GLOB ${BBTK_PACKAGE_NAME}_XML_SOURCES "." "*.xml")
 ENDIF(${BBTK_PACKAGE_NAME}_COMPILE_ALL_XML) 
+
+
 #----------------------------------------------------------------------------
 FOREACH(xmlfile ${${BBTK_PACKAGE_NAME}_XML_SOURCES})
   GET_FILENAME_COMPONENT(filename "${xmlfile}" NAME_WE) 
@@ -109,10 +113,16 @@ FOREACH(xmlfile ${${BBTK_PACKAGE_NAME}_XML_SOURCES})
  #   SET(command00 Path=c:/creatis/dlls__RR__%WXWIN%/lib/vc_dll/__RR__%VTK_DIR%__RR__%ITK_DIR%/../../bin/__RR__%PATH%)
  #   STRING(REPLACE "__RR__" "\;" SETPATH ${command00} )
  #   SET(SETPATH set ${command0} &&)
+
  ADD_CUSTOM_COMMAND(
-    OUTPUT ${BBFY_CXX_OUT}
-    COMMAND
-    set Path=${DLL_PATH} && ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
+    OUTPUT ${BBFY_CXX_OUT} 
+       COMMAND echo ${BBFY_CXX_OUT}
+       COMMAND  echo set "Path=${crea_DIR}/bin/\;"${DLL_PATH} 
+       COMMAND  echo ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
+       COMMAND echo ${BBFY_CXX_OUT}
+       COMMAND  set "Path=${crea_DIR}/bin/\;"${DLL_PATH} && ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
+ ##  COMMAND  set Path=${DLL_PATH} && ${BBTK_BBFY} ${xmlfile} ${BBTK_PACKAGE_NAME} ${CMAKE_CURRENT_BINARY_DIR}/ -q
     DEPENDS ${xmlfile}
     ${BBTK_BBFY_DEPENDENCY} 
     )
@@ -295,3 +305,32 @@ IF(CHCON_LIBRARIES)
 ENDIF(CHCON_LIBRARIES)
 #----------------------------------------------------------------------------
 
+
+
+#----------------------------------------------------------------------------
+#  bbpConfigurator
+#----------------------------------------------------------------------------
+# --Creates the file ${BBTK_PACKAGE_NAME}.bbp-- 
+## bbpConfigurator   create de PACKAGE.bbp file
+## bbConfigurator <path_to_bbs> <package_name> <output_path>
+
+  IF (WIN32)
+    MAKE_DLL_PATH()
+ #   SET(command00 Path=c:/creatis/dlls__RR__%WXWIN%/lib/vc_dll/__RR__%VTK_DIR%__RR__%ITK_DIR%/../../bin/__RR__%PATH%)
+ #   STRING(REPLACE "__RR__" "\;" SETPATH ${command00} )
+ #   SET(SETPATH set ${command0} &&)
+
+  ADD_CUSTOM_COMMAND( 
+        TARGET  bb${BBTK_PACKAGE_NAME} PRE_BUILD
+       COMMAND  set "Path=${crea_DIR}/bin/\;"${DLL_PATH} && $(OutDir)/bbpConfigurator.exe ${CMAKE_CURRENT_SOURCE_DIR}/boxes/  ${BBTK_PACKAGE_NAME}  ${BBTK_BBS_BUILD_PATH}/
+    ) 
+       
+  ELSE(WIN32)
+    SET(LD_LIBRARY_PATH "$ENV{LD_LIBRARY_PATH}:${LIBRARY_OUTPUT_PATH}")
+    ADD_CUSTOM_TARGET( bb${BBTK_PACKAGE_NAME}.bbp ALL
+##    COMMAND export LD_LIBRARY_PATH=${LD_LIBRARY_PATH} && ${BBTK_BBPCONFIGURATOR}  ${CMAKE_CURRENT_SOURCE_DIR}/boxes/  ${BBTK_PACKAGE_NAME}  ${BBTK_BBS_BUILD_PATH}/
+      COMMAND  ${BBTK_BBPCONFIGURATOR} ${CMAKE_CURRENT_SOURCE_DIR}/boxes/  ${BBTK_PACKAGE_NAME}  ${BBTK_BBS_BUILD_PATH}/
+    ) 
+       
+  ENDIF(WIN32)
+
index 29d89ad648498e89a8a889b506df2698a289ffbf..91d4eaeb4cdb8315807de00dfb5ad6d164993053 100644 (file)
@@ -80,33 +80,39 @@ MACRO(BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT    BBTK_PACKAGE_NAME    BBTK_PACKAGE_BB
 
 
   ##  --Configure and installing bbs boxes--
-  # --Creates the file ${BBTK_PACKAGE_NAME}.bbp--
-  SET(OUTPUT_FILE ${BBTK_BBS_BUILD_PATH}/${BBTK_PACKAGE_NAME}.bbp)
-  FILE(WRITE 
-    "${OUTPUT_FILE}" 
-    "#-----------------------------------------\n"
-    "# Include script for bbtk package '${BBTK_PACKAGE_NAME}'\n"
-    "# Automatically generated by cmake (macro BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT)\n")
-  FILE(APPEND 
-    "${OUTPUT_FILE}"
-    "#-----------------------------------------\n"
-    "load ${BBTK_PACKAGE_NAME}\n"
-    "#-----------------------------------------\n"
-    "package ${BBTK_PACKAGE_NAME}\n"
-    )
-  
-  #FILE(APPEND 
-  #  "${OUTPUT_FILE}"
-  #  "#-----------------------------------------\n"
-  #  "include ${BBTK_PACKAGE_NAME}/boxes/*\n"
-  #  )
-  
+
+
+##EED 24/06/2013
+##  FILE(WRITE 
+##    "${OUTPUT_FILE}" 
+##    "#-----------------------------------------\n"
+##    "# Include script for bbtk package '${BBTK_PACKAGE_NAME}'\n"
+##    "# Automatically generated by cmake (macro BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT)\n")
+##  FILE(APPEND 
+##    "${OUTPUT_FILE}"
+##    "#-----------------------------------------\n"
+##    "load ${BBTK_PACKAGE_NAME}\n"
+##    "#-----------------------------------------\n"
+##    "package ${BBTK_PACKAGE_NAME}\n"
+##    )
+##  
+##  #FILE(APPEND 
+##  #  "${OUTPUT_FILE}"
+##  #  "#-----------------------------------------\n"
+##  #  "include ${BBTK_PACKAGE_NAME}/boxes/*\n"
+##  #  )
+##  
+
   FOREACH(bbs ${BBTK_PACKAGE_BBS_BOXES})  
-    FILE(APPEND 
-      "${OUTPUT_FILE}"
-      "#-----------------------------------------\n"
-      "include ${BBTK_PACKAGE_NAME}/${bbs}\n"
-      )
+
+##EED 24/06/2013
+##    FILE(APPEND 
+##      "${OUTPUT_FILE}"
+##      "#-----------------------------------------\n"
+##      "include ${BBTK_PACKAGE_NAME}/${bbs}\n"
+##      )
+
     CONFIGURE_FILE(
       ${CMAKE_CURRENT_SOURCE_DIR}/${bbs}
       ${BBTK_BBS_BUILD_PATH}/${BBTK_PACKAGE_NAME}/${bbs}
@@ -116,29 +122,32 @@ MACRO(BBTK_CREATE_PACKAGE_INCLUDE_SCRIPT    BBTK_PACKAGE_NAME    BBTK_PACKAGE_BB
     
     
     IF(WIN32)
-    INSTALL(
-      FILES ${CMAKE_CURRENT_SOURCE_DIR}/${bbs}
-#      DESTINATION ${BBTK_BBS_INSTALL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
-      DESTINATION ${BBTK_BBS_REL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
-    )
-ELSE(WIN32)
-INSTALL(
-      FILES ${CMAKE_CURRENT_SOURCE_DIR}/${bbs}
-      DESTINATION ${BBTK_BBS_INSTALL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
-#      DESTINATION ${BBTK_BBS_REL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
-    )
-ENDIF(WIN32)
+      INSTALL(
+        FILES ${CMAKE_CURRENT_SOURCE_DIR}/${bbs}
+#       DESTINATION ${BBTK_BBS_INSTALL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
+        DESTINATION ${BBTK_BBS_REL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
+      )
+    ELSE(WIN32)
+      INSTALL(
+        FILES ${CMAKE_CURRENT_SOURCE_DIR}/${bbs}
+        DESTINATION ${BBTK_BBS_INSTALL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
+#       DESTINATION ${BBTK_BBS_REL_PATH}/${BBTK_PACKAGE_NAME}/${bbs_path}
+      )
+    ENDIF(WIN32)
+
   ENDFOREACH(bbs)
 
 
 
-  ##  --Configure and installing bbs appli--
-  FILE(APPEND 
-    "${OUTPUT_FILE}"
-      "#-----------------------------------------\n"
-      "endpackage\n"
-      "#-- EOF ----------------------------------\n"
-    )
+##EED 24/06/2013
+##  ##  --Configure and installing bbs appli--
+##  FILE(APPEND 
+##    "${OUTPUT_FILE}"
+##      "#-----------------------------------------\n"
+##      "endpackage\n"
+##      "#-- EOF ----------------------------------\n"
+##    )
+
  IF(WIN32)
   INSTALL(
     FILES ${OUTPUT_FILE}
@@ -152,6 +161,10 @@ ELSE(WIN32)
 #   DESTINATION ${BBTK_BBS_REL_PATH}
     )
 ENDIF(WIN32)
+
+
+
+
   # Creates the file ${BBTK_PACKAGE_NAME}-appli.bbp
   SET(OUTPUT_FILE ${BBTK_BBS_BUILD_PATH}/${BBTK_PACKAGE_NAME}-appli.bbp)
   FILE(WRITE 
index bdb2f45cfa5727186cebe39edf7242183ade0341..dc2584328a7bc59e24fe8448216ccbf5fb648fd6 100644 (file)
@@ -87,6 +87,7 @@ IF(WIN32)
   SET(BBTK_BBC ${BBTK_BIN_PATH}/bbc.exe)
   SET(BBTK_BBI ${BBTK_BIN_PATH}/bbi.exe)
   SET(BBTK_BBFY ${BBTK_BIN_PATH}/bbfy.exe)
+  SET(BBTK_BBPCONFIGURATOR ${BBTK_BIN_PATH}/bbpConfigurator.exe)
 
 ELSE(WIN32)
 # For Xcode : have to test the cmake generator !
@@ -99,6 +100,7 @@ ELSE(WIN32)
   SET(BBTK_BBS2CPP ${BBTK_BIN_PATH}/bbs2cpp)
   SET(BBTK_BBC ${BBTK_BIN_PATH}/bbc)
   SET(BBTK_BBFY ${BBTK_BIN_PATH}/bbfy)
+  SET(BBTK_BBPCONFIGURATOR ${BBTK_BIN_PATH}/bbpConfigurator)
 ENDIF(WIN32)  
 SET(BBTK_PACKAGE_LIB_PATH ${BBTK_LIB_PATH})
 
@@ -112,6 +114,7 @@ MESSAGE(STATUS "* BBTK_BBI              =${BBTK_BBI}")
 MESSAGE(STATUS "* BBTK_BBS2CPP          =${BBTK_BBS2CPP}")
 MESSAGE(STATUS "* BBTK_BBC              =${BBTK_BBC}")
 MESSAGE(STATUS "* BBTK_BBFY             =${BBTK_BBFY}")
+MESSAGE(STATUS "* BBTK_BBPCONFIGURATOR  =${BBTK_BBPCONFIGURATOR}")
 #-----------------------------------------------------------------------------
 
 #-----------------------------------------------------------------------------
index 92210a7aaa6d9d560a55329560598dc4c1df7c98..bf1bf560bf0d02d56a6d69faf7305e5e51dfc078 100644 (file)
@@ -106,6 +106,13 @@ IF(BBTK_CORE_PACKAGE)
     SET(BBTK_BBFY_DEPENDENCY ${BBTK_BBFY})
   ENDIF(EXISTS "${BBTK_BBFY}")
 
+  IF(EXISTS "${BBTK_BBPCONFIGURATOR}")
+    SET(BBTK_BBPCONFIGURATOR_DEPENDENCY)
+  ELSE(EXISTS "${BBTK_BBPCONFIGURATOR}")
+    SET(BBTK_BBPCONFIGURATOR_DEPENDENCY ${BBTK_BBPCONFIGURATOR})
+  ENDIF(EXISTS "${BBTK_BBPCONFIGURATOR}")
+
+
 ENDIF(BBTK_CORE_PACKAGE)
 #-----------------------------------------------------------------------------
 
diff --git a/kernel/src/bbtkBBPInterpreter.cxx b/kernel/src/bbtkBBPInterpreter.cxx
new file mode 100644 (file)
index 0000000..a9f246c
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Santé)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+ */
+
+/*=========================================================================
+Program:   bbtk
+Module:    $RCSfile$
+Language:  C++
+Date:      $Date$
+Version:   $Revision$
+=========================================================================*/
+
+
+/**
+ *  \file
+ *  \brief Class bbtk::BBPInterpreter
+ */
+
+
+#include "bbtkBBPInterpreter.h"
+
+#include "bbtkExecuter.h"
+#include "bbtkMessageManager.h"
+#include "bbtkFactory.h"
+#include "bbtkUtilities.h"
+
+namespace bbtk
+{
+
+  //=========================================================================
+  BBPInterpreter::Pointer BBPInterpreter::New()
+  {
+    return MakePointer( new BBPInterpreter() );
+  }
+  //=========================================================================
+
+
+
+  //=========================================================================
+  BBPInterpreter::BBPInterpreter()
+  {
+    bbtk::InterpreterVirtual::Init();
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  BBPInterpreter::~BBPInterpreter()
+  {
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  /// Creates a new black box in current complex box
+  void BBPInterpreter::commandNew( const std::string& boxType, const std::string& boxName) // virtual
+  {
+    this->dependencies.insert(boxType);
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  /// Connects the output boxOutput to the input boxInput
+  void BBPInterpreter::commandConnection (const std::string &boxfrom,
+      const std::string &output,
+      const std::string &boxto,
+      const std::string &input)                        // virtual
+  {
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void BBPInterpreter::commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string  &help)
+  {
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void BBPInterpreter::commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string  &help)
+  {
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  /// sets the input of the box with the value
+  void BBPInterpreter::commandSet(const std::string &box,const std::string &input,const std::string &value) // virtual
+  {
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  void BBPInterpreter::commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename) // virtual
+  {
+    this->boxName = name;
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  void BBPInterpreter::commandEndDefine() // virtual
+  {
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  void BBPInterpreter::commandExec(const std::string &word) // virtual
+  {
+  }
+  //=========================================================================
+
+
+  //=========================================================================
+  void BBPInterpreter::commandAuthor(const std::string &author)  // virtual
+  {
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void BBPInterpreter::commandCategory(const std::string &categorytype)  // virtual
+  {
+  }
+  //=========================================================================
+
+  //=========================================================================
+  void BBPInterpreter::commandDescription(const std::string &description)  // virtual
+  {
+  }
+  //=========================================================================
+
+}  // EO namespace bbtk
+
+// EOF
+
diff --git a/kernel/src/bbtkBBPInterpreter.h b/kernel/src/bbtkBBPInterpreter.h
new file mode 100644 (file)
index 0000000..5fa1c63
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+# ---------------------------------------------------------------------
+#
+# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+#                        pour la Santé)
+# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+#
+#  This software is governed by the CeCILL-B license under French law and
+#  abiding by the rules of distribution of free software. You can  use,
+#  modify and/ or redistribute the software under the terms of the CeCILL-B
+#  license as circulated by CEA, CNRS and INRIA at the following URL
+#  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+#  or in the file LICENSE.txt.
+#
+#  As a counterpart to the access to the source code and  rights to copy,
+#  modify and redistribute granted by the license, users are provided only
+#  with a limited warranty  and the software's author,  the holder of the
+#  economic rights,  and the successive licensors  have only  limited
+#  liability.
+#
+#  The fact that you are presently reading this means that you have had
+#  knowledge of the CeCILL-B license and that you accept its terms.
+# ------------------------------------------------------------------------
+*/
+
+/*=========================================================================
+Program:   bbtk
+Module:    $RCSfile$
+Language:  C++
+Date:      $Date$
+Version:   $Revision$
+=========================================================================*/
+
+
+#ifndef __bbtkBBPInterpreter_h__
+#define __bbtkBBPInterpreter_h__
+
+//Includes bbtk
+#include "bbtkInterpreterVirtual.h"
+
+//Includes std
+#include <iostream>
+#include <set>
+
+
+//#include "bbtkSystem.h"
+//#include "bbtkComplexBlackBox.h"
+
+namespace bbtk
+{
+  class BBTK_EXPORT BBPInterpreter : public InterpreterVirtual
+  {
+  public:
+    static Pointer New();
+    BBPInterpreter();
+    ~BBPInterpreter();
+
+    //Public methods
+
+    virtual void commandNew( const std::string& boxType, const std::string& boxName);
+
+    virtual void commandConnection (const std::string &boxfrom,
+                       const std::string &output,
+                       const std::string &boxto,
+                       const std::string &input);
+    virtual void commandSet(const std::string &box,const std::string &input,const std::string &value);
+
+
+    virtual void commandDefine(const std::string &name,const std::string &pack,const std::string &scriptfilename);
+    virtual void commandEndDefine();
+
+    virtual void commandExec(const std::string &word);
+
+    virtual void commandAuthor(const std::string &author);
+    virtual void commandCategory(const std::string &categorytype);
+    virtual void commandDescription(const std::string &description);
+
+    virtual void commandInput(const std::string &name,const std::string &box,const std::string &input,const std::string  &help);
+    virtual void commandOutput(const std::string &name,const std::string &box,const std::string &output,const std::string  &help);
+
+    std::string boxName;
+    std::set<std::string> dependencies;
+
+  private:
+
+    //Private Attributes
+
+    //Private Methods
+
+  protected:
+
+    //Protected Attributes
+
+    //Protected methods
+
+  };
+}
+// namespace bbtk
+#endif
+