X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FCDMUtilities.cpp;h=defe3f82d8a4229b73f97faf434f6c64ad8ce74f;hb=752294dd30e2ee94f38be513d441f4716509ce13;hp=29a277fa2646cabfea5264d4323012e1295dbec2;hpb=609d8d48cae96384e664ec6b000e8ecfcbad6459;p=crea.git diff --git a/lib/creaDevManagerLib/CDMUtilities.cpp b/lib/creaDevManagerLib/CDMUtilities.cpp index 29a277f..defe3f8 100644 --- a/lib/creaDevManagerLib/CDMUtilities.cpp +++ b/lib/creaDevManagerLib/CDMUtilities.cpp @@ -36,7 +36,10 @@ #include #include -#include +#include +#include +#include +#include namespace CDMUtilities { @@ -83,11 +86,11 @@ namespace CDMUtilities //break path into folders std::vector pathSlpit; - splitter::split(pathSlpit, path, "/", splitter::no_empties); + splitter::split(pathSlpit, path, CDMUtilities::SLASH, splitter::no_empties); for (int i = 0; i < pathSlpit.size(); i++) { - pathFixed += "/" + pathSlpit[i]; + pathFixed += CDMUtilities::SLASH + pathSlpit[i]; } #endif return pathFixed; @@ -135,10 +138,161 @@ namespace CDMUtilities return system(comm.c_str()); } - int openTerminal() + int openTerminal(const std::string& command) { - std::string comm = TERMINAL + "&"; + std::string comm = TERMINAL; + if (command != "") + comm += + " " + command; + comm += " &"; return system(comm.c_str()); } + bool createEmptyClass(const std::string& name, const std::string& path) + { + std::vector words; + splitter::split(words,name," \\/\",.'`",splitter::no_empties); + std::string fixedName = ""; + for (int i = 0; i < words.size(); i++) + { + fixedName += words[i]; + } + + if(fixedName == "" || path == "") + { + return false; + } + + std::string nameupper = fixedName; + std::transform(nameupper.begin(), nameupper.end(),nameupper.begin(),::toupper); + + std::ofstream out((path + SLASH + fixedName + ".h").c_str()); + if( !out.is_open()) + { + return false; + } + + out << "/*" << std::endl; + out << "# ---------------------------------------------------------------------" << std::endl; + out << "#" << std::endl; + out << "# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image" << std::endl; + out << "# pour la Sante)" << std::endl; + out << "# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton" << std::endl; + out << "# Previous Authors : Laurent Guigues, Jean-Pierre Roux" << std::endl; + out << "# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil" << std::endl; + out << "#" << std::endl; + out << "# This software is governed by the CeCILL-B license under French law and" << std::endl; + out << "# abiding by the rules of distribution of free software. You can use," << std::endl; + out << "# modify and/ or redistribute the software under the terms of the CeCILL-B" << std::endl; + out << "# license as circulated by CEA, CNRS and INRIA at the following URL" << std::endl; + out << "# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html" << std::endl; + out << "# or in the file LICENSE.txt." << std::endl; + out << "#" << std::endl; + out << "# As a counterpart to the access to the source code and rights to copy," << std::endl; + out << "# modify and redistribute granted by the license, users are provided only" << std::endl; + out << "# with a limited warranty and the software's author, the holder of the" << std::endl; + out << "# economic rights, and the successive licensors have only limited" << std::endl; + out << "# liability." << std::endl; + out << "#" << std::endl; + out << "# The fact that you are presently reading this means that you have had" << std::endl; + out << "# knowledge of the CeCILL-B license and that you accept its terms." << std::endl; + out << "# ------------------------------------------------------------------------" << std::endl; + out << "*/" << std::endl; + out << "" << std::endl; + out << "#ifndef _" << nameupper << "_H_" << std::endl; + out << "#define _" << nameupper << "_H_" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "// Class Name: " << fixedName << "" << std::endl; + out << "// [classdescription]" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "" << std::endl; + out << "class " << fixedName << "" << std::endl; + out << "{" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Methods and attributes exposed to other classes" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "public :" << std::endl; + out << " " << fixedName << "();" << std::endl; + out << " ~" << fixedName << "();" << std::endl; + out << "" << std::endl; + out << "//--Method template----------------------------" << std::endl; + out << "// void FunctionName(int& parameterA);" << std::endl; + out << "" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Methods and attributes exposed only to classes" << std::endl; + out << "//that are derived from this class" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "protected:" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Methods and attributes only visible by this class" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "private:" << std::endl; + out << "" << std::endl; + out << "};" << std::endl; + out << "" << std::endl; + out << "//-end of _" << nameupper << "_H_------------------------------------------------------" << std::endl; + out << "#endif" << std::endl; + + out.close(); + + out.open((path + CDMUtilities::SLASH + fixedName + ".cpp").c_str()); + if( !out.is_open()) + { + return false; + } + + out << "/*" << std::endl; + out << "# ---------------------------------------------------------------------" << std::endl; + out << "#" << std::endl; + out << "# Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image" << std::endl; + out << "# pour la Sante)" << std::endl; + out << "# Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton" << std::endl; + out << "# Previous Authors : Laurent Guigues, Jean-Pierre Roux" << std::endl; + out << "# CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil" << std::endl; + out << "#" << std::endl; + out << "# This software is governed by the CeCILL-B license under French law and" << std::endl; + out << "# abiding by the rules of distribution of free software. You can use," << std::endl; + out << "# modify and/ or redistribute the software under the terms of the CeCILL-B" << std::endl; + out << "# license as circulated by CEA, CNRS and INRIA at the following URL" << std::endl; + out << "# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html" << std::endl; + out << "# or in the file LICENSE.txt." << std::endl; + out << "#" << std::endl; + out << "# As a counterpart to the access to the source code and rights to copy," << std::endl; + out << "# modify and redistribute granted by the license, users are provided only" << std::endl; + out << "# with a limited warranty and the software's author, the holder of the" << std::endl; + out << "# economic rights, and the successive licensors have only limited" << std::endl; + out << "# liability." << std::endl; + out << "#" << std::endl; + out << "# The fact that you are presently reading this means that you have had" << std::endl; + out << "# knowledge of the CeCILL-B license and that you accept its terms." << std::endl; + out << "# ------------------------------------------------------------------------" << std::endl; + out << "*/" << std::endl; + out << "" << std::endl; + out << "#include \"" << fixedName << ".h\"" << std::endl; + out << "" << std::endl; + out << "" << fixedName << "::" << fixedName << "()" << std::endl; + out << "{" << std::endl; + out << "}" << std::endl; + out << "" << std::endl; + out << "" << fixedName << "::~" << fixedName << "()" << std::endl; + out << "{" << std::endl; + out << "}" << std::endl; + out << "" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "//Method template" << std::endl; + out << "//---------------------------------------------" << std::endl; + out << "/*" << std::endl; + out << "void " << fixedName << "::FunctionName(int& parameterA)" << std::endl; + out << "{" << std::endl; + out << " parameterA = 2 * parameterA;" << std::endl; + out << " return;" << std::endl; + out << "}" << std::endl; + out << "*/" << std::endl; + + return true; + } + }