X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkComplexBlackBoxDescriptor.cxx;h=0e1114d52383c1480eb50ca410ba084ff1aa0746;hb=5d503ab0e50fbae3cd2ebd26e6c815557abbe42e;hp=4d6b6e88533c1b74a84e978766b12cf5d6c40fe4;hpb=a26195c366a89795288009cf7e20f11afa494970;p=bbtk.git diff --git a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx index 4d6b6e8..0e1114d 100644 --- a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx +++ b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkComplexBlackBoxDescriptor.cxx,v $ Language: C++ - Date: $Date: 2008/01/22 15:02:00 $ - Version: $Revision: 1.1 $ + Date: $Date: 2008/05/14 10:26:29 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -28,17 +28,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("Core",5, - "ComplexBlackBoxDescriptor::CreateInstance(\"" + bbtkDebugMessageInc("Kernel",5, + "ComplexBlackBoxDescriptor::NewBlackBox(\"" <bbClone(name); - bbtkDebugDecTab("Core",5); + bbtkDebugDecTab("Kernel",5); } //======================================================================= - + /* + //======================================================================= + /// Release + void ComplexBlackBoxDescriptor::Release(bool release_package) + { + } + //======================================================================= + */ //======================================================================= /// Adds a black box to the complex box @@ -81,11 +107,16 @@ namespace bbtk const std::string& name ) { - bbtkDebugMessageInc("Core",5, + bbtkDebugMessageInc("Kernel",5, "ComplexBlackBoxDescriptor::Add(\"" <bbUnsafeGetBlackBox( name ) ) @@ -93,22 +124,32 @@ namespace bbtk bbtkError("a black box \""<bbAddBlackBox ( /*mFactory->Create*/ NewBlackBox(type,name) ); + mPrototype->bbAddBlackBox ( GetFactory()->NewBlackBox(type,name) ); - bbtkDebugDecTab("Core",5); + 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("Core",5, + bbtkDebugMessageInc("Kernel",5, "ComplexBlackBoxDescriptor::AddToExecutionList(\"" <bbUnsafeGetBlackBox( box ); + BlackBox::Pointer b = mPrototype->bbUnsafeGetBlackBox( box ); if ( !b ) { bbtkError("the black box \""<bbAddToExecutionList ( box ); - bbtkDebugDecTab("Core",5); + bbtkDebugDecTab("Kernel",5); } @@ -128,29 +169,37 @@ namespace bbtk const std::string& input ) { - bbtkDebugMessageInc("Core",5, + bbtkDebugMessageInc("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("Core",5); + bbtkDebugDecTab("Kernel",5); } //======================================================================= @@ -162,14 +211,14 @@ namespace bbtk const std::string& input, const std::string& help) { - bbtkDebugMessageInc("Core",5, + bbtkDebugMessageInc("Kernel",5, "ComplexBlackBoxDescriptor::DefineInput(\"" <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("Core",5); + + bbtkDebugDecTab("Kernel",5); } //======================================================================= @@ -199,14 +253,14 @@ namespace bbtk const std::string& output, const std::string& help) { - bbtkDebugMessageInc("Core",5, + bbtkDebugMessageInc("Kernel",5, "ComplexBlackBoxDescriptor::DefineOutput(\"" <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("Core",5); + bbtkDebugDecTab("Kernel",5); } //======================================================================= @@ -256,7 +314,7 @@ namespace bbtk int detail, int level, const std::string& output_dir, bool relative_link) { - bbtkDebugMessageInc("Core",9, + bbtkDebugMessageInc("Kernel",9, "ComplexBlackBoxDescriptor::InsertHtmlHelp() [" < categories; + // Split the category string + std::string delimiters = ";,"; + Utilities::SplitString(GetCategory(), + delimiters,categories); + + (s) << "

\n"; (s) << "\n"; + << descr << "\n"; + (s) << "\n"; - + << author << "\n"; + + (s) << "\n"; std::string inc = GetScriptFileName(); if (inc.size()>0) { - (s) << "\n"; + s << "\n"; } const ComplexBlackBox::BlackBoxMapType& B = mPrototype->bbGetBlackBoxMap(); if (B.size()) - { - (s) << "\n"; + (s) << "\n"; - } + } - (s) << "
Description : " - << descr << "
Author(s) : " - << author << "
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]"; + s << "
Dependencies : "; - - - - std::set pdeps; - ComplexBlackBox::BlackBoxMapType::const_iterator b; - for ( b = B.begin(); b != B.end(); ++b ) - { - BlackBoxDescriptor* d = b->second->bbGetDescriptor(); - if (pdeps.find(d) != pdeps.end()) continue; - pdeps.insert(d); - - Package* p = d->GetPackage(); + { + (s) << "
Uses : "; + + 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 name = b->second->bbGetTypeName(); + std::string name = b->second->bbGetTypeName(); - std::string url; - if (relative_link) - url = p->GetDocRelativeURL(); - else - url = p->GetDocURL(); + std::string url; + if (relative_link) + url = p->GetDocRelativeURL(); + else + url = p->GetDocURL(); - s << "" - << p->GetName()<<"::"<\n"; - } + s << "" + << p->GetName()<<"::"<\n"; + } - (s) << "
\n"; + (s) << "\n"; //------------- @@ -395,7 +470,6 @@ namespace bbtk std::string descr(o->second->GetDescription()); //Utilities::html_format(descr); - (s) << "

 "<"
 	  << "
 "<"
 	  << ""<\n";
