]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkComplexBlackBoxDescriptor.cxx
Forgot this one
[bbtk.git] / kernel / src / bbtkComplexBlackBoxDescriptor.cxx
index 0e1114d52383c1480eb50ca410ba084ff1aa0746..3037cae072d36a075e40e19a3a9786540c36c2c4 100644 (file)
@@ -1,21 +1,34 @@
-/*=========================================================================
-                                                                                
+/*=========================================================================                                                                               
   Program:   bbtk
   Module:    $RCSfile: bbtkComplexBlackBoxDescriptor.cxx,v $
   Language:  C++
-  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
-  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/12/08 14:10:36 $
+  Version:   $Revision: 1.21 $
 =========================================================================*/
 
+/* ---------------------------------------------------------------------
+
+* 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.
 #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
 {
    //=======================================================================
@@ -45,13 +63,13 @@ namespace bbtk
   /// Default ctor
   ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(const std::string& name)
   {
-    bbtkDebugMessage("object",2,"==> ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
+    bbtkDDebugMessage("object",2,"==> ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
     SetTypeName(name);
     AddToCategory("complex box");
     mPrototype = ComplexBlackBox::New(name+std::string("Prototype"),
                                      MakePointer(this,true));
     mPrototype->SetAsPrototype();
-    bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
+    bbtkDDebugMessage("object",2,"<== ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
   }
   //=======================================================================
 
@@ -61,10 +79,9 @@ namespace bbtk
   /// Default dtor
   ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor()
   {
-    bbtkDebugMessage("object",2,"==> ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
-    //    mPrototype->Delete();
+    bbtkDDebugMessage("object",2,"==> ~ComplexBlackBoxDescriptor()"<<std::endl);
     mPrototype.reset();
-    bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
+    bbtkDDebugMessage("object",2,"<== ~ComplexBlackBoxDescriptor()"<<std::endl);
   }
   //=======================================================================
 
@@ -81,14 +98,14 @@ namespace bbtk
   BlackBox::Pointer 
   ComplexBlackBoxDescriptor::NewBlackBox(const std::string& name)
   {
-    bbtkDebugMessageInc("Kernel",5,
-                       "ComplexBlackBoxDescriptor::NewBlackBox(\""
-                       <<name<<"\") ["
-                       <<GetTypeName()<<"]"<<std::endl);
+    bbtkDDebugMessage("kernel",5,
+                     "ComplexBlackBoxDescriptor::NewBlackBox(\""
+                     <<name<<"\")"
+                     <<std::endl);
     
     return mPrototype->bbClone(name);
 
-    bbtkDebugDecTab("Kernel",5);
+
   }
   //=======================================================================
 
@@ -107,10 +124,10 @@ namespace bbtk
                                        const std::string& name
                                        )
   {
-    bbtkDebugMessageInc("Kernel",5,
+    bbtkDDebugMessage("kernel",5,
                        "ComplexBlackBoxDescriptor::Add(\""
-                       <<type<<"\",\""<<name<<"\") ["
-                       <<GetTypeName()<<"]"<<std::endl);
+                       <<type<<"\",\""<<name<<"\")"
+                       <<std::endl);
     
     // 
     if (!GetFactory()) 
@@ -126,7 +143,7 @@ namespace bbtk
     // ok : create new one
     mPrototype->bbAddBlackBox ( GetFactory()->NewBlackBox(type,name) );
 
-    bbtkDebugDecTab("Kernel",5);
+
   }
   //=======================================================================
   
@@ -144,10 +161,10 @@ namespace bbtk
   /// 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::Pointer b = mPrototype->bbUnsafeGetBlackBox( box ); 
     if ( !b ) 
@@ -157,7 +174,7 @@ namespace bbtk
     // ok 
     mPrototype->bbAddToExecutionList ( box  );
 
-    bbtkDebugDecTab("Kernel",5);
+
     }
 
 
@@ -169,12 +186,12 @@ namespace bbtk
                                            const std::string& input
                                            )
   {
-    bbtkDebugMessageInc("Kernel",5,
+    bbtkDDebugMessage("kernel",5,
                        "ComplexBlackBoxDescriptor::Connect(\""
                        <<from<<"\",\""<<output<<"\",\""
                        <<to<<"\",\""<<input
-                       <<"\") ["
-                       <<GetTypeName()<<"]"<<std::endl);
+                       <<"\")"
+                       <<std::endl);
   // 
     if (!GetFactory()) 
       { 
@@ -199,7 +216,7 @@ namespace bbtk
 
     mPrototype->bbAddConnection(c);
 
-    bbtkDebugDecTab("Kernel",5);
+
   }
   //=======================================================================
 
@@ -211,12 +228,12 @@ namespace bbtk
                                                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::Pointer bb = mPrototype->bbGetBlackBox( box );
     if ( !bb ) 
@@ -242,7 +259,7 @@ namespace bbtk
                           d->GetTypeInfo()));
     
     
-    bbtkDebugDecTab("Kernel",5);
+
   }
   //=======================================================================
 
@@ -253,12 +270,12 @@ namespace bbtk
                                                 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::Pointer bb = mPrototype->bbGetBlackBox( box );
     if ( !bb ) 
@@ -284,7 +301,7 @@ namespace bbtk
                            d->GetTypeInfo()));
     
     
-    bbtkDebugDecTab("Kernel",5);
+
   }
   //=======================================================================
 
@@ -314,9 +331,9 @@ namespace bbtk
                                                   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 
@@ -366,7 +383,9 @@ namespace bbtk
     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 << "&nbsp;&nbsp;<a href=\"../../../bbs/"<<inc<<"\">[source]</a>";
+       // s << inc << "&nbsp;&nbsp;<a href=\"../../../bbs/"<<inc<<"\">[source]</a>";
+       // LG TODO : USE PACKAGE BBS PATH
+       s << inc << "&nbsp;&nbsp;<a href=\""<<inc<<"\">[source]</a>";
        s << "</TD></TR>\n";
        
       }
@@ -395,14 +414,14 @@ namespace bbtk
                 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";
 
@@ -437,9 +456,15 @@ namespace bbtk
        std::string descr(in->second->GetDescription());
        //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";
@@ -470,17 +495,22 @@ namespace bbtk
        std::string descr(o->second->GetDescription());
        //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);
+
    }
   //=========================================================================
  
@@ -488,16 +518,16 @@ 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()<<"::"
                          <<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;
@@ -537,7 +567,7 @@ namespace bbtk
           std::string nature(i->second->GetNature());
           nature += "]";
           nature.append(1+natlmax-nature.size(),' ');
-          bbtkMessage("Help",1,
+          bbtkMessage("help",1,
                       "    '"<<name
                       <<" <"<<type
                       <<" ["<<nature
@@ -546,9 +576,9 @@ namespace bbtk
     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());
@@ -560,7 +590,7 @@ namespace bbtk
             std::string nature(o->second->GetNature());
             nature += "]";
             nature.append(1+natlmax-nature.size(),' ');
-            bbtkMessage("Help",1,
+            bbtkMessage("help",1,
                       "    '"<<name
                         <<" <"<<type
                         <<" ["<<nature
@@ -572,14 +602,14 @@ namespace bbtk
           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() 
                         <<"::"