From 4634377e45465b15485afc9da74a5bf13b32d17b Mon Sep 17 00:00:00 2001 From: ctorres Date: Mon, 12 May 2014 09:46:06 +0200 Subject: [PATCH] Obtaining the tree boxes related to a sigle box. The classes changed were Utilities, Package, BlackBoxDescriptor and ComplexBlackBoxDescriptor. Date: 12/05/2014 9:45am --- kernel/src/bbtkBlackBoxDescriptor.cxx | 4 +- kernel/src/bbtkBlackBoxDescriptor.h | 4 +- kernel/src/bbtkComplexBlackBoxDescriptor.cxx | 46 ++++++++++- kernel/src/bbtkComplexBlackBoxDescriptor.h | 6 +- kernel/src/bbtkPackage.cxx | 14 +++- kernel/src/bbtkPackage.h | 3 + kernel/src/bbtkUtilities.cxx | 81 ++++++++++++++++++++ kernel/src/bbtkUtilities.h | 29 ++++++- 8 files changed, 178 insertions(+), 9 deletions(-) diff --git a/kernel/src/bbtkBlackBoxDescriptor.cxx b/kernel/src/bbtkBlackBoxDescriptor.cxx index 7427580..9f40f1f 100644 --- a/kernel/src/bbtkBlackBoxDescriptor.cxx +++ b/kernel/src/bbtkBlackBoxDescriptor.cxx @@ -315,7 +315,9 @@ namespace bbtk return "::" + mTypeName; } //========================================================================= - + void BlackBoxDescriptor::GetBoxesInside (NodeTreeC& tree, std::vector& temp, int cont){ + + } //========================================================================= void BlackBoxDescriptor::InsertHtmlHelp ( std::ofstream& s, int detail, int level, diff --git a/kernel/src/bbtkBlackBoxDescriptor.h b/kernel/src/bbtkBlackBoxDescriptor.h index ca8f355..25f4544 100644 --- a/kernel/src/bbtkBlackBoxDescriptor.h +++ b/kernel/src/bbtkBlackBoxDescriptor.h @@ -51,7 +51,7 @@ #include "bbtkBlackBoxOutputDescriptor.h" #include #include - +#include "bbtkUtilities.h" namespace bbtk { @@ -170,7 +170,7 @@ namespace bbtk /// virtual void Check(bool recursive=true) const; - + virtual void GetBoxesInside (NodeTreeC& tree, std::vector& temp, int cont); /// Sets the name of the script file from which it is defined void SetScriptFileName(const std::string& n) { mScriptFileName = n; } diff --git a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx index 20d2ca9..c25819f 100644 --- a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx +++ b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx @@ -416,7 +416,7 @@ namespace bbtk Package::Pointer p = d->GetPackage(); std::string name = b->second->bbGetTypeName(); - + std::string url; if (relative_link) url = p->GetDocRelativeURL(); @@ -666,6 +666,50 @@ size_t ComplexBlackBoxDescriptor::GetObjectInternalSize() const return s; } //========================================================================== +void ComplexBlackBoxDescriptor::GetBoxesInside (NodeTreeC& tree, std::vector& list, int cont) + { + std::string name = GetTypeName(); + std::string descr = GetDescription(); + std::string author = GetAuthor(); + list.push_back(name); + tree.setData(name); + // list.push_back(descr); + // list.push_back(author); + int k = 0; + const ComplexBlackBox::BlackBoxMapType& B = mPrototype->bbGetBlackBoxMap(); + if (B.size()) + { + std::set pdeps; + ComplexBlackBox::BlackBoxMapType::const_iterator b; + for ( b = B.begin(); b != B.end(); ++b ) + { + BlackBoxDescriptor::Pointer d = b->second->bbGetDescriptor(); + + + //if (pdeps.find(d) != pdeps.end()) + // continue; + //pdeps.insert(d); + + Package::Pointer p = d->GetPackage(); + std::string nameBox = b->second->bbGetTypeName(); + std::string packageBox = p->GetName(); + + tree.insertChild(nameBox); + + list.push_back(nameBox); + list.push_back(packageBox); + + d->GetBoxesInside (tree.childs[k],list, cont+1); + k++; + } // for + + } // If B.size + + } + +//=================================================== + + //========================================================================== } diff --git a/kernel/src/bbtkComplexBlackBoxDescriptor.h b/kernel/src/bbtkComplexBlackBoxDescriptor.h index 34fc4a3..f9e7f8d 100644 --- a/kernel/src/bbtkComplexBlackBoxDescriptor.h +++ b/kernel/src/bbtkComplexBlackBoxDescriptor.h @@ -51,7 +51,8 @@ #include "bbtkComplexBlackBoxOutputDescriptor.h" #include "bbtkFactory.h" #include - +#include +#include "bbtkUtilities.h" namespace bbtk { @@ -143,7 +144,7 @@ namespace bbtk const std::string& output_dir = "", bool relative_link = false ); - + void GetBoxesInside (NodeTreeC& tree, std::vector& list, int cont); /// virtual void Check(bool recursive=true) const; @@ -165,7 +166,6 @@ namespace bbtk //========================================================================== - } // namespace bbtk #endif diff --git a/kernel/src/bbtkPackage.cxx b/kernel/src/bbtkPackage.cxx index 9b692c9..1b0abc0 100644 --- a/kernel/src/bbtkPackage.cxx +++ b/kernel/src/bbtkPackage.cxx @@ -1404,10 +1404,22 @@ namespace bbtk return s; } //========================================================================== - + void Package::GetBoxesInside(NodeTreeC& tree, std::vector& list, int cont) + { + DescriptorMapType::const_iterator i; + + std::vector temp; + for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i) + { + i->second->GetBoxesInside(tree, list, cont); + list.insert( list.end(), temp.begin(), temp.end() ); + } + } + //========================================================================== //========================================================================== std::set Package::mReleasedDynamicallyLoadedPackages; //========================================================================== + } diff --git a/kernel/src/bbtkPackage.h b/kernel/src/bbtkPackage.h index a6bf8c8..f39dfc6 100644 --- a/kernel/src/bbtkPackage.h +++ b/kernel/src/bbtkPackage.h @@ -49,6 +49,8 @@ #include "bbtkBlackBox.h" #include "bbtkDynamicLibraryHandling.h" +#include "bbtkUtilities.h" +#include namespace bbtk { @@ -71,6 +73,7 @@ namespace bbtk const std::string& pkgname, const std::string& path); + void GetBoxesInside(NodeTreeC& tree, std::vector& list, int cont); /// NOTE : All the static methods below for package destruction /// are not member because they can cause the package death /// and thus close the dynamic library from which it has been loaded. diff --git a/kernel/src/bbtkUtilities.cxx b/kernel/src/bbtkUtilities.cxx index 8cd21b8..58d4b7d 100644 --- a/kernel/src/bbtkUtilities.cxx +++ b/kernel/src/bbtkUtilities.cxx @@ -767,6 +767,87 @@ namespace bbtk } //========================================================================= +//TAD Arbol CFT +//---------NodeTree--------------- + +NodeTreeC::NodeTreeC() +{ + +} + +NodeTreeC::NodeTreeC(std::string _data) +{ + data = _data; +} + +NodeTreeC::~NodeTreeC() +{ + +} + +void NodeTreeC::insertChild(std::string _data) +{ + NodeTreeC temp = NodeTreeC(_data); + childs.push_back(temp); +} + +void NodeTreeC::treeTour() +{ + std::cout <<"data "<< data << std::endl; + std::cout <<"size "<< childs.size() << std::endl; + for(int i = 0 ; i < childs.size(); i++) + { + childs[i].treeTour(); + } +} + +void NodeTreeC::setData(std::string _data) +{ + data = _data; +} + + +//---------Tree------------ +/* +TreeC::TreeC() +{ + +} + +TreeC::TreeC(std::string _data) +{ + root = NodeTreeC(_data); +} + +TreeC::~TreeC() +{ + +} + +void TreeC::insertRoot(std::string _data) +{ + NodeTreeC temp = NodeTreeC(_data); + root = temp; +} + +void TreeC::treeTour() +{ + root.treeTour(); +} + +void TreeC::insertData(std::string _data) +{ + +} + +TreeC* TreeC::getSubTree() +{ + TreeC temp; + temp.root = root.childs[0]; + return ; +} +*/ + } diff --git a/kernel/src/bbtkUtilities.h b/kernel/src/bbtkUtilities.h index 5a68f5f..e860fea 100644 --- a/kernel/src/bbtkUtilities.h +++ b/kernel/src/bbtkUtilities.h @@ -201,7 +201,34 @@ namespace bbtk }; - +class NodeTreeC +{ +public: + std::string data; + std::vector childs; + + NodeTreeC(); + NodeTreeC(std::string _data); + ~NodeTreeC(); + void insertChild(std::string _data); + void treeTour(); + void setData(std::string _data); +}; +/* +class TreeC +{ +public: + NodeTreeC root; + + TreeC(); + TreeC(std::string _data); + ~TreeC(); + void insertRoot(std::string _data); + void treeTour(); + void insertData(std::string _data); + TreeC getSubTree(); +}; + */ } // namespace bbtk -- 2.47.1