#include "modelCDMProject.h"
+#include <iostream>
+#include <vector>
+#include <fstream>
+
+#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<std::string> wordBits;
+ CDMUtilities::splitter::split(wordBits,word," (\n",CDMUtilities::splitter::no_empties);
+
+ if(wordBits[wordBits.size()-1] == "PROJECT")
+ {
+ std::getline(confFile,word,')');
+ std::vector<std::string> 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<std::string> 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<std::string> 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<std::string> 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<std::string> 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&
return true;
}
-bool modelCDMProject::Refresh(std::string*& result)
+const bool modelCDMProject::Refresh(std::string*& result)
{
//TODO: implement method
return true;