@@ -406,7 +480,7 @@ namespace bbtk
     //------------
     // End
 
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
    }
   //=========================================================================
  
@@ -417,8 +491,9 @@ namespace bbtk
     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->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) 
-      {
-	for ( o = mOutput.begin();  o != mOutput.end(); ++o ) 
-	  {
-	    if (o->second->GetName().size()>namelmax) 
-	      namelmax = o->second->GetName().size();
+    {
+	   for ( o = mOutput.begin();  o != mOutput.end(); ++o ) 
+	   {
+	     if (o->second->GetName().size()>namelmax) 
+	       namelmax = o->second->GetName().size();
 	    if (o->second->GetTypeName().size()>typelmax) 
-	      typelmax = o->second->GetTypeName().size();
-	  }
-      }
+	       typelmax = o->second->GetTypeName().size();
+	   if (o->second->GetNature().size()>natlmax) 
+	     natlmax = o->second->GetNature().size();
+	   }
+    }
     //
 
     for ( i = mInput.begin();  i != mInput.end(); ++i ) 
-      {
-	std::string name(i->second->GetName());
-	name += "'";
-	name.append(1+namelmax-name.size(),' ');
-	std::string type(i->second->GetTypeName());
-	type += ">";
-	type.append(1+typelmax-type.size(),' ');
-	bbtkMessage("Help",1,
-		    "    '"<second->GetDescription()<second->GetName());
+	   name += "'";
+	   name.append(1+namelmax-name.size(),' ');
+	   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->GetName());
-	    name += "'";
-	    name.append(1+namelmax-name.size(),' ');
-	    std::string type(o->second->GetTypeName());
-	    type += ">";
-	    type.append(1+typelmax-type.size(),' ');
-	    bbtkMessage("Help",1,
-			"    '"<second->GetDescription()<second->GetName());
+	     name += "'";
+	     name.append(1+namelmax-name.size(),' ');
+	     std::string type(o->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()<bbGetBlackBoxMap();
+    {
+	   const ComplexBlackBox::BlackBoxMapType& B = mPrototype->bbGetBlackBoxMap();
 	
-	if (B.size()) 
-	  bbtkMessage("Help",1," * Boxes : "<second->bbGetName()<<
-			"' <"
-			<< b->second->bbGetDescriptor()->GetPackage()->GetName() 
-			<<"::"
-			<second->bbGetTypeName()<<">"<second->bbGetName()<<
+			 "' <"
+			 << b->second->bbGetDescriptor()->GetPackage()->GetName() 
+			 <<"::"
+			 <second->bbGetTypeName()<<">"<GetObjectRecursiveSize();
+    return s;
+  }
+  //==========================================================================
 
 }