X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMProject.cpp;h=25bba8d0b34c3838c5cea47dcc8b342cb93a8807;hb=07de43de26544771a25b4edb25cbbf878bf32de3;hp=b7a0747506bd7ae94e456ce8b0a873bb66b1933c;hpb=b10bc326c058168a64969db6c6a29b91a3136fb3;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMProject.cpp b/lib/creaDevManagerLib/modelCDMProject.cpp index b7a0747..25bba8d 100644 --- a/lib/creaDevManagerLib/modelCDMProject.cpp +++ b/lib/creaDevManagerLib/modelCDMProject.cpp @@ -34,19 +34,139 @@ #include "modelCDMProject.h" +#include +#include +#include + +#include "CDMUtilities.h" +#include "creaWx.h" +#include "wx/dir.h" + modelCDMProject::modelCDMProject() { - //TODO: implement method + std::cout << "in constructor1" << std::endl; + this->appli = NULL; + this->lib = NULL; } modelCDMProject::modelCDMProject( - const std::string& name, const std::string& path, - const unsigned char& type, - const int& level + const std::string& buildPath ) { + this->path = CDMUtilities::fixPath(path); + //open makelists file + std::string pathFixed(CDMUtilities::fixPath(path)); + + //TODO: set pathMakeLists for windows + std::string pathMakeLists = pathFixed + "/CMakeLists.txt"; + + std::ifstream confFile; + confFile.open((pathMakeLists).c_str()); + + std::string word; + while(confFile.is_open() && !confFile.eof()) + { + //std::cout << "leyendo " << word << std::endl; + //get project name + std::getline(confFile,word,'('); + std::vector wordBits; + CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties); + + if(wordBits[wordBits.size()-1] == "PROJECT") + { + std::getline(confFile,word,')'); + std::vector nameBits; + CDMUtilities::splitter::split(nameBits, word, " ", CDMUtilities::splitter::no_empties); + + this->name = ""; + for (int i = 0; i < nameBits.size(); i++) + { + if(i != 0) + this->name += " "; + this->name += nameBits[i]; + } + + } + + + if(wordBits[wordBits.size()-1] == "SET") + { + //get project version + std::getline(confFile,word,')'); + if(word.find("PROJECT_MAJOR_VERSION") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " ", CDMUtilities::splitter::no_empties); + version = versionBits[versionBits.size()-1]; + } + if(word.find("PROJECT_MINOR_VERSION") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " ", CDMUtilities::splitter::no_empties); + version += "." + versionBits[versionBits.size()-1]; + } + if(word.find("PROJECT_BUILD_VERSION") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " ", CDMUtilities::splitter::no_empties); + version += "." + versionBits[versionBits.size()-1]; + } + + //get project versionDate + if(word.find("PROJECT_VERSION_DATE") != std::string::npos) + { + std::vector versionBits; + CDMUtilities::splitter::split(versionBits, word, " \"", CDMUtilities::splitter::no_empties); + versionDate = versionBits[versionBits.size()-1]; + } + //get project buildPath + + if (buildPath != "") + { + this->buildPath = buildPath; + } + else + { + this->buildPath = this->path + "Bin"; + } + } + } + confFile.close(); + + this->type = wxDIR_DIRS; + this->level = 0; + //TODO: implement method + //if appli exist create Appli + this->appli = NULL; + //if lib exist create Lib + this->lib = NULL; + //if bbtk_* exist create Packages + + +} + +modelCDMProject::~modelCDMProject() +{ + if(this->appli != NULL) + { + delete this->appli; + this->appli = NULL; + } + if(this->lib != NULL) + { + delete this->lib; + this->lib = NULL; + } + for (int i = 0; i < this->packages.size(); i++) + { + if(this->packages[i] != NULL) + { + delete this->packages[i]; + this->packages[i] = NULL; + } + } } const std::string& @@ -137,7 +257,7 @@ bool modelCDMProject::OpenCMakeListsFile(std::string*& result) return true; } -bool modelCDMProject::Refresh(std::string*& result) +const bool modelCDMProject::Refresh(std::string*& result) { //TODO: implement method return true;