X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FcreaDevManagerLib%2FmodelCDMPackageSrc.cpp;h=4654e58cf3a462951eafd26a048c4f4e8c58aa79;hb=76962b2ed3513cee0f6afd83b9d93e2b43bdefc5;hp=44481877708dc5c62c1be8440ca7852709b09943;hpb=11150e550ff03ee658e90cda4b475b4c24da0a7f;p=crea.git diff --git a/lib/creaDevManagerLib/modelCDMPackageSrc.cpp b/lib/creaDevManagerLib/modelCDMPackageSrc.cpp index 4448187..4654e58 100644 --- a/lib/creaDevManagerLib/modelCDMPackageSrc.cpp +++ b/lib/creaDevManagerLib/modelCDMPackageSrc.cpp @@ -88,11 +88,18 @@ modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const s while (cont) { std::string stdfileName = crea::wx2std(fileName); - modelCDMFile* file; + std::size_t fileTypePos = stdfileName.find_last_of("."); + std::string fileType; + if(fileTypePos != std::string::npos) + fileType = stdfileName.substr(fileTypePos); + else + fileType = ""; + + modelCDMCodeFile* file; if(stdfileName.substr(0,2) == "bb") { - file = new modelCDMFile(this, path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + file = new modelCDMCodeFile(this, path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); this->children.push_back(file); modelCDMBlackBox* blackBox = new modelCDMBlackBox(this, path, stdfileName.substr(2,stdfileName.size()-4), level + 1); blackBox->SetHeaderFile(file); @@ -100,7 +107,7 @@ modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const s cont = dir2.GetFirst(&fileName, crea::std2wx(stdfileName.substr(0,stdfileName.size()-2) + ".cxx"), wxDIR_FILES); if (cont) { - file = new modelCDMFile(this, path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1); + file = new modelCDMCodeFile(this, path + CDMUtilities::SLASH + crea::wx2std(fileName), crea::wx2std(fileName), this->level + 1); this->children.push_back(file); blackBox->SetSourceFile(file); } @@ -116,7 +123,7 @@ modelCDMPackageSrc::modelCDMPackageSrc(modelCDMIProjectTreeNode* parent, const s modelCDMPackageSrc::~modelCDMPackageSrc() { - for (int i = 0; i < this->blackBoxes.size(); i++) + for (int i = 0; i < (int)(this->blackBoxes.size()); i++) { if(this->blackBoxes[i] != NULL) { @@ -147,7 +154,7 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox( std::vector words; CDMUtilities::splitter::split(words, name, " \n\",/\\'", CDMUtilities::splitter::no_empties); std::string bbName; - for (int i = 0; i < words.size(); i++) + for (int i = 0; i < (int)(words.size()); i++) { bbName += words[i]; } @@ -158,7 +165,7 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox( if(words.size() > 0) { bbCategories = words[0]; - for (int i = 1; i < words.size(); i++) + for (int i = 1; i < (int)(words.size()); i++) { bbCategories += "," + words[i]; } @@ -172,7 +179,7 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox( if(words.size() > 0) { bbAuthors = words[0]; - for (int i = 1; i < words.size(); i++) + for (int i = 1; i < (int)(words.size()); i++) { bbAuthors += "," + words[i]; } @@ -186,7 +193,7 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox( if(words.size() > 0) { bbDescription = words[0]; - for (int i = 1; i < words.size(); i++) + for (int i = 1; i < (int)(words.size()); i++) { bbDescription += "," + words[i]; } @@ -196,7 +203,7 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox( if(words.size() > 0) { bbDescription += words[0]; - for (int i = 1; i < words.size(); i++) + for (int i = 1; i < (int)(words.size()); i++) { bbDescription += words[i]; } @@ -209,15 +216,23 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox( //create command std::string command = "bbCreateBlackBox"; command += " \"" + this->path + "\""; +#ifdef _WIN32 + command += " " + package; + command += " " + bbName; + command += " " + type; + command += " " + format; +#else command += " \"" + package + "\""; command += " \"" + bbName + "\""; command += " \"" + type + "\""; command += " \"" + format + "\""; +#endif command += " \"" + bbAuthors + "\""; command += " \"" + bbDescription + "\""; command += " \"" + bbCategories + "\""; //excecute command + //wxMessageBox(crea::std2wx("Command: ->" + command + "<-"),_T("Creating Black Box"),wxOK | wxICON_INFORMATION); if(system(command.c_str())) { result = new std::string("Error executing command '" + command + "'"); @@ -238,13 +253,13 @@ modelCDMBlackBox* modelCDMPackageSrc::CreateBlackBox( if (cont) { std::string stdfileName = crea::wx2std(fileName); - header = new modelCDMFile(this, this->path + stdfileName, stdfileName, this->level+1); + header = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level+1); } cont = dir.GetFirst(&fileName, crea::std2wx("bb"+package+bbName+".cxx"), wxDIR_FILES); if (cont) { std::string stdfileName = crea::wx2std(fileName); - source = new modelCDMFile(this, this->path + stdfileName, stdfileName, this->level+1); + source = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level+1); } } //if source and header exist @@ -297,7 +312,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result) std::string folderName = stdfileName; //check if they already exist bool found = false; - for (int i = 0; !found && i < this->children.size(); i++) + for (int i = 0; !found && i < (int)(this->children.size()); i++) { if (this->children[i]->GetName() == folderName) { @@ -319,6 +334,12 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result) while (cont) { std::string stdfileName = crea::wx2std(fileName); + std::size_t fileTypePos = stdfileName.find_last_of("."); + std::string fileType; + if(fileTypePos != std::string::npos) + fileType = stdfileName.substr(fileTypePos); + else + fileType = ""; //if CMakeLists, create CMakeLists if(stdfileName == "CMakeLists.txt") @@ -340,7 +361,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result) else { bool found = false; - for (int i = 0; !found && i < this->children.size(); i++) + for (int i = 0; !found && i < (int)(this->children.size()); i++) { if (this->children[i]->GetName() == stdfileName) { @@ -353,8 +374,22 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result) if(!found) { - modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); - this->children.push_back(file); + //if is a code file, create modelCDMCodeFile + if( + fileType == ".c" || + fileType == ".cxx" || + fileType == ".h" || + fileType == ".cpp" || + fileType == ".txx" || + fileType == ".cmake" ) + { + this->children.push_back(new modelCDMCodeFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1)); + } + else + { + modelCDMFile* file = new modelCDMFile(this, this->path + CDMUtilities::SLASH + stdfileName, stdfileName, this->level + 1); + this->children.push_back(file); + } } } @@ -362,7 +397,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result) if(stdfileName.substr(stdfileName.size() - 2, 2) == ".h" && stdfileName.substr(0,2) == "bb") { bool found = false; - for (int i = 0; i < this->blackBoxes.size(); i++) + for (int i = 0; i < (int)(this->blackBoxes.size()); i++) { if(this->blackBoxes[i]->GetHeaderFile()->GetName() == stdfileName) { @@ -386,7 +421,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result) } } - for (int i = 0; i < checkedBoxes.size(); i++) + for (int i = 0; i < (int)(checkedBoxes.size()); i++) { if(!checkedBoxes[i]) { @@ -397,7 +432,7 @@ const bool modelCDMPackageSrc::Refresh(std::string*& result) } } - for (int i = 0; i < checked.size(); i++) + for (int i = 0; i < (int)(checked.size()); i++) { if(!checked[i]) {