X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FCDMUtilities.cpp;h=29ed9c0371ffafc1c8dc9c973566fc8ca256d402;hb=741b9c1d03c7984f7ac4a39188e2bb114471f579;hp=431ebef21c7477ab7564fb035103960661705b33;hpb=cd4ae62285af30451b264ceb3202e1e912740fc7;p=crea.git diff --git a/lib/creaDevManagerLib/CDMUtilities.cpp b/lib/creaDevManagerLib/CDMUtilities.cpp index 431ebef..29ed9c0 100644 --- a/lib/creaDevManagerLib/CDMUtilities.cpp +++ b/lib/creaDevManagerLib/CDMUtilities.cpp @@ -36,7 +36,10 @@ #include #include -#include +#include +#include +#include +#include namespace CDMUtilities { @@ -77,17 +80,27 @@ namespace CDMUtilities #if(_WIN32) // ------ Windows - //TODO: implementation for windows + std::vector pathSplit; + + splitter::split(pathSplit, path, CDMUtilities::SLASH, splitter::no_empties); + + if(0 < pathSplit.size()) + pathFixed = pathSplit[0]; + + for (int i = 1; i < (int)(pathSplit.size()); i++) + { + pathFixed += CDMUtilities::SLASH + pathSplit[i]; + } #else // ------ LINUX / MacOS //break path into folders - std::vector pathSlpit; + std::vector pathSplit; - splitter::split(pathSlpit, path, CDMUtilities::SLASH, splitter::no_empties); + splitter::split(pathSplit, path, CDMUtilities::SLASH, splitter::no_empties); - for (int i = 0; i < pathSlpit.size(); i++) + for (int i = 0; i < pathSplit.size(); i++) { - pathFixed += CDMUtilities::SLASH + pathSlpit[i]; + pathFixed += CDMUtilities::SLASH + pathSplit[i]; } #endif return pathFixed; @@ -144,4 +157,152 @@ namespace CDMUtilities 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 < (int)(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; + } + }