X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkComplexBlackBoxDescriptor.cxx;h=c25819f5003eb9bb497c8f4aa6e7530defb99cbb;hb=4634377e45465b15485afc9da74a5bf13b32d17b;hp=e421055a8e2c5c65f136566801765cacbe528f6c;hpb=6c5d7746e8e4cb0b5d6e164b917008a7137910fb;p=bbtk.git diff --git a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx index e421055..c25819f 100644 --- a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx +++ b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx @@ -1,21 +1,41 @@ +/* + # --------------------------------------------------------------------- + # + # 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/04/08 06:59:30 $ - Version: $Revision: 1.13 $ - - 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. @@ -26,21 +46,38 @@ #include "bbtkMessageManager.h" #include "bbtkUtilities.h" +#define bbtkDMessage(key,level,mess) \ + bbtkMessage(key,level,"["< ComplexBlackBoxDescriptor::New(\""< ComplexBlackBoxDescriptor(\""<SetAsPrototype(); + bbtkDDebugMessage("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(\"" - <bbClone(name); - bbtkDebugDecTab("Kernel",5); + } //======================================================================= - + /* + //======================================================================= + /// Release + void ComplexBlackBoxDescriptor::Release(bool release_package) + { + } + //======================================================================= + */ //======================================================================= /// Adds a black box to the complex box @@ -83,13 +132,13 @@ namespace bbtk const std::string& name ) { - bbtkDebugMessageInc("Kernel",5, + bbtkDDebugMessage("kernel",5, "ComplexBlackBoxDescriptor::Add(\"" - <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(\"" - <bbUnsafeGetBlackBox( box ); + BlackBox::Pointer b = mPrototype->bbUnsafeGetBlackBox( box ); if ( !b ) { bbtkError("the black box \""<bbAddToExecutionList ( box ); - bbtkDebugDecTab("Kernel",5); + } @@ -135,36 +194,37 @@ namespace bbtk const std::string& input ) { - bbtkDebugMessageInc("Kernel",5, + bbtkDDebugMessage("kernel",5, "ComplexBlackBoxDescriptor::Connect(\"" <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); - bbtkDebugDecTab("Kernel",5); + } //======================================================================= @@ -176,14 +236,14 @@ namespace bbtk const std::string& input, const std::string& help) { - bbtkDebugMessageInc("Kernel",5, + bbtkDDebugMessage("kernel",5, "ComplexBlackBoxDescriptor::DefineInput(\"" <bbGetBlackBox( box ); + BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box ); if ( !bb ) { bbtkError("the black box \""<GetTypeInfo())); - bbtkDebugDecTab("Kernel",5); + } //======================================================================= @@ -218,14 +278,14 @@ namespace bbtk const std::string& output, const std::string& help) { - bbtkDebugMessageInc("Kernel",5, + bbtkDDebugMessage("kernel",5, "ComplexBlackBoxDescriptor::DefineOutput(\"" <bbGetBlackBox( box ); + BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box ); if ( !bb ) { bbtkError("the black box \""<GetTypeInfo())); - bbtkDebugDecTab("Kernel",5); + } //======================================================================= @@ -279,9 +339,9 @@ namespace bbtk int detail, int level, const std::string& output_dir, bool relative_link) { - bbtkDebugMessageInc("Kernel",9, - "ComplexBlackBoxDescriptor::InsertHtmlHelp() [" - <0) { s << " To use it : include "; - s << inc << "  [source]"; + // s << inc << "  [source]"; + // LG TODO : USE PACKAGE BBS PATH + s << inc << "  [source]"; s << "\n"; } @@ -342,32 +404,32 @@ namespace bbtk { (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(); - + std::string url; if (relative_link) url = p->GetDocRelativeURL(); else url = p->GetDocURL(); - + s << "" << p->GetName()<<"::"<\n"; - } + } // for (s) << "\n"; - } + } // If B.size (s) << "\n"; @@ -400,11 +462,17 @@ namespace bbtk Utilities::html_format(type); std::string descr(in->second->GetDescription()); - Utilities::html_format(descr); + //Utilities::html_format(descr); +/*EED 10/11/2009 (s) << "
 "<"
 	  << "
 "<"
 	  << ""<\n";
+*/
+
+	(s) << "
 "<"
+	  << "
 "<"
+	  << ""<\n";
 	
       }
     //	(s) << "\n";
@@ -433,19 +501,24 @@ namespace bbtk
 	Utilities::html_format(type);
 	
 	std::string descr(o->second->GetDescription());
-	Utilities::html_format(descr);
+	//Utilities::html_format(descr);
 	
+/*EED 10/11/2009
 	(s) << "
 "<"
 	  << "
 "<"
 	  << ""<\n";
-	
+*/	
+	(s) << "
 "<"
+	  << "
 "<"
+	  << ""<\n";
+
       }
     (s) << "\n";
 
     //------------
     // End
 
-    bbtkDebugDecTab("Kernel",9);
+
    }
   //=========================================================================
  
@@ -453,25 +526,28 @@ namespace bbtk
   //=======================================================================
   void ComplexBlackBoxDescriptor::GetHelp(bool full) const
   {
-    if (full) bbtkMessage("Help",1,"Complex Black Box <"<<
+    if (full) bbtkMessage("help",1,"Complex Black Box <"<<
 			  GetPackage()->GetName()<<"::"
 			  <"<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) 
@@ -482,6 +558,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();
 	   }
     }
     //
@@ -494,17 +572,21 @@ namespace bbtk
 	   std::string type(i->second->GetTypeName());
 	   type += ">";
 	   type.append(1+typelmax-type.size(),' ');
-	   bbtkMessage("Help",1,
-		    "    '"<second->GetDescription()<second->GetNature());
+	   nature += "]";
+	   nature.append(1+natlmax-nature.size(),' ');
+	   bbtkMessage("help",1,
+		       "    '"<second->GetDescription()<second->GetName());
@@ -513,9 +595,13 @@ namespace bbtk
 	     std::string type(o->second->GetTypeName());
 	     type += ">";
 	     type.append(1+typelmax-type.size(),' ');
-	     bbtkMessage("Help",1,
-			 "    '"<second->GetNature());
+	     nature += "]";
+	     nature.append(1+natlmax-nature.size(),' ');
+	     bbtkMessage("help",1,
+		       "    '"<second->GetDescription()<bbGetBlackBoxMap();
 	
 	   if (B.size()) 
-	     bbtkMessage("Help",1," * Boxes : "<second->bbGetName()<<
+	     bbtkMessage("help",1,"    '"<second->bbGetName()<<
 			 "' <"
 			 << b->second->bbGetDescriptor()->GetPackage()->GetName() 
 			 <<"::"
@@ -542,7 +628,88 @@ namespace bbtk
   }   
   //=======================================================================
 
+  //==========================================================================
+  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, 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
 
+	}
 
+//===================================================
 
+	 //==========================================================================
 }