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 #ifndef MODELCDMPROJECT_H_
36 #define MODELCDMPROJECT_H_
42 #include "modelCDMFolder.h"
43 #include "modelCDMLib.h"
44 #include "modelCDMAppli.h"
45 #include "modelCDMPackage.h"
46 #include "modelCDMCMakeListsFile.h"
47 #include "modelCDMCodeFile.h"
50 * Project model class.
51 * This class represents a project stored in a hard drive. It can perform some of the most relevant operations for a crea project.
53 class modelCDMProject : public modelCDMFolder
57 * Default constructor.
62 * Constructor receiving the source path and the build path.
63 * @param parent Parent node of the Project node.
64 * @param path The source path.
65 * @param name Name of the project folder.
66 * @param buildPath The build path. By default it's an empty string.
68 modelCDMProject(modelCDMIProjectTreeNode* parent, const std::string& path, const std::string& name, const std::string& buildPath = "");
78 * Retrieves the name of the project.
79 * @return The name of the project.
81 const std::string& GetNameProject() const;
84 * Retrieves the version of the project.
85 * @return The version of the project in the format X.Y.Z where X is the major version of the project, Y is the minor version of the project, and Z is the build version.
87 const std::string& GetVersion() const;
90 * Retrieves the last version modification date of the project
91 * @return The date of the last version modification in the format DD/MM/YYYY
93 const std::string& GetVersionDate() const;
96 * Retrieves the build path of the project.
97 * @return The build path of the project. By default .../ProjectNameBin.
99 const std::string& GetBuildPath() const;
102 * Retrieves the package vector containing the packages present in the project.
103 * @return The package vector containing references to the packages of the project.
105 const std::vector<modelCDMPackage*>& GetPackages() const;
108 * Retrieves the appli containing the applications present in the project.
109 * @return The appli object present in the project.
111 modelCDMAppli* GetAppli() const;
114 * Retrieves the lib containing the libraries present in the project.
115 * @return The lib object present in the project.
117 modelCDMLib* GetLib() const;
120 * Retrieves the default make instruction to compile the project.
121 * @return The make instruction to compile.
123 std::string GetBuildInstruction() const;
128 * Sets the version of the project. It also modifies the build date of the project.
129 * @param version New version of the project.
130 * @param result returns the result of the operation.
131 * @return If the version configuration was successful it returns true. If not, it returns false and the error description returns in the parameter result.
133 bool SetVersion(const std::string& version, std::string*& result);
136 * Sets the build path of the project.
137 * @param path Path for builing the project.
138 * @param result Result of the operation.
139 * @return If the build path configuration was successful it returns true. If not, it returns false and the error description returns in the parameter result.
141 bool SetBuildPath(const std::string& path, std::string*& result);
146 * Creates a package and sets it as a children of the project. This method creates the package in the hard drive and also in the model. The created package is included in the project's CMakeLists file.
147 * @param name Name of the package.
148 * @param result Result of the operation.
149 * @param authors Authors of the operation. If any space is found, it will be replaced by '_'.
150 * @param authorsEmail Authors' E-mails. This is appended to the package description.
151 * @param description Package description.
152 * @param version Package version in the format X.Y.Z where X is the major version, Y the minor version, and Z the build version.
153 * @return The result of the creation. If everything goes well it returns true, else it returns false.
155 modelCDMIProjectTreeNode* CreatePackage(
156 const std::string& name,
157 std::string*& result,
158 const std::string& authors = "info-dev",
159 const std::string& authorsEmail = "info-dev@creatis.insa-lyon.fr",
160 const std::string& description = "no description",
161 const std::string& version = "1.0.0"
165 * Creates a library and sets it as a children of the lib folder in the project. This method creates the library in the hard drive and also in the model.
166 * @param name Library name.
167 * @param result Result of the operation.
168 * @param path Path of the library if not in the lib folder. This parameter is not used (for now).
169 * @return The result of the creation. If everything goes well it returns true, else it returns false.
171 modelCDMIProjectTreeNode* CreateLibrary(
172 const std::string& name,
173 std::string*& result,
174 const std::string& path = "/lib"
178 * Creates an application and sets it as a children of the appli folder in the project. This method creates the library in the hard drive and also in the model.
179 * @param name Application name.
180 * @param type Application type. 0=console application, 1=GUI application (wxWidgets).
181 * @param result Result of the operation.
182 * @param path Path of the application if not in the application folder. This parameter is not used (for now).
183 * @return The result of the creation. If everything goes well it returns true, else it returns false.
185 modelCDMIProjectTreeNode* CreateApplication(
186 const std::string& name,
188 std::string*& result,
189 const std::string& path = "/appli"
193 * Creates a black box and sets it as a children of the specified package folder in the project. This method creates the black box in the hard drive and also in the model.
194 * @param name Black box name.
195 * @param package The name of the package where the black box is created. The name should not contain neither the "bbtk_" , nor the "_PKG" parts of the folder name. If empty converts into "/bbtk_*projectName*_PKG"
196 * @param authors The authors of the black box. This string should not contain commas or spaces, they will be replaced by '_'.
197 * @param authorsEmail The authors e-mails. This string should not contain spaces, they will be replaced by '/'. This field is appended to the black box description.
198 * @param categories The categories of concerning for the created black box.
199 * @param description Description of the black box. It should not contain spaces, they will be replaced by '_'.
200 * @return The result of the creation. If everything goes well it returns true, else it returns false.
202 modelCDMIProjectTreeNode* CreateBlackBox(
203 const std::string& name,
204 const std::string& package = "", //if empty converts into "[projectName]"
205 const std::string& authors = "unknown",
206 const std::string& authorsEmail = "",
207 const std::string& categories = "empty",
208 const std::string& description = "no description"
214 * Opens the CMakeLists.txt file in the system's default text editor.
215 * @param result Result of the operation.
216 * @return Success of the operation. If the file doesn't exist or can't be opened it returns false.
218 bool OpenCMakeListsFile(std::string*& result);
221 * Refresh the model with the file hierarchy in the hard drive.
222 * @param result Result of the operation.
223 * @return if there's an error refreshing the project it returns false.
225 virtual const bool Refresh(std::string*& result);
228 * Launches in console the ccmake tool in the build path to configure the building of the project.
229 * @param result The result message of the operation.
230 * @return if the ccmake tool doesn't launches it returns false.
232 bool ConfigureBuild(std::string*& result);
235 * Launches in console the make -clean and make commands to build the project.
236 * @param result Result message for building the project.
237 * @param line Line to execute the compilation.
238 * @return if any of the commands cannot be executed it return false.
240 bool Build(std::string*& result, const std::string& line);
243 * Launches in console the bbPlugPackage command to connect the project to the .bbtk folder in the hard drive.
244 * @param result Result message for connecting the project.
245 * @param folder Folder to make connection with. It must contain the bbtkPackage file
246 * @return if the command cannot be executed it return false.
248 bool Connect(std::string*& result, const std::string& folder);
251 * Checks the CMakeLists files to see what's going to be compiled and what's not.
252 * @param properties Map containing the project compilation properties.
254 void CheckStructure(std::map<std::string, bool>& properties);
257 * Checks if the given package is included in the CMakeLists file.
258 * @param package_name Name of the package to check.
259 * @return True if the package is included, otherwise returns False.
261 bool IsPackageIncluded(const std::string& package_name);
264 * Sets the inclusion of the package in the project's CMakeLists file. If the package inclusion already exist in file, then the line is uncommented/commented depending on the requested action. If the package inclusion doesn't exist yet, then it is included if the request is an inclusion.
265 * @param package_name Name of the package to include/exclude.
266 * @param toInclude True if the request is an inclusion, False otherwise.
267 * @return True if the request was processed successfully.
269 bool SetPackageInclude(const std::string& package_name, const bool& toInclude);
272 * Checks the project folder's CMakeLists file to check which third party libraries are enabled.
273 * @return A map with the name of the library and if it's included in the CMakeLists file.
275 std::map<std::string, bool> Get3rdPartyLibraries();
278 * Sets the 3rd party library inclusion in the CMakeLists file.
279 * @return if the operation was successful.
281 bool Set3rdPartyLibrary(const std::string& library_name, const bool& toInclude);
289 std::string nameProject;
295 * Last Project Version Modification Date
297 std::string versionDate;
299 * Build Path for compiling the project
301 std::string buildPath;
310 modelCDMAppli* appli;
314 std::vector<modelCDMPackage*> packages;
318 #endif /* MODELCDMPROJECT_H_ */