]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkComplexBlackBox.cxx
Add unfinished version of bbtkTranscriptor
[bbtk.git] / kernel / src / bbtkComplexBlackBox.cxx
index 2c09e31427908e8054c3fd63cd72eea8dfe8d438..8da8dadc19772309ca462eac88eb7564cd38dc96 100644 (file)
@@ -3,8 +3,8 @@
 Program:   bbtk
 Module:    $RCSfile: bbtkComplexBlackBox.cxx,v $
 Language:  C++
-Date:      $Date: 2008/01/22 15:02:00 $
-Version:   $Revision: 1.1 $
+Date:      $Date: 2008/02/08 10:05:38 $
+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
@@ -37,11 +37,11 @@ namespace bbtk
     : BlackBox(name),
       mDescriptor(desc)
   {
-    bbtkDebugMessageInc("Core",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::ComplexBlackBox(\""
                        <<name<<"\")"<<std::endl);
     bbAllocateConnectors();
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
   }
   //=======================================================================
 
@@ -53,28 +53,28 @@ namespace bbtk
       mDescriptor(from.mDescriptor),
      mExecutionList(from.mExecutionList)    
   {
-    bbtkDebugMessageInc("Core",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::ComplexBlackBox(\""
                        <<from.bbGetName()<<"\",\""
                        <<name<<"\")"<<std::endl);
 
-    bbtkDebugMessageInc("Core",9,"* Cloning Black Boxes"<<std::endl);
+    bbtkDebugMessageInc("Kernel",9,"* Cloning Black Boxes"<<std::endl);
     BlackBoxMapType::const_iterator i;
     for ( i = from.mBlackBoxMap.begin(); i != from.mBlackBoxMap.end(); ++i ) 
       {
-       bbtkDebugMessageInc("Core",9,"* Cloning \""<<i->first<<"\""<<std::endl);
+       bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<i->first<<"\""<<std::endl);
        BlackBox* B = i->second->bbClone(i->second->bbGetName());
        bbUnsafeAddBlackBox(B);
        
-       bbtkDebugDecTab("Core",9);
+       bbtkDebugDecTab("Kernel",9);
       }
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
    
-    bbtkDebugMessageInc("Core",9,"* Cloning Connections"<<std::endl);
+    bbtkDebugMessageInc("Kernel",9,"* Cloning Connections"<<std::endl);
     ConnectionListType::const_iterator j;
     for ( j = from.mConnectionList.begin(); j != from.mConnectionList.end(); ++j ) 
       {
-       bbtkDebugMessageInc("Core",9,"* Cloning \""<<
+       bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<
                            (*j)->GetFullName()<<"\""<<std::endl);
 
        BlackBox* bbfrom = bbGetBlackBox( (*j)->GetBlackBoxFrom()->bbGetName() );
@@ -87,12 +87,12 @@ namespace bbtk
        
        bbAddConnection(c);
 
-       bbtkDebugDecTab("Core",9);
+       bbtkDebugDecTab("Kernel",9);
       }
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
 
     bbAllocateConnectors();
-    bbtkDebugDecTab("Core",9);    
+    bbtkDebugDecTab("Kernel",9);    
   }
   //=======================================================================
 
@@ -100,37 +100,37 @@ namespace bbtk
   ///  Destructor
   ComplexBlackBox::~ComplexBlackBox()
   {
-    bbtkDebugMessageInc("Core",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::~ComplexBlackBox() ["
                        <<bbGetFullName()<<"]"<<std::endl);
     
-    bbtkDebugMessageInc("Core",9,"* Delete Connections"<<std::endl);
+    bbtkDebugMessageInc("Kernel",9,"* Delete Connections"<<std::endl);
     ConnectionListType::iterator j;
     for ( j = mConnectionList.begin(); j != mConnectionList.end(); ++j ) 
       {
-       bbtkDebugMessageInc("Core",9,"* Delete \""<<
+       bbtkDebugMessageInc("Kernel",9,"* Delete \""<<
                            (*j)->GetFullName()<<"\""<<std::endl);
        delete *j;
-       bbtkDebugDecTab("Core",9);
+       bbtkDebugDecTab("Kernel",9);
       }
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
 
     
-    bbtkDebugMessageInc("Core",9,"* Delete Black Boxes"<<std::endl);
+    bbtkDebugMessageInc("Kernel",9,"* Delete Black Boxes"<<std::endl);
     BlackBoxMapType::iterator i;
     for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i ) 
       {
-       bbtkDebugMessageInc("Core",9,"* Delete \""<<i->first<<"\""<<std::endl);
+       bbtkDebugMessageInc("Kernel",9,"* Delete \""<<i->first<<"\""<<std::endl);
        i->second->bbDelete();
-       bbtkDebugDecTab("Core",9);
+       bbtkDebugDecTab("Kernel",9);
       }
-    bbtkDebugDecTab("Core",9);
-    //    bbtkDebugMessage("Core",9,"EO ComplexBlackBox::~ComplexBlackBox  ["
+    bbtkDebugDecTab("Kernel",9);
+    //    bbtkDebugMessage("Kernel",9,"EO ComplexBlackBox::~ComplexBlackBox  ["
     //              <<bbGetFullName()<<"]"<<std::endl);
 
     
     this->bbDesallocateConnectors();
-    bbtkDebugDecTab("Core",9);   
+    bbtkDebugDecTab("Kernel",9);   
   } 
   //=======================================================================
 
@@ -138,7 +138,7 @@ namespace bbtk
   /// Allocates the i/o connectors of the black box
   void ComplexBlackBox::bbAllocateConnectors()
   {  
-    bbtkDebugMessageInc("Core",8,
+    bbtkDebugMessageInc("Kernel",8,
                        "ComplexBlackBox::bbAllocateConnectors() ["
                        <<bbGetFullName()<<"]"
                        <<std::endl);   
@@ -149,7 +149,7 @@ namespace bbtk
     BlackBoxDescriptor::InputDescriptorMapType::const_iterator i;      
     for ( i = imap.begin(); i != imap.end(); ++i )                     
       {                                                                        
-       bbtkDebugMessage("Core",8,"* Allocate \""<<i->first<<"\""<<std::endl);
+       bbtkDebugMessage("Kernel",8,"* Allocate \""<<i->first<<"\""<<std::endl);
        // Redirect the connector to the internal box connector
        // Cast the BBInputDescriptor into a ComplexBBInputDescriptor
        ComplexBlackBoxInputDescriptor* d = 
@@ -169,7 +169,7 @@ namespace bbtk
     BlackBoxDescriptor::OutputDescriptorMapType::const_iterator o; 
     for ( o = omap.begin(); o != omap.end(); ++o )
       {                                                        
-       bbtkDebugMessage("Core",8,"* Allocate \""<<o->first<<"\""<<std::endl);
+       bbtkDebugMessage("Kernel",8,"* Allocate \""<<o->first<<"\""<<std::endl);
        // Redirect the connector to the internal box connector
        // Cast the BBOutputDescriptor into a ComplexBBOutputDescriptor
        ComplexBlackBoxOutputDescriptor* d = 
@@ -182,7 +182,7 @@ namespace bbtk
        bbGetOutputConnectorMap()[o->second->GetName()] = c;
        //new BlackBoxOutputConnector();
       }
-    bbtkDebugDecTab("Core",8);  
+    bbtkDebugDecTab("Kernel",8);  
   }
   //=========================================================================
 
@@ -191,7 +191,7 @@ namespace bbtk
   /// Desallocates the i/o connectors of the black box
   void ComplexBlackBox::bbDesallocateConnectors()
   {
-    bbtkDebugMessageInc("Core",8,
+    bbtkDebugMessageInc("Kernel",8,
                        "ComplexBlackBox::DesallocateConnectors()"
                        <<std::endl);                                   
 
@@ -202,7 +202,7 @@ namespace bbtk
     bbGetInputConnectorMap().clear();
     bbGetOutputConnectorMap().clear();
 
-    bbtkDebugDecTab("Core",8);  
+    bbtkDebugDecTab("Kernel",8);  
 
   }
   //=========================================================================
@@ -210,13 +210,13 @@ namespace bbtk
   //=======================================================================
   BlackBox* ComplexBlackBox::bbClone(const std::string& name)
   {
-    bbtkDebugMessageInc("Core",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::bbClone(\""<<name<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);
     
     ComplexBlackBox* CBB = new ComplexBlackBox(*this,name);
     
-    bbtkDebugDecTab("Core",9);   
+    bbtkDebugDecTab("Kernel",9);   
 
     return CBB;
   }
@@ -231,7 +231,7 @@ namespace bbtk
                        "ComplexBlackBox::bbExecute() ["
                        <<bbGetFullName()<<"]"<<std::endl);
 
-    wx::BeginBusyCursor();
+    Wx::BeginBusyCursor();
     
     if (mExecutionList.size() != 0) 
       {
@@ -254,7 +254,7 @@ namespace bbtk
          }
       } 
 
-    wx::EndBusyCursor();
+    Wx::EndBusyCursor();
     
     bbtkDebugDecTab("Process",1);
     
@@ -279,14 +279,14 @@ namespace bbtk
   //==================================================================
   void ComplexBlackBox::bbAddToExecutionList( const std::string& name )
   {
-        bbtkDebugMessageInc("Core",9,
+        bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::bbAddToExecutionList(\""
                        <<name<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);
 
        mExecutionList.push_back( name );
 
-     bbtkDebugDecTab("Core",9);   
+     bbtkDebugDecTab("Kernel",9);   
 
   }
   //==================================================================
@@ -461,7 +461,7 @@ namespace bbtk
   /// Adds the black box to the complex box
   void ComplexBlackBox::bbAddBlackBox( BlackBox* b)
   {
-    bbtkDebugMessageInc("Core",7,
+    bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::AddBlackBox(\""<<b->bbGetName()
                        <<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);  
@@ -474,7 +474,7 @@ namespace bbtk
     b->bbSetParent(this);
     mBlackBoxMap[b->bbGetName()] = b;
 
-    bbtkDebugDecTab("Core",7);
+    bbtkDebugDecTab("Kernel",7);
   }
   //==================================================================
 
@@ -482,7 +482,7 @@ namespace bbtk
   /// Adds the black box to the complex box (unsafe)
   void ComplexBlackBox::bbUnsafeAddBlackBox( BlackBox* b)
   {
-    bbtkDebugMessageInc("Core",7,
+    bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::UnsafeAddBlackBox(\""<<b->bbGetName()
                        <<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);  
@@ -490,7 +490,7 @@ namespace bbtk
     b->bbSetParent(this);
     mBlackBoxMap[b->bbGetName()] = b;
 
-    bbtkDebugDecTab("Core",7);
+    bbtkDebugDecTab("Kernel",7);
   }
   //==================================================================
 
@@ -498,13 +498,13 @@ namespace bbtk
   /// Removes the black box from the complex box
   void ComplexBlackBox::bbRemoveBlackBox( const std::string& name )
   {
-    bbtkDebugMessageInc("Core",7,
+    bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::RemoveBlackBox(\""<<name<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);  
 
     bbtkError("ComplexBlackBox::RemoveBlackBox not implemented");
 
-    bbtkDebugDecTab("Core",7);
+    bbtkDebugDecTab("Kernel",7);
   }
   //==================================================================
 
@@ -512,13 +512,13 @@ namespace bbtk
   /// Adds the connection to the complex box
   void ComplexBlackBox::bbAddConnection( Connection* c)
   {
-    bbtkDebugMessageInc("Core",7,
+    bbtkDebugMessageInc("Kernel",7,
                        "ComplexBlackBox::AddConnection(\""<<"..."<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);  
 
     mConnectionList.push_back(c);
 
-    bbtkDebugDecTab("Core",7);
+    bbtkDebugDecTab("Kernel",7);
   }
   //==================================================================
   //    void RemoveConnection( );
@@ -527,7 +527,7 @@ namespace bbtk
   /// Returns the black box with name <name>
   BlackBox* ComplexBlackBox::bbGetBlackBox( const std::string& name )
   {
-    bbtkDebugMessageInc("Core",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::GetBlackBox(\""<<name<<"\") ["
                        <<bbGetFullName()<<"]"<<std::endl);  
 
@@ -537,7 +537,7 @@ namespace bbtk
        bbtkError("the black box \""<<name<<"\" does not exist");
       }
 
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
     return i->second;
   }
   //==================================================================
@@ -547,7 +547,7 @@ namespace bbtk
   /// if it does not exist but return a null pointer
   BlackBox* ComplexBlackBox::bbUnsafeGetBlackBox( const std::string& name )
   {
-    bbtkDebugMessageInc("Core",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::UnsafeGetBlackBox(\""<<name<<"\") ["
                        <<bbGetFullName()<<"]"
                        <<std::endl);  
@@ -555,11 +555,11 @@ namespace bbtk
     BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
     if ( i == mBlackBoxMap.end() ) 
       {
-       bbtkDebugDecTab("Core",9);
+       bbtkDebugDecTab("Kernel",9);
        return 0;
       }
 
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
     return i->second;
     
   }
@@ -568,7 +568,7 @@ namespace bbtk
   //==================================================================
   void ComplexBlackBox::bbPrintBlackBoxes()
   {
-    bbtkDebugMessageInc("Core",9,
+    bbtkDebugMessageInc("Kernel",9,
                        "ComplexBlackBox::PrintBlackBoxes() ["
                        <<bbGetFullName()<<"]"
                        <<std::endl);  
@@ -579,7 +579,7 @@ namespace bbtk
        bbtkMessage("Help",1,i->second->bbGetFullName()<<std::endl);
       }
 
-    bbtkDebugDecTab("Core",9);
+    bbtkDebugDecTab("Kernel",9);
   }
   //==================================================================
 
@@ -616,20 +616,22 @@ namespace bbtk
     restname = blackboxname.substr(lastPos+pos - lastPos+1, 999);
 
     if (restname==subname)
-      {
-       restname="";
-      }
+    {
+          restname="";
+    }
 
     BlackBoxMapType::iterator i = mBlackBoxMap.find(subname);
     if ( i == mBlackBoxMap.end() ) 
-      {
-       blackbox = NULL;
-      } else {
-      blackbox = i->second;
-      if (restname!="")
-       {
-         blackbox = blackbox->bbFindBlackBox(restname);
-       }
+    {
+          blackbox = NULL;
+    } 
+    else 
+    {
+       blackbox = i->second;
+       if (restname!="")
+           {
+            blackbox = blackbox->bbFindBlackBox(restname);
+           }
     }
     return blackbox;
   }
@@ -647,11 +649,11 @@ namespace bbtk
     std::string directory(output_dir);
 
     if (output_dir.length() == 0) 
-      {
-       // Don't pollute the file store with  "doc_tmp" directories ... 
-       std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_doc_tmp();
-       directory =  default_doc_dir + "/" + "doc_tmp";
-      }
+    {
+          // Don't pollute the file store with  "temp_dir" directories ... 
+          std::string default_temp_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
+          directory =  default_temp_dir + "/" + "temp_dir";
+    }
     
     std::string simplefilename  (this->bbGetTypeName()+"_"+this->bbGetName());
     std::string simplefilename_png (simplefilename+".png");
@@ -701,13 +703,13 @@ namespace bbtk
     char c;
     ff2=fopen(filename_cmap.c_str(),"r");
     while (!feof(ff2))
-      {
-       c=fgetc(ff2);
-       if (c!=-1)
-         {
-           (s) << c;
-         }
-      }
+    {
+          c=fgetc(ff2);
+          if (c!=-1)
+          {
+             (s) << c;
+          }
+    }
     (s) << "</map>\n\n";
     
     // End
@@ -728,38 +730,40 @@ namespace bbtk
     Package *package = this->bbGetDescriptor()->GetPackage(); 
 
     if (package!=NULL)
-      {
-       if (relative_link)
-         tmp1 = this->bbGetDescriptor()->GetPackage()->GetDocRelativeURL();
-       else 
-         tmp1 = this->bbGetDescriptor()->GetPackage()->GetDocURL();
-      
+    {
+      if (relative_link)
+            tmp1 = this->bbGetDescriptor()->GetPackage()->GetDocRelativeURL();
+          else 
+            tmp1 = this->bbGetDescriptor()->GetPackage()->GetDocURL();
+    } 
     else 
-      {
-       tmp1 = "Caspitas";
-      }
+    {
+          tmp1 = "Caspitas";
+    }
 
     std::string tmp2=bbGetTypeName();
     std::string url(tmp1 + "#" + tmp2 );       
     fprintf( ff , "subgraph cluster_%s_%p {\n",bbGetName().c_str(),this);
 
     if (!(   (bbGetTypeName()=="workspace") && (bbGetName()=="workspacePrototype")) )
-      {
-       fprintf( ff , "  URL = \"%s\" %s",url.c_str(),";");
-      }
+    {
+          fprintf( ff , "  URL = \"%s\" %s",url.c_str(),";");
+    }
 
     std::string boxname="["+bbGetTypeName()+"]";
     if (this!=parentblackbox)
-      {
-       if (detail==0)
-         {
-           boxname=bbGetName();
-         } else {
-         boxname = bbGetName();
-         boxname = boxname + "   [" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "]";
-       }
+    {
+       if (detail==0)
+           {
+          boxname=bbGetName();
+       } 
+       else 
+       {
+          boxname = bbGetName();
+          boxname = boxname + "   [" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "]";
+           }
 
-      }
+    }
     fprintf( ff , "  label = \"%s\"%s\n",  boxname.c_str() ,";");