X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkComplexBlackBoxDescriptor.cxx;h=de6d2b70922fe06ff02e89c24ae5c258c1950ff8;hb=98e18224b83c6955a804d79d4e7083626ea8afcd;hp=f6f6f4b14df01f43cf89dc6e3c07ef86fd990129;hpb=71376d8384d5d21b5c56d36ecc8cbf31315c039a;p=bbtk.git diff --git a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx index f6f6f4b..de6d2b7 100644 --- a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx +++ b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx @@ -1,21 +1,34 @@ -/*========================================================================= - +/*========================================================================= Program: bbtk Module: $RCSfile: bbtkComplexBlackBoxDescriptor.cxx,v $ Language: C++ - Date: $Date: 2008/02/05 13:23:46 $ - Version: $Revision: 1.4 $ - - 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: 2009/03/30 15:22:51 $ + Version: $Revision: 1.19 $ =========================================================================*/ +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* 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. +* ------------------------------------------------------------------------ */ + + /** * \file * \brief Class bbtk::ComplexBlackBoxDescriptor : describes a ComplexBlackBox (constituents, connections) and is able to create an instance of it. @@ -28,17 +41,30 @@ namespace bbtk { - + //======================================================================= + /// + ComplexBlackBoxDescriptor::Pointer + ComplexBlackBoxDescriptor::New(const std::string& name) + { + bbtkDebugMessage("object",1,"##> ComplexBlackBoxDescriptor::New(\""< ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<SetAsPrototype(); + bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""< ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<Delete(); + mPrototype.reset(); + bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<Check(recursive); + } + //========================================================================= //======================================================================= /// Creates an instance of 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(\"" + "ComplexBlackBoxDescriptor::NewBlackBox(\"" <bbUnsafeGetBlackBox( name ) ) @@ -93,13 +137,23 @@ namespace bbtk bbtkError("a black box \""<bbAddBlackBox ( /*mFactory->Create*/ 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) { @@ -108,7 +162,7 @@ namespace bbtk <bbUnsafeGetBlackBox( box ); + BlackBox::Pointer b = mPrototype->bbUnsafeGetBlackBox( box ); if ( !b ) { bbtkError("the black box \""<bbGetBlackBox( from ); + BlackBox::Pointer bbfrom = mPrototype->bbGetBlackBox( from ); if ( !bbfrom ) { bbtkError("the black box \""<bbGetBlackBox( to ); + BlackBox::Pointer bbto = mPrototype->bbGetBlackBox( to ); if ( !bbto ) { bbtkError("the black box \""<*/ NewConnection( bbfrom, output, bbto, input ); + Connection::Pointer c + = GetFactory()->NewConnection( bbfrom, output, bbto, input ); mPrototype->bbAddConnection(c); @@ -169,7 +231,7 @@ namespace bbtk <<"\") [" <bbGetBlackBox( box ); + BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box ); if ( !bb ) { bbtkError("the black box \""<bbGetInputType(input))); - + const BlackBoxInputDescriptor* d = + bb->bbGetDescriptor()->GetInputDescriptor(input); + AddInputDescriptor ( new ComplexBlackBoxInputDescriptor + ( typeid(ComplexBlackBoxDescriptor), + name, + help, + d->GetNature(), + box, + input, + d->GetTypeInfo())); + bbtkDebugDecTab("Kernel",5); } @@ -206,7 +273,7 @@ namespace bbtk <<"\") [" <bbGetBlackBox( box ); + BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box ); if ( !bb ) { bbtkError("the black box \""<bbGetDescriptor()->GetOutputDescriptor(output); AddOutputDescriptor ( new ComplexBlackBoxOutputDescriptor - ( name, + ( typeid(ComplexBlackBoxDescriptor), + name, help, + d->GetNature(), box, output, - bb->bbGetOutputType(output))); + d->GetTypeInfo())); bbtkDebugDecTab("Kernel",5); @@ -282,8 +353,12 @@ namespace bbtk std::string author = GetAuthor(); Utilities::html_format(author); - std::string category = GetCategory(); - Utilities::html_format(category); + std::vector categories; + // Split the category string + std::string delimiters = ";,"; + Utilities::SplitString(GetCategory(), + delimiters,categories); + (s) << "

\n"; (s) << "\n"; - (s) << "\n"; - + (s) << "\n"; std::string inc = GetScriptFileName(); if (inc.size()>0) { - (s) << "\n"; + s << "\n"; } @@ -307,18 +390,18 @@ namespace bbtk if (B.size()) { - (s) << "\n"; - } + } // If B.size (s) << "
Description : " @@ -292,14 +367,22 @@ namespace bbtk (s) << "
Author(s) : " << author << "
Category(s) : " - << category << "
Category(s) : "; + std::vector::iterator ci; + for (ci=categories.begin(); ci!=categories.end(); ++ci) + { + s << "" << *ci + << " \n"; + } + s << "
Include : " - << inc << "
To use it : include "; + // s << inc << "  [source]"; + // LG TODO : USE PACKAGE BBS PATH + s << inc << "  [source]"; + s << "
Dependencies : "; + (s) << "
Uses : "; - std::set pdeps; + std::set 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(); @@ -327,14 +410,14 @@ namespace bbtk url = p->GetDocRelativeURL(); else url = p->GetDocURL(); - + s << "" << p->GetName()<<"::"<\n"; - } + } // for (s) << "
\n"; @@ -433,12 +516,15 @@ namespace bbtk 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) @@ -449,6 +535,8 @@ namespace bbtk 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(); } } // @@ -461,10 +549,14 @@ namespace bbtk std::string type(i->second->GetTypeName()); type += ">"; type.append(1+typelmax-type.size(),' '); + std::string nature(i->second->GetNature()); + nature += "]"; + nature.append(1+natlmax-nature.size(),' '); bbtkMessage("Help",1, - " '"<second->GetDescription()<second->GetDescription()<second->GetTypeName()); type += ">"; type.append(1+typelmax-type.size(),' '); + std::string nature(o->second->GetNature()); + nature += "]"; + nature.append(1+natlmax-nature.size(),' '); bbtkMessage("Help",1, - " '"<second->GetDescription()<GetObjectRecursiveSize(); + return s; + } + //========================================================================== }