2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
31 * Created on: 13/11/2012
32 * Author: Daniel Felipe Gonzalez Obando
35 #include "modelCDMProject.h"
41 #include "CDMUtilities.h"
45 modelCDMProject::modelCDMProject()
47 std::cout << "in constructor1" << std::endl;
50 this->CMakeLists = NULL;
53 modelCDMProject::modelCDMProject(
54 const std::string& path,
55 const std::string& buildPath
58 this->path = CDMUtilities::fixPath(path);
60 std::string pathFixed(CDMUtilities::fixPath(path));
62 //TODO: set pathMakeLists for windows
63 std::string pathMakeLists = pathFixed + "/CMakeLists.txt";
65 std::ifstream confFile;
66 confFile.open((pathMakeLists).c_str());
69 while(confFile.is_open() && !confFile.eof())
71 //std::cout << "leyendo " << word << std::endl;
73 std::getline(confFile,word,'(');
74 std::vector<std::string> wordBits;
75 CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties);
77 if(wordBits[wordBits.size()-1] == "PROJECT")
79 std::getline(confFile,word,')');
80 std::vector<std::string> nameBits;
81 CDMUtilities::splitter::split(nameBits, word, " ", CDMUtilities::splitter::no_empties);
83 this->name = this->nameProject = "";
84 for (int i = 0; i < nameBits.size(); i++)
88 this->name += nameBits[i];
90 this->nameProject = this->name;
95 if(wordBits[wordBits.size()-1] == "SET")
98 std::getline(confFile,word,')');
99 CDMUtilities::splitter::split(wordBits, word, " ", CDMUtilities::splitter::no_empties);
100 if(wordBits[0] == "PROJECT_MAJOR_VERSION")
102 version = wordBits[1];
104 if(wordBits[0] == "PROJECT_MINOR_VERSION")
106 version += "." + wordBits[1];
108 if(wordBits[0] == "PROJECT_BUILD_VERSION")
110 version += "." + wordBits[1];
113 //get project versionDate
114 if(wordBits[0] == "PROJECT_VERSION_DATE")
116 std::vector<std::string> versionBits;
117 CDMUtilities::splitter::split(versionBits, wordBits[1], "\"", CDMUtilities::splitter::no_empties);
118 versionDate = versionBits[0];
120 //get project buildPath
124 this->buildPath = buildPath;
128 this->buildPath = this->path + "Bin";
134 this->type = wxDIR_DIRS;
137 this->children.clear();
140 this->packages.clear();
144 wxDir dir(crea::std2wx((pathFixed).c_str()));
148 bool cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_DIRS);
151 std::string stdfileName = crea::wx2std(fileName);
153 //if appli, create appli
154 if(stdfileName == "appli")
156 this->appli = new modelCDMAppli(pathFixed + "/appli", this->level + 1);
157 this->children.push_back(this->appli);
160 else if(stdfileName == "lib")
162 this->lib = new modelCDMLib(pathFixed + "/lib", this->level + 1);
163 this->children.push_back(this->lib);
165 //if package , create package
166 else if(stdfileName.size() > 9 && stdfileName.substr(0,5) == "bbtk_" && stdfileName.substr(stdfileName.size()-4,4) == "_PKG")
168 modelCDMPackage* package = new modelCDMPackage(pathFixed + "/" + stdfileName, this->level + 1);
169 this->packages.push_back(package);
170 this->children.push_back(package);
172 //if is an unknown folder, create folder
175 this->children.push_back(new modelCDMFolder(pathFixed + "/" + stdfileName, this->level + 1));
178 cont = dir.GetNext(&fileName);
181 cont = dir.GetFirst(&fileName, wxEmptyString, wxDIR_FILES);
184 std::string stdfileName = crea::wx2std(fileName);
186 //if CMakeLists, create CMakeLists
187 if(stdfileName == "CMakeLists.txt")
189 this->CMakeLists = new modelCDMCMakeListsFile(pathFixed + "/" + stdfileName, this->level + 1);
190 this->children.push_back(this->CMakeLists);
194 this->children.push_back(new modelCDMFile(pathFixed + "/" + stdfileName, this->level + 1));
196 //if is an unknown file, create file
197 cont = dir.GetNext(&fileName);
201 this->SortChildren();
205 modelCDMProject::~modelCDMProject()
207 for (int i = 0; i < this->children.size(); i++)
209 if(this->children[i] != NULL)
211 delete this->children[i];
212 this->children[i] = NULL;
217 const std::string& modelCDMProject::GetNameProject() const
219 return this->nameProject;
222 const std::string& modelCDMProject::GetVersion() const
224 return this->version;
227 const std::string& modelCDMProject::GetVersionDate() const
229 return this->versionDate;
232 const std::string& modelCDMProject::GetBuildPath() const
234 return this->buildPath;
237 bool modelCDMProject::SetVersion(const std::string& version, std::string*& result)
239 //TODO: implement method
243 bool modelCDMProject::SetBuildPath(const std::string& path, std::string*& result)
245 //TODO: implement method
249 bool modelCDMProject::CreatePackage(
250 const std::string& name,
251 std::string*& result,
252 const std::string& authors,
253 const std::string& authorsEmail,
254 const std::string& version,
255 const std::string& description
258 //TODO: implement method
262 bool modelCDMProject::CreateLibrary(
263 const std::string& name,
264 std::string*& result,
265 const std::string& path
268 //TODO: implement method
272 bool modelCDMProject::CreateApplication(
273 const std::string& name,
274 std::string*& result,
275 const std::string& path
278 //TODO: implement method
282 bool modelCDMProject::CreateBlackBox(
283 const std::string& name,
284 const std::string& package,
285 const std::string& authors,
286 const std::string& authorsEmail,
287 const std::string& categories,
288 const std::string& description
291 //TODO: implement method
295 bool modelCDMProject::OpenCMakeListsFile(std::string*& result)
297 //TODO: implement method
301 const bool modelCDMProject::Refresh(std::string*& result)
303 //TODO: implement method
307 bool modelCDMProject::ConfigureBuild(std::string*& result)
309 //TODO: implement method
313 bool modelCDMProject::Build(std::string*& result)
315 //TODO: implement method
319 bool modelCDMProject::Connect(std::string*& result)
321 //TODO: implement method