+/*
+ # ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ # pour la SantÈ)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ # This software is governed by the CeCILL-B license under French law and
+ # abiding by the rules of distribution of free software. You can use,
+ # modify and/ or redistribute the software under the terms of the CeCILL-B
+ # license as circulated by CEA, CNRS and INRIA at the following URL
+ # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ # or in the file LICENSE.txt.
+ #
+ # As a counterpart to the access to the source code and rights to copy,
+ # modify and redistribute granted by the license, users are provided only
+ # with a limited warranty and the software's author, the holder of the
+ # economic rights, and the successive licensors have only limited
+ # liability.
+ #
+ # The fact that you are presently reading this means that you have had
+ # knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
+
/*=========================================================================
-
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBoxDescriptor.cxx,v $
Language: C++
- Date: $Date: 2008/03/07 10:21:30 $
- Version: $Revision: 1.12 $
-
- Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
- l'Image). All rights reserved. See Doc/License.txt or
- http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notices for more information.
-
+ Date: $Date: 2012/11/16 08:49:01 $
+ Version: $Revision: 1.23 $
=========================================================================*/
+
+
+
/**
* \file
* \brief Class bbtk::ComplexBlackBoxDescriptor : describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it.
#include "bbtkMessageManager.h"
#include "bbtkUtilities.h"
+#define bbtkDMessage(key,level,mess) \
+ bbtkMessage(key,level,"["<<GetFullTypeName()<<"] "<<mess)
+#define bbtkDDebugMessage(key,level,mess) \
+ bbtkDebugMessage(key,level,"["<<GetFullTypeName()<<"] "<<mess)
+
namespace bbtk
{
-
+ //=======================================================================
+ ///
+ ComplexBlackBoxDescriptor::Pointer
+ ComplexBlackBoxDescriptor::New(const std::string& name)
+ {
+ bbtkDebugMessage("object",1,"##> ComplexBlackBoxDescriptor::New(\""<<name<<"\")"<<std::endl);
+ ComplexBlackBoxDescriptor::Pointer p =
+ MakePointer(new ComplexBlackBoxDescriptor(name));
+ bbtkDebugMessage("object",1,"<## ComplexBlackBoxDescriptor::New(\""<<name<<"\")"<<std::endl);
+ return p;
+ }
+ //=======================================================================
//=======================================================================
/// Default ctor
ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(const std::string& name)
- : BlackBoxDescriptor(),
- mFactory(0)
{
- bbtkDebugMessageInc("Kernel",9,"ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
+ bbtkDDebugMessage("object",2,"==> ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
+ SetTypeOfScript(TS_SCRIPT_COMPLEXBOX);
SetTypeName(name);
AddToCategory("complex box");
- mPrototype = new ComplexBlackBox(name+std::string("Prototype"),this);
- bbtkDebugDecTab("Kernel",9);
+ mPrototype = ComplexBlackBox::New(name+std::string("Prototype"),
+ MakePointer(this,true));
+ mPrototype->SetAsPrototype();
+ bbtkDDebugMessage("object",2,"<== ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
}
//=======================================================================
/// Default dtor
ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor()
{
- bbtkDebugMessageInc("Kernel",9,"ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
-
- delete mPrototype;
-
- bbtkDebugDecTab("Kernel",9);
+ bbtkDDebugMessage("object",2,"==> ~ComplexBlackBoxDescriptor()"<<std::endl);
+ mPrototype.reset();
+ bbtkDDebugMessage("object",2,"<== ~ComplexBlackBoxDescriptor()"<<std::endl);
}
//=======================================================================
+ //=========================================================================
+ /// Check
+ void ComplexBlackBoxDescriptor::Check(bool recursive) const
+ {
+ mPrototype->Check(recursive);
+ }
+ //=========================================================================
//=======================================================================
/// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
- BlackBox* ComplexBlackBoxDescriptor::CreateInstance(const std::string& name)
+ BlackBox::Pointer
+ ComplexBlackBoxDescriptor::NewBlackBox(const std::string& name)
{
- //bbtkError("ComplexBlackBoxDescriptor::CreateInstance not implemented");
- bbtkDebugMessageInc("Kernel",5,
- "ComplexBlackBoxDescriptor::CreateInstance(\""
- <<name<<"\") ["
- <<GetTypeName()<<"]"<<std::endl);
+ bbtkDDebugMessage("kernel",5,
+ "ComplexBlackBoxDescriptor::NewBlackBox(\""
+ <<name<<"\")"
+ <<std::endl);
return mPrototype->bbClone(name);
- bbtkDebugDecTab("Kernel",5);
+
}
//=======================================================================
-
+ /*
+ //=======================================================================
+ /// Release
+ void ComplexBlackBoxDescriptor::Release(bool release_package)
+ {
+ }
+ //=======================================================================
+ */
//=======================================================================
/// Adds a black box to the complex box
const std::string& name
)
{
- bbtkDebugMessageInc("Kernel",5,
+ bbtkDDebugMessage("kernel",5,
"ComplexBlackBoxDescriptor::Add(\""
- <<type<<"\",\""<<name<<"\") ["
- <<GetTypeName()<<"]"<<std::endl);
+ <<type<<"\",\""<<name<<"\")"
+ <<std::endl);
//
- if (mFactory == 0)
+ if (!GetFactory())
{
bbtkError("ComplexBlackBoxDescriptor::Add : no factory set");
}
bbtkError("a black box \""<<name<<"\" already exists");
}
// ok : create new one
- mPrototype->bbAddBlackBox ( mFactory->NewBlackBox(type,name) );
+ mPrototype->bbAddBlackBox ( GetFactory()->NewBlackBox(type,name) );
+
- bbtkDebugDecTab("Kernel",5);
+ }
+ //=======================================================================
+
+ //=======================================================================
+ /// Removes a black box from the complex box
+ void ComplexBlackBoxDescriptor::Remove( const std::string& name,
+ bool remove_connections)
+ {
+ mPrototype->bbRemoveBlackBox(name,remove_connections);
}
//=======================================================================
- //=======================================================================
+
+ //=======================================================================
/// Adds a black box to the execution list
void ComplexBlackBoxDescriptor::AddToExecutionList ( const std::string& box)
{
- bbtkDebugMessageInc("Kernel",5,
- "ComplexBlackBoxDescriptor::AddToExecutionList(\""
- <<box<<"\" ["
- <<GetTypeName()<<"]"<<std::endl);
+ bbtkDDebugMessage("kernel",5,
+ "ComplexBlackBoxDescriptor::AddToExecutionList(\""
+ <<box<<"\""
+ <<std::endl);
// Verify that the box exists
- BlackBox* b = mPrototype->bbUnsafeGetBlackBox( box );
+ BlackBox::Pointer b = mPrototype->bbUnsafeGetBlackBox( box );
if ( !b )
{
bbtkError("the black box \""<<box<<"\" does not exist");
// ok
mPrototype->bbAddToExecutionList ( box );
- bbtkDebugDecTab("Kernel",5);
+
}
const std::string& input
)
{
- bbtkDebugMessageInc("Kernel",5,
+ bbtkDDebugMessage("kernel",5,
"ComplexBlackBoxDescriptor::Connect(\""
<<from<<"\",\""<<output<<"\",\""
<<to<<"\",\""<<input
- <<"\") ["
- <<GetTypeName()<<"]"<<std::endl);
+ <<"\")"
+ <<std::endl);
//
- if (mFactory == 0)
+ if (!GetFactory())
{
bbtkError("ComplexBlackBoxDescriptor::Connect : no factory set");
}
// Verify that a box with the same name does not exist already
- BlackBox* bbfrom = mPrototype->bbGetBlackBox( from );
+ BlackBox::Pointer bbfrom = mPrototype->bbGetBlackBox( from );
if ( !bbfrom )
{
bbtkError("the black box \""<<from<<"\" does not exist");
}
- BlackBox* bbto = mPrototype->bbGetBlackBox( to );
+ BlackBox::Pointer bbto = mPrototype->bbGetBlackBox( to );
if ( !bbto )
{
bbtkError("the black box \""<<to<<"\" does not exist");
}
- Connection* c = mFactory->NewConnection( bbfrom, output, bbto, input );
+ Connection::Pointer c
+ = GetFactory()->NewConnection( bbfrom, output, bbto, input );
mPrototype->bbAddConnection(c);
- bbtkDebugDecTab("Kernel",5);
+
}
//=======================================================================
const std::string& input,
const std::string& help)
{
- bbtkDebugMessageInc("Kernel",5,
+ bbtkDDebugMessage("kernel",5,
"ComplexBlackBoxDescriptor::DefineInput(\""
<<name<<"\",\""<<box<<"\",\""
<<input<<"\",\""<<help
- <<"\") ["
- <<GetTypeName()<<"]"<<std::endl);
+ <<"\")"
+ <<std::endl);
- BlackBox* bb = mPrototype->bbGetBlackBox( box );
+ BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box );
if ( !bb )
{
bbtkError("the black box \""<<box<<"\" does not exist");
<<input<<"\"");
}
+ const BlackBoxInputDescriptor* d =
+ bb->bbGetDescriptor()->GetInputDescriptor(input);
AddInputDescriptor ( new ComplexBlackBoxInputDescriptor
( typeid(ComplexBlackBoxDescriptor),
name,
help,
+ d->GetNature(),
box,
input,
- bb->bbGetInputType(input)));
+ d->GetTypeInfo()));
- bbtkDebugDecTab("Kernel",5);
+
}
//=======================================================================
const std::string& output,
const std::string& help)
{
- bbtkDebugMessageInc("Kernel",5,
+ bbtkDDebugMessage("kernel",5,
"ComplexBlackBoxDescriptor::DefineOutput(\""
<<name<<"\",\""<<box<<"\",\""
<<output<<"\",\""<<help
- <<"\") ["
- <<GetTypeName()<<"]"<<std::endl);
+ <<"\")"
+ <<std::endl);
- BlackBox* bb = mPrototype->bbGetBlackBox( box );
+ BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box );
if ( !bb )
{
bbtkError("the black box \""<<box<<"\" does not exist");
<<output<<"\"");
}
+ const BlackBoxOutputDescriptor* d =
+ bb->bbGetDescriptor()->GetOutputDescriptor(output);
AddOutputDescriptor ( new ComplexBlackBoxOutputDescriptor
( typeid(ComplexBlackBoxDescriptor),
name,
help,
+ d->GetNature(),
box,
output,
- bb->bbGetOutputType(output)));
+ d->GetTypeInfo()));
- bbtkDebugDecTab("Kernel",5);
+
}
//=======================================================================
int detail, int level,
const std::string& output_dir, bool relative_link)
{
- bbtkDebugMessageInc("Kernel",9,
- "ComplexBlackBoxDescriptor::InsertHtmlHelp() ["
- <<GetTypeName()<<"]"<<std::endl);
+ bbtkDDebugMessage("kernel",9,
+ "ComplexBlackBoxDescriptor::InsertHtmlHelp()"
+ <<std::endl);
//-------------
// General info
std::string descr = GetDescription();
- Utilities::html_format(descr);
+ //Utilities::html_format(descr);
std::string author = GetAuthor();
Utilities::html_format(author);
if (inc.size()>0)
{
s << "<TR><TD style='vertical-align: top;'><b> To use it </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> include ";
- s << inc << " <a href=\"../../../bbs/"<<inc<<"\">[source]</a>";
+ // s << inc << " <a href=\"../../../bbs/"<<inc<<"\">[source]</a>";
+ // LG TODO : USE PACKAGE BBS PATH
+ s << inc << " <a href=\""<<inc<<"\">[source]</a>";
s << "</TD></TR>\n";
}
{
(s) << "<TR><TD style='vertical-align: top;'><b> Uses </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> ";
- std::set<BlackBoxDescriptor*> pdeps;
+ std::set<BlackBoxDescriptor::Pointer> pdeps;
ComplexBlackBox::BlackBoxMapType::const_iterator b;
for ( b = B.begin(); b != B.end(); ++b )
{
- BlackBoxDescriptor* d = b->second->bbGetDescriptor();
+ BlackBoxDescriptor::Pointer d = b->second->bbGetDescriptor();
if (pdeps.find(d) != pdeps.end())
continue;
pdeps.insert(d);
- Package* p = d->GetPackage();
+ Package::Pointer p = d->GetPackage();
std::string name = b->second->bbGetTypeName();
-
+
std::string url;
if (relative_link)
url = p->GetDocRelativeURL();
else
url = p->GetDocURL();
-
+
s << "<a href=\"" <<url<<"#"<<name<<"\">"
<< p->GetName()<<"::"<<name<<"</a>\n";
- }
+ } // for
(s) << "</TD></TR>\n";
- }
+ } // If B.size
(s) << "</TABLE>\n";
Utilities::html_format(type);
std::string descr(in->second->GetDescription());
- Utilities::html_format(descr);
+ //Utilities::html_format(descr);
+/*EED 10/11/2009
(s) << "<TR><TD style='vertical-align: top;'><B><PRE> "<<name<<" </PRE></B></TD>"
<< "<TD style='vertical-align: top;'><I><PRE> "<<type<<" </PRE></I></TD>"
<< "<TD style='vertical-align: top;'>"<<descr<<"</TD></TR>\n";
+*/
+
+ (s) << "<TR><TD style='vertical-align: top;'><B><PRE> "<<name<<" </PRE></B></TD>"
+ << "<TD style='vertical-align: top;'><I><PRE> "<<descr<<" </PRE></I></TD>"
+ << "<TD style='vertical-align: top;'>"<<type<<"</TD></TR>\n";
}
// (s) << "</TABLE>\n";
Utilities::html_format(type);
std::string descr(o->second->GetDescription());
- Utilities::html_format(descr);
+ //Utilities::html_format(descr);
+/*EED 10/11/2009
(s) << "<TR><TD style='vertical-align: top;'><B><PRE> "<<name<<" </PRE></B></TD>"
<< "<TD style='vertical-align: top;'><I><PRE> "<<type<<" </PRE></I></TD>"
<< "<TD style='vertical-align: top;'>"<<descr<<"</TD></TR>\n";
-
+*/
+ (s) << "<TR><TD style='vertical-align: top;'><B><PRE> "<<name<<" </PRE></B></TD>"
+ << "<TD style='vertical-align: top;'><I><PRE> "<<descr<<" </PRE></I></TD>"
+ << "<TD style='vertical-align: top;'>"<<type<<"</TD></TR>\n";
+
}
(s) << "</TABLE>\n";
//------------
// End
- bbtkDebugDecTab("Kernel",9);
+
}
//=========================================================================
//=======================================================================
void ComplexBlackBoxDescriptor::GetHelp(bool full) const
{
- if (full) bbtkMessage("Help",1,"Complex Black Box <"<<
+ if (full) bbtkMessage("help",1,"Complex Black Box <"<<
GetPackage()->GetName()<<"::"
<<GetTypeName()<<">"<<std::endl);
- bbtkMessage("Help",1," " << GetDescription() <<std::endl);
- bbtkMessage("Help",1," By : " << GetAuthor() <<std::endl);
- bbtkMessage("Help",1," Category(s) : " << GetCategory() <<std::endl);
+ bbtkMessage("help",1," " << GetDescription() <<std::endl);
+ bbtkMessage("help",1," By : " << GetAuthor() <<std::endl);
+ bbtkMessage("help",1," Category(s) : " << GetCategory() <<std::endl);
if (mInput.size())
- bbtkMessage("Help",1," * Inputs : "<<std::endl);
+ bbtkMessage("help",1," * Inputs : "<<std::endl);
else
- bbtkMessage("Help",1," * No inputs"<<std::endl);
+ bbtkMessage("help",1," * No inputs"<<std::endl);
InputDescriptorMapType::const_iterator i;
unsigned int namelmax = 0;
unsigned int typelmax = 0;
+ unsigned int natlmax = 0;
for ( i = mInput.begin(); i != mInput.end(); ++i )
{
if (i->second->GetName().size()>namelmax)
namelmax = i->second->GetName().size();
if (i->second->GetTypeName().size()>typelmax)
typelmax = i->second->GetTypeName().size();
+ if (i->second->GetNature().size()>natlmax)
+ natlmax = i->second->GetNature().size();
}
OutputDescriptorMapType::const_iterator o;
if (full)
namelmax = o->second->GetName().size();
if (o->second->GetTypeName().size()>typelmax)
typelmax = o->second->GetTypeName().size();
+ if (o->second->GetNature().size()>natlmax)
+ natlmax = o->second->GetNature().size();
}
}
//
std::string type(i->second->GetTypeName());
type += ">";
type.append(1+typelmax-type.size(),' ');
- bbtkMessage("Help",1,
- " '"<<name
- <<" <"<<type
- <<" : "<<i->second->GetDescription()<<std::endl);
+ std::string nature(i->second->GetNature());
+ nature += "]";
+ nature.append(1+natlmax-nature.size(),' ');
+ bbtkMessage("help",1,
+ " '"<<name
+ <<" <"<<type
+ <<" ["<<nature
+ <<" : "<<i->second->GetDescription()<<std::endl);
}
if (full)
{
if (mOutput.size())
- bbtkMessage("Help",1," * Outputs : "<<std::endl);
+ bbtkMessage("help",1," * Outputs : "<<std::endl);
else
- bbtkMessage("Help",1," * No outputs"<<std::endl);
+ bbtkMessage("help",1," * No outputs"<<std::endl);
for ( o = mOutput.begin(); o != mOutput.end(); ++o )
{
std::string name(o->second->GetName());
std::string type(o->second->GetTypeName());
type += ">";
type.append(1+typelmax-type.size(),' ');
- bbtkMessage("Help",1,
- " '"<<name
+ std::string nature(o->second->GetNature());
+ nature += "]";
+ nature.append(1+natlmax-nature.size(),' ');
+ bbtkMessage("help",1,
+ " '"<<name
<<" <"<<type
+ <<" ["<<nature
<<" : "<<o->second->GetDescription()<<std::endl);
}
}
const ComplexBlackBox::BlackBoxMapType& B = mPrototype->bbGetBlackBoxMap();
if (B.size())
- bbtkMessage("Help",1," * Boxes : "<<std::endl);
+ bbtkMessage("help",1," * Boxes : "<<std::endl);
else
- bbtkMessage("Help",1," * No boxes"<<std::endl);
+ bbtkMessage("help",1," * No boxes"<<std::endl);
ComplexBlackBox::BlackBoxMapType::const_iterator b;
for ( b = B.begin(); b != B.end(); ++b )
{
- bbtkMessage("Help",1," '"<<b->second->bbGetName()<<
+ bbtkMessage("help",1," '"<<b->second->bbGetName()<<
"' <"
<< b->second->bbGetDescriptor()->GetPackage()->GetName()
<<"::"
}
//=======================================================================
+ //==========================================================================
+ std::string ComplexBlackBoxDescriptor::GetObjectName() const
+ {
+ return std::string("ComplexBlackBoxDescriptor '")+GetFullTypeName()
+ +std::string("'");
+ }
+ //==========================================================================
+ //=======================================================================
+ std::string ComplexBlackBoxDescriptor::GetObjectInfo() const
+ {
+ std::string i;
+ return i;
+ }
+ //=======================================================================
+ //==========================================================================
+size_t ComplexBlackBoxDescriptor::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += ComplexBlackBoxDescriptor::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t ComplexBlackBoxDescriptor::GetObjectInternalSize() const
+{
+ size_t s = sizeof(ComplexBlackBoxDescriptor);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t ComplexBlackBoxDescriptor::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += ComplexBlackBoxDescriptor::GetObjectInternalSize();
+ s += mPrototype->GetObjectRecursiveSize();
+ return s;
+ }
+ //==========================================================================
+void ComplexBlackBoxDescriptor::GetBoxesInside (NodeTreeC& tree, int cont)
+ {
+ std::cout<<"getBoxesInside recursivo "<<std::endl;
+ cont++;
+ std::string name = GetTypeName();
+ std::cout<<"despues de getTypeName : "<<name<<std::endl;
+ 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();
-
+ std::cout<<"----B size "<< B.size() << std::endl;
+ std::cout<<"----antes if "<<std::endl;
+ if (B.size())
+ {
+ std::set<BlackBoxDescriptor::Pointer> pdeps;
+ ComplexBlackBox::BlackBoxMapType::const_iterator b;
+ std::cout<<"----antes for "<<std::endl;
+ for ( b = B.begin(); b != B.end(); ++b )
+ {
+ BlackBoxDescriptor::Pointer d = b->second->bbGetDescriptor();
+ //std::cout<<"nombre objeto d "<< d->GetObjectName() <<std::endl;
+
+ //if (pdeps.find(d) != pdeps.end())
+ // continue;
+ //pdeps.insert(d);
+ std::cout<<"----1~ "<<std::endl;
+ Package::Pointer p = d->GetPackage();
+ std::string nameBox = b->second->bbGetTypeName();
+ std::string packageBox = p->GetName();
+ tree.insertChild(nameBox);
+ std::cout<<"----2~ "<<std::endl;
+ //list.push_back(nameBox);
+ //list.push_back(packageBox);
+ std::cout<<"-----cont "<<cont<<std::endl;
+ //tree.treeTour(cont);
+ d->GetBoxesInside (tree.childs[k], cont);
+ std::cout<<"----3~ "<<std::endl;
+ //std::cout<<"--despues de la recursion "<<k<<std::endl;
+ k++;
+ } // for
+ std::cout<<"----despues for "<<std::endl;
+ } // If B.size
+ std::cout<<"----despues if "<<std::endl;
+ std::cout<<"end getBoxesInside recursivo"<<std::endl;
+ }
+
+//===================================================
+
+ //==========================================================================
}