]> Creatis software - crea.git/blob - lib/creaDevManagerLib/modelCDMProject.h
Feature #1711
[crea.git] / lib / creaDevManagerLib / modelCDMProject.h
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Sant�)
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
9 #
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.
16 #
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
21 #  liability. 
22 #
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 # ------------------------------------------------------------------------ 
26  */
27
28 /*
29  * modelCDMProject.h
30  *
31  *  Created on: 13/11/2012
32  *      Author: Daniel Felipe Gonzalez Obando
33  */
34
35 #ifndef MODELCDMPROJECT_H_
36 #define MODELCDMPROJECT_H_
37
38 #include<iostream>
39 #include<vector>
40
41 #include "modelCDMFolder.h"
42 #include "modelCDMLib.h"
43 #include "modelCDMAppli.h"
44 #include "modelCDMPackage.h"
45 #include "modelCDMCMakeListsFile.h"
46
47 /**
48  * Project model class.
49  * This class represents a project stored in a hard drive. It can perform some of the most relevant operations for a crea project.
50  */
51 class modelCDMProject : public modelCDMFolder
52 {
53 public:
54   /**
55    * Default constructor.
56    */
57   modelCDMProject();
58
59   /**
60    * Constructor receiving the source path and the build path.
61    * @param path The source path.
62    * @param buildPath The build path. By default it's an empty string.
63    */
64   modelCDMProject(const std::string& path, const std::string& name, const std::string& buildPath = "");
65
66   /**
67    * Destructor.
68    */
69   ~modelCDMProject();
70
71   /**
72    * Unimplemented.
73    */
74   void PopulateProject();
75
76
77   //Getters
78   /**
79    * Retrieves the name of the project.
80    * @return The name of the project.
81    */
82   const std::string& GetNameProject() const;
83
84   /**
85    * Retrieves the version of the project.
86    * @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    */
88   const std::string& GetVersion() const;
89
90   /**
91    * Retrieves the last version modification date of the project
92    * @return The date of the last version modification in the format DD/MM/YYYY
93    */
94   const std::string& GetVersionDate() const;
95
96   /**
97    * Retrieves the build path of the project.
98    * @return The build path of the project. By default .../ProjectNameBin.
99    */
100   const std::string& GetBuildPath() const;
101
102   /**
103    * Retrieves the package vector containing the packages present in the project.
104    * @return The package vector containing references to the packages of the project.
105    */
106   const std::vector<modelCDMPackage*>& GetPackages() const;
107
108   /**
109    * Retrieves the appli containing the applications present in the project.
110    * @return The appli object present in the project.
111    */
112   modelCDMAppli* GetAppli() const;
113
114   /**
115    * Retrieves the lib containing the libraries present in the project.
116    * @return The lib object present in the project.
117    */
118   modelCDMLib* GetLib() const;
119
120
121   //Setters
122   /**
123    * Sets the version of the project. It also modifies the build date of the project.
124    * @param version New version of the project.
125    * @param result returns the result of the operation.
126    * @return If the version configuration was successful it returns true. If not, it returns false and the error description returns in the parameter result.
127    */
128   bool SetVersion(const std::string& version, std::string*& result);
129
130   /**
131    * Sets the build path of the project.
132    * @param path Path for builing the project.
133    * @param result Result of the operation.
134    * @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.
135    */
136   bool SetBuildPath(const std::string& path, std::string*& result);
137
138
139   //Creations
140   /**
141    * 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.
142    * @param name Name of the package.
143    * @param result Result of the operation.
144    * @param authors Authors of the operation. If any space is found, it will be replaced by '_'.
145    * @param authorsEmail Authors' E-mails. This is appended to the package description.
146    * @param description Package description.
147    * @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.
148    * @return The result of the creation. If everything goes well it returns true, else it returns false.
149    */
150   modelCDMIProjectTreeNode* CreatePackage(
151       const std::string& name,
152       std::string*& result,
153       const std::string& authors = "info-dev",
154       const std::string& authorsEmail = "info-dev@creatis.insa-lyon.fr",
155       const std::string& description = "no description",
156       const std::string& version = "1.0.0"
157   );
158
159   /**
160    * 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.
161    * @param name Library name.
162    * @param result Result of the operation.
163    * @param path Path of the library if not in the lib folder. This parameter is not used (for now).
164    * @return The result of the creation. If everything goes well it returns true, else it returns false.
165    */
166   modelCDMIProjectTreeNode* CreateLibrary(
167       const std::string& name,
168       std::string*& result,
169       const std::string& path = "/lib"
170   );
171
172   /**
173    * 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.
174    * @param name Application name.
175    * @param result Result of the operation.
176    * @param path Path of the application if not in the application folder. This parameter is not used (for now).
177    * @return The result of the creation. If everything goes well it returns true, else it returns false.
178    */
179   modelCDMIProjectTreeNode* CreateApplication(
180       const std::string& name,
181       std::string*& result,
182       const std::string& path = "/appli"
183   );
184
185   /**
186    * 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.
187    * @param name Black box name.
188    * @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"
189    * @param authors The authors of the black box. This string should not contain commas or spaces, they will be replaced by '_'.
190    * @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.
191    * @param categories The categories of concerning for the created black box.
192    * @param description Description of the black box. It should not contain spaces, they will be replaced by '_'.
193    * @return The result of the creation. If everything goes well it returns true, else it returns false.
194    */
195   modelCDMIProjectTreeNode* CreateBlackBox(
196       const std::string& name,
197       const std::string& package = "", //if empty converts into "/bbtk_*projectName*_PKG"
198       const std::string& authors = "unknown",
199       const std::string& authorsEmail = "",
200       const std::string& categories = "empty",
201       const std::string& description = "no description"
202   );
203
204
205   //Operations
206   /**
207    * Opens the CMakeLists.txt file in the system's default text editor.
208    * @param result Result of the operation.
209    * @return Success of the operation. If the file doesn't exist or can't be opened it returns false.
210    */
211   bool OpenCMakeListsFile(std::string*& result);
212
213   /**
214    * Refresh the model with the file hierarchy in the hard drive.
215    * @param result Result of the operation.
216    * @return if there's an error refreshing the project it returns false.
217    */
218   virtual const bool Refresh(std::string*& result);
219
220   /**
221    * Launches in console the ccmake tool in the build path to configure the building of the project.
222    * @param result The result message of the operation.
223    * @return if the ccmake tool doesn't launches it returns false.
224    */
225   bool ConfigureBuild(std::string*& result);
226
227   /**
228    * Launches in console the make -clean and make commands to build the project.
229    * @param result Result message for building the project.
230    * @return if any of the commands cannot be executed it return false.
231    */
232   bool Build(std::string*& result);
233
234   /**
235    * Launches in console the bbPlugPackage command to connect the project to the .bbtk folder in the hard drive.
236    * @param result Result message for connecting the project.
237    * @return if the command cannot be executed it return false.
238    */
239   bool Connect(std::string*& result);
240
241
242 private:
243
244   std::string nameProject;
245   std::string version;
246   std::string versionDate;
247   std::string buildPath;
248
249   modelCDMLib* lib;
250   modelCDMAppli* appli;
251   std::vector<modelCDMPackage*> packages;
252
253 };
254
255 #endif /* MODELCDMPROJECT_H_ */