#include<vector>
#include<string>
-#include <cstdlib>
+#include<iostream>
+#include<fstream>
+#include<algorithm>
+#include<cstdlib>
namespace CDMUtilities
{
#if(_WIN32)
// ------ Windows
- //TODO: implementation for windows
+ std::vector<std::string> 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<std::string> pathSlpit;
+ std::vector<std::string> 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;
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<std::string> 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;
+ }
+
}