Commit 09c35ffc authored by vlad_burin's avatar vlad_burin
Browse files

Run Time Libraries working version (not final)

Qt GUI UClassesListWidget updated.

--HG--
branch : RunTimeLibsTest
parent 512c32083df3
......@@ -7354,8 +7354,9 @@ void UEngine::CreateEnvironment(bool isinit, list<UContainer*>* external_classes
++I;
}
}
Storage->InitRTlibs();
Logger->LogMessage(RDK_EX_DEBUG, "Build storage has been started...");
Storage->InitRTlibs();
Storage->BuildStorage();
Logger->LogMessage(RDK_EX_DEBUG, "Build storage has been finished");
}
......
......@@ -205,7 +205,9 @@ int ULibrary::Upload(UStorage *storage)
CreateClassSamples(Storage);
count=int(Complete.size());
//Storage=0;
// Storage RunTime
if(Type != 2)
Storage=0;
return count;
}
// --------------------------
......@@ -385,8 +387,8 @@ void ULibrary::RemoveClassFromCompletedList(const string &name)
// --------------------------
//
// --------------------------
URuntimeLibrary::URuntimeLibrary(const string &name, const string &version)
: ULibrary(name,version,2)
URuntimeLibrary::URuntimeLibrary(const string &name, const string &version, const string& path)
: ULibrary(name,version,2), LibPath(path)
{
}
......@@ -400,48 +402,59 @@ URuntimeLibrary::~URuntimeLibrary(void)
// --------------------------
//
// --------------------------
///
const USerStorageXML& URuntimeLibrary::GetCurrentComponentStruct(void) const
vector<string>& URuntimeLibrary::GetClassesStructures()
{
return ClassesStructures;
}
///
const std::string& URuntimeLibrary::GetLibPath() const
{
return CurrentComponentStruct;
return LibPath;
}
///
bool URuntimeLibrary::LoadCompDescriptions()
{
//
std::string lib_path = "../../../RTlibs/" + Name;
// xml
// ClassesStructures
std::vector<std::string> comp_descriptions;
if(RDK::FindFilesList(lib_path,"*.xml",true,comp_descriptions))
if(RDK::FindFilesList(LibPath,"*.xml",true,comp_descriptions))
return false;
ClassesStructures.resize(comp_descriptions.size());
for(int i = 0 ; i < comp_descriptions.size(); i++)
{
//
CurrentComponentStruct.LoadFromFile(lib_path+"/"+comp_descriptions[i],"");
CurrentComponentStruct.LoadFromFile(LibPath+"/"+comp_descriptions[i],"");
//
CurrentComponentStruct.Save(ClassesStructures[i]);
}
CurrentComponentStruct.Destroy();
return true;
}
/// ( )
bool URuntimeLibrary::AddNewClass(const std::string &new_class_name, UContainer *newclass)
{
UEPtr<UComponent> p = newclass;
UEPtr<UContainer> p = newclass;
UEPtr<UNet> cont = dynamic_pointer_cast<UNet>(p);
std::string buff;
std::string buff;
// XML .
// Destroy() , . Create
CurrentComponentStruct.Create("stub");
CurrentComponentStruct.Destroy();
// XML RTname
// TODO XML
// XML RTname
cont->SaveComponent(&CurrentComponentStruct, true, ptPubParameter);
CurrentComponentStruct.SelectNode(cont->GetName());
CurrentComponentStruct.SetNodeAttribute("RTname", new_class_name);
......@@ -450,8 +463,7 @@ bool URuntimeLibrary::AddNewClass(const std::string &new_class_name, UContainer
//std::string class_name = CurrentComponentStruct.GetNodeAttribute("Class");
//cont=dynamic_pointer_cast<UNet>(Storage->TakeObject(class_name));
std::string lib_path = "../../../RTlibs/" + Name;
CurrentComponentStruct.SaveToFile(lib_path+"/"+new_class_name+".xml");
CurrentComponentStruct.SaveToFile(LibPath+"/"+new_class_name+".xml");
UEPtr<UContainer> cont_1 = CreateClassSample(Storage, CurrentComponentStruct);
......@@ -460,8 +472,6 @@ bool URuntimeLibrary::AddNewClass(const std::string &new_class_name, UContainer
ClassesStructures.push_back(buff);
CurrentComponentStruct.Destroy();
return true;
}
......@@ -480,30 +490,39 @@ bool URuntimeLibrary::ReplaceClass(const std::string &new_class_name, UContainer
/// Storage
bool URuntimeLibrary::DelClass(const std::string &class_name)
{
// TODO
URuntimeLibrary *library = nullptr;
// .
if(Storage->CheckClass(class_name))
{
UEPtr<ULibrary> lib = Storage->GetCollection(class_name);
library = dynamic_cast<URuntimeLibrary*>(lib.Get());
Storage->DelClass(Storage->FindClassId(class_name));
}
CurrentComponentStruct.Destroy();
auto ClStr = library->GetClassesStructures();
for(auto it = ClassesStructures.begin(); it != ClassesStructures.end(); ++it)
for(auto it = ClStr.begin(); it != ClStr.end(); ++it)
{
// xml
CurrentComponentStruct.Load(*it,"");
std::string search_name = CurrentComponentStruct.GetNodeAttribute("RTname");
if(class_name == search_name)
{
ClassesStructures.erase(it);
ClStr.erase(it);
std::string xml_path = "../../../RTlibs/" + library->GetName() +"/" + search_name + ".xml";
RDK::DeleteFile(xml_path.c_str());
break;
}
}
CurrentComponentStruct.Destroy();
}
bool URuntimeLibrary::DeleteOwnDirectory(void)
{
//
std::string lib_path = "../../../RTlibs/" + Name;
RDK::DeleteDirectory(lib_path.c_str());
RDK::DeleteDirectory(LibPath.c_str());
}
// --------------------------
......@@ -543,7 +562,6 @@ void URuntimeLibrary::CreateClassSamples(UStorage *storage)
{
try
{
CurrentComponentStruct.Destroy();
CurrentComponentStruct.Load(ClassesStructures[i],"");
UEPtr<UContainer> cont=CreateClassSample(storage, CurrentComponentStruct);
......@@ -557,7 +575,6 @@ void URuntimeLibrary::CreateClassSamples(UStorage *storage)
// smth
}
}
CurrentComponentStruct.Destroy();
}
// --------------------------
......
......@@ -193,6 +193,9 @@ protected: //
protected: //
protected: //
///
std::string LibPath;
/// XML
USerStorageXML CurrentComponentStruct;
......@@ -203,16 +206,17 @@ public: //
// --------------------------
//
// --------------------------
URuntimeLibrary(const string &name, const string &version);
URuntimeLibrary(const string &name, const string &version, const string& path);
virtual ~URuntimeLibrary(void);
// --------------------------
// --------------------------
//
// --------------------------
///
const USerStorageXML& GetCurrentComponentStruct(void) const;
vector<string>& GetClassesStructures();
///
const std::string& GetLibPath() const;
/// (, )
bool AddNewClass(const std::string &new_class_name, UContainer *newclass);
......
......@@ -889,6 +889,10 @@ const string& UStorage::GetCollectionVersion(int index)
///
bool UStorage::AddClassToCollection(const std::string &new_class_name, bool force_replace, UContainer *newclass, const std::string &lib_name)
{
try
{
//
// + Upload
URuntimeLibrary *library = nullptr;
......@@ -903,6 +907,7 @@ bool UStorage::AddClassToCollection(const std::string &new_class_name, bool forc
}
//
// TODO ,
if(CheckClass(new_class_name))
{
//
......@@ -920,6 +925,13 @@ bool UStorage::AddClassToCollection(const std::string &new_class_name, bool forc
library->AddNewClass(new_class_name, newclass);
}
}
catch(UException &ex)
{
if(Logger)
Logger->LogMessage(RDK_EX_ERROR, __FUNCTION__, ex.what());
}
return true;
}
......@@ -938,7 +950,8 @@ bool UStorage::DelClassFromCollection(const std::string &class_name, const std::
library = dynamic_cast<URuntimeLibrary*>(lib.Get());
}
}
// TODO Storage
//
library->DelClass(class_name);
return true;
}
......@@ -950,23 +963,64 @@ bool UStorage::CreateRuntimeCollection(const std::string &lib_name)
if(lib_name.empty())
return false;
URuntimeLibrary* lib=new URuntimeLibrary(lib_name,"");
// TODO
if(GetCollection(lib_name) != nullptr)
return false;
//
std::string lib_path = "../../../RTlibs/" + lib_name;
URuntimeLibrary* lib=new URuntimeLibrary(lib_name,"", lib_path);
if(AddCollection(lib))
{
//
std::string lib_path = "../../../RTlibs/" + lib_name;
if(RDK::CreateNewDirectory(lib_path.c_str())==0)
if(RDK::CreateNewDirectory(lib->GetLibPath().c_str())==0)
{
return true;
}
else
{
delete lib;
return false;
}
}
else
{
delete lib;
return false;
}
}
/// runtime-
bool UStorage::DeleteRuntimeCollection(const std::string &lib_name)
{
int index = 0;
for(size_t i=0;i<CollectionList.size();i++)
{
UEPtr<ULibrary> lib=CollectionList[i];
if(lib && lib->GetName() == lib_name)
{
index = i;
break;
}
}
if(index < 0 || index >= int(CollectionList.size()))
return false;
std::vector<ULibrary*>::iterator I=CollectionList.begin()+index;
if((*I)->GetType() == 2)
{
static_cast<URuntimeLibrary*>(*I)->DeleteOwnDirectory();
delete *I;
CollectionList.erase(I);
DelAbandonedClasses();
return true;
}
else
{
delete lib;
return false;
}
}
......@@ -982,18 +1036,17 @@ void UStorage::InitRTlibs(void)
// ClassesStructures
std::vector<std::string> lib_names;
// TODO
if(RDK::FindFilesList(lib_path,"*",false,lib_names))
return;
for(int i = 0 ; i < lib_names.size(); i++)
{
LoadRuntimeCollection(lib_names[i],true);
LoadRuntimeCollection(lib_names[i]);
}
}
/// runtime-
bool UStorage::LoadRuntimeCollection(const std::string &lib_name, bool force_build)
bool UStorage::LoadRuntimeCollection(const std::string &lib_name)
{
// runtime-
if(lib_name.empty())
......@@ -1003,13 +1056,16 @@ bool UStorage::LoadRuntimeCollection(const std::string &lib_name, bool force_bui
if(GetCollection(lib_name) != nullptr)
return false;
URuntimeLibrary* lib = new URuntimeLibrary(lib_name,"");
//
std::string lib_path = "../../../RTlibs/" + lib_name;
URuntimeLibrary* lib = new URuntimeLibrary(lib_name,"",lib_path);
//
if(lib->LoadCompDescriptions())
lib->LoadCompDescriptions();
if(AddCollection(lib, true))
if(AddCollection(lib))
{
return true;
}
......@@ -1057,7 +1113,7 @@ bool UStorage::DelCollection(int index)
std::vector<ULibrary*>::iterator I=CollectionList.begin()+index;
if((*I)->GetType() == 2)
{
static_cast<URuntimeLibrary*>(*I)->DeleteOwnDirectory();
//static_cast<URuntimeLibrary*>(*I)->DeleteOwnDirectory();
delete *I;
}
CollectionList.erase(I);
......
......@@ -37,7 +37,6 @@ typedef std::map<std::string, UEPtr<UContainerDescription> >::iterator UClassesD
typedef std::map<std::string, UEPtr<UContainerDescription> >::const_iterator UClassesDescriptionCIterator;
typedef std::vector<ULibrary*> UClassLibraryList;
typedef std::vector<URuntimeLibrary*> URTLibraryList;
/* *********************************************************************** */
//
class RDK_LIB_TYPE UInstancesStorageElement
......@@ -303,11 +302,11 @@ const string& GetCollectionVersion(int index);
// RT-
///
/// Engine
/// Engine . CollectionList
void InitRTlibs(void);
/// runtime-
virtual bool LoadRuntimeCollection(const std::string &lib_name, bool force_build=false);
virtual bool LoadRuntimeCollection(const std::string &lib_name);
/// ( )
/// force_replace = true
......@@ -319,6 +318,8 @@ virtual bool DelClassFromCollection(const std::string &class_name, const std::st
///
virtual bool CreateRuntimeCollection(const std::string &lib_name);
/// runtime-
bool DeleteRuntimeCollection(const std::string &lib_name);
// .
// false.
......
......@@ -5,12 +5,14 @@
#include <QDragMoveEvent>
#include <QDrag>
#include <QDebug>
#include <QDialog>
UClassesListWidget::UClassesListWidget(QWidget *parent, RDK::UApplication *app) :
UVisualControllerWidget(parent, app),
ui(new Ui::UClassesListWidget)
{
ui->setupUi(this);
UpdateInterval = 0; //
setAccessibleName("UClassesListWidget"); //
......@@ -66,7 +68,6 @@ UClassesListWidget::UClassesListWidget(QWidget *parent, RDK::UApplication *app)
ui->listWidgetRTlibs->addItems(componentNames);
ui->listWidgetRTlibs->sortItems(Qt::AscendingOrder);
//
connect(ui->treeWidgetStorageByLibs, SIGNAL(pressed(QModelIndex)), this, SLOT(dragEvent(QModelIndex)));
connect(ui->listWidgetStorageByName, SIGNAL(pressed(QModelIndex)), this, SLOT(dragEvent(QModelIndex)));
......@@ -75,6 +76,24 @@ UClassesListWidget::UClassesListWidget(QWidget *parent, RDK::UApplication *app)
connect(ui->treeWidgetStorageByLibs, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SIGNAL(classSelectionChanged()));
connect(ui->listWidgetStorageByName, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SIGNAL(classSelectionChanged()));
//
ui->listWidgetRTlibs->addAction(ui->actionCreateRuntimeLibrary);
ui->listWidgetRTlibs->addAction(ui->actionDeleteRuntimeLibrary);
ui->listWidgetRTlibs->setContextMenuPolicy(Qt::ActionsContextMenu);
connect(ui->actionCreateRuntimeLibrary, SIGNAL(triggered()), this, SLOT(CreateRTlibrary()));
connect(ui->actionDeleteRuntimeLibrary, SIGNAL(triggered()), this, SLOT(DeleteRTlibrary()));
ui->listWidgetRTlibs->setContextMenuPolicy(Qt::ActionsContextMenu);
//
ui->listWidgetRTlibClasses->addAction(ui->actionAddNewClass);
ui->listWidgetRTlibClasses->addAction(ui->actionDeleteClass);
connect(ui->actionAddNewClass, SIGNAL(triggered()), this, SLOT(AddNewClass()));
connect(ui->actionDeleteClass, SIGNAL(triggered()), this, SLOT(DeleteClass()));
ui->listWidgetRTlibClasses->setContextMenuPolicy(Qt::ActionsContextMenu);
}
UClassesListWidget::~UClassesListWidget()
......@@ -114,7 +133,6 @@ void UClassesListWidget::AUpdateInterface(void)
ui->listWidgetRTlibs->clear();
ui->listWidgetRTlibs->addItems(componentNames);
ui->listWidgetRTlibs->sortItems(Qt::AscendingOrder);
}
void UClassesListWidget::dragEvent(QModelIndex index)
......@@ -199,7 +217,28 @@ void UClassesListWidget::on_lineEdit_textChanged(const QString &arg1)
if (reply == QMessageBox::Cancel) return;*/
}
void UClassesListWidget::on_CreateRTlibButton_clicked()
void UClassesListWidget::on_listWidgetRTlibs_itemSelectionChanged()
{
QListWidgetItem* item = ui->listWidgetRTlibs->currentItem();
QString lib_name = item->text();
//
const char* stringBuff = Storage_GetLibraryClassNames(lib_name.toLocal8Bit());
QStringList libClasses = QString(stringBuff).split(",");
Engine_FreeBufString(stringBuff);
QString className;
ui->listWidgetRTlibClasses->clear();
foreach(className, libClasses)
{
if(className != "")
{
ui->listWidgetRTlibClasses->addItem(className);
}
}
}
void UClassesListWidget::CreateRTlibrary()
{
RDK::UELockPtr<RDK::UStorage> storage=RDK::GetStorageLock();
......@@ -213,25 +252,41 @@ void UClassesListWidget::on_CreateRTlibButton_clicked()
AUpdateInterface();
}
void UClassesListWidget::on_AddNewClassButton_clicked()
void UClassesListWidget::DeleteRTlibrary()
{
QListWidgetItem* item = ui->listWidgetRTlibs->currentItem();
QString lib_name = item->text().toUtf8().data();
RDK::UELockPtr<RDK::UStorage> storage=RDK::GetStorageLock();
if(!storage)
return;
storage->DeleteRuntimeCollection(lib_name.toLocal8Bit().data());
AUpdateInterface();
}
void UClassesListWidget::AddNewClass()
{
RDK::UELockPtr<RDK::UEngine> engine=RDK::GetEngineLock();
if(!engine)
return;
std::string lib_name = ui->lineEdit->text().toUtf8().data();
//std::string new_comp_name = ui->CompName->text().toUtf8().data();
std::string cont_name = ui->lineEdit->text().toUtf8().data();
std::string new_comp_name = ui->lineEditSearch->text().toUtf8().data();
std::string lib_name = ui->listWidgetRTlibs->currentItem()->text().toUtf8().data();
auto container = engine->GetModel()->GetComponent("Capture", true);
RDK::UEPtr<RDK::UContainer> container = engine->GetModel()->GetComponent(cont_name, true);
engine->GetEnvironment()->
GetStorage()->AddClassToCollection(lib_name,true,container,"NewLiba");
GetStorage()->AddClassToCollection(new_comp_name,true,container,lib_name);
AUpdateInterface();
}
void UClassesListWidget::on_DeleteClassButton_clicked()
void UClassesListWidget::DeleteClass()
{
RDK::UELockPtr<RDK::UStorage> storage=RDK::GetStorageLock();
......@@ -245,43 +300,6 @@ void UClassesListWidget::on_DeleteClassButton_clicked()
QString class_name = item->text();
//TODO +
storage->DelClassFromCollection(class_name.toUtf8().data(), lib_name.toUtf8().data());
AUpdateInterface();
}
void UClassesListWidget::on_listWidgetRTlibs_itemSelectionChanged()
{
QListWidgetItem* item = ui->listWidgetRTlibs->currentItem();
QString lib_name = item->text().toUtf8().data();
//
const char* stringBuff = Storage_GetLibraryClassNames(lib_name.toLocal8Bit());
QStringList libClasses = QString(stringBuff).split(",");
Engine_FreeBufString(stringBuff);
QString className;
ui->listWidgetRTlibClasses->clear();
foreach(className, libClasses)
{
if(className != "")
{
ui->listWidgetRTlibClasses->addItem(className);
}
}
}
void UClassesListWidget::on_DeleteLibButton_clicked()
{
QListWidgetItem* item = ui->listWidgetRTlibs->currentItem();
QString lib_name = item->text().toUtf8().data();
RDK::UELockPtr<RDK::UStorage> storage=RDK::GetStorageLock();
if(!storage)
return;
storage->DelCollection(lib_name.toLocal8Bit().data());
AUpdateInterface();
}
......@@ -42,21 +42,23 @@ signals:
private slots:
void on_lineEdit_textChanged(const QString &arg1);
void on_CreateRTlibButton_clicked();
void on_AddNewClassButton_clicked();
//
void on_listWidgetRTlibs_itemSelectionChanged();
void on_DeleteLibButton_clicked();
void on_DeleteClassButton_clicked();
public slots:
//
// /
void CreateRTlibrary();
void DeleteRTlibrary();
///
void AddNewClass();
void DeleteClass();
private:
Ui::UClassesListWidget *ui;
UDrawEngineImageWidget* neighbor;
};
#endif // UCLASSESLISTWIDGET_H
......@@ -162,60 +162,43 @@
</layout>
</widget>
</item>