1 /*=========================================================================
4 Module: $RCSfile: bbtkComplexBlackBox.cxx,v $
6 Date: $Date: 2008/04/08 06:59:29 $
7 Version: $Revision: 1.8 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
22 * \brief class bbtk::ComplexBlackBox : user defined complex black boxes
24 #include "bbtkComplexBlackBox.h"
25 #include "bbtkBlackBoxDescriptor.h"
26 #include "bbtkFactory.h"
27 #include "bbtkConfigurationFile.h"
33 //=======================================================================
34 /// Usefull constructor
35 ComplexBlackBox::ComplexBlackBox(const std::string &name,
36 ComplexBlackBoxDescriptor* desc)
40 bbtkDebugMessageInc("Kernel",9,
41 "ComplexBlackBox::ComplexBlackBox(\""
42 <<name<<"\")"<<std::endl);
43 bbAllocateConnectors();
44 bbtkDebugDecTab("Kernel",9);
46 //=======================================================================
48 //=======================================================================
49 /// Constructor from an existing box (copy) with a new name
50 ComplexBlackBox::ComplexBlackBox(ComplexBlackBox& from,
51 const std::string &name)
52 : BlackBox(from,name),
53 mDescriptor(from.mDescriptor),
54 mExecutionList(from.mExecutionList)
56 bbtkDebugMessageInc("Kernel",9,
57 "ComplexBlackBox::ComplexBlackBox(\""
58 <<from.bbGetName()<<"\",\""
59 <<name<<"\")"<<std::endl);
61 bbtkDebugMessageInc("Kernel",9,"* Cloning Black Boxes"<<std::endl);
62 BlackBoxMapType::const_iterator i;
63 for ( i = from.mBlackBoxMap.begin(); i != from.mBlackBoxMap.end(); ++i )
65 bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<i->first<<"\""<<std::endl);
66 BlackBox* B = i->second->bbClone(i->second->bbGetName());
67 bbUnsafeAddBlackBox(B);
69 bbtkDebugDecTab("Kernel",9);
71 bbtkDebugDecTab("Kernel",9);
73 bbtkDebugMessageInc("Kernel",9,"* Cloning Connections"<<std::endl);
74 ConnectionListType::const_iterator j;
75 for ( j = from.mConnectionList.begin(); j != from.mConnectionList.end(); ++j )
77 bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<
78 (*j)->GetFullName()<<"\""<<std::endl);
80 BlackBox* bbfrom = bbGetBlackBox( (*j)->GetBlackBoxFrom()->bbGetName() );
81 BlackBox* bbto = bbGetBlackBox( (*j)->GetBlackBoxTo()->bbGetName() );
82 Connection* c = mDescriptor->GetFactory()->
83 NewConnection( bbfrom,
84 (*j)->GetBlackBoxFromOutput(),
86 (*j)->GetBlackBoxToInput() );
90 bbtkDebugDecTab("Kernel",9);
92 bbtkDebugDecTab("Kernel",9);
94 bbAllocateConnectors();
95 bbtkDebugDecTab("Kernel",9);
97 //=======================================================================
99 //=======================================================================
101 ComplexBlackBox::~ComplexBlackBox()
103 bbtkDebugMessageInc("Kernel",9,
104 "ComplexBlackBox::~ComplexBlackBox() ["
105 <<bbGetFullName()<<"]"<<std::endl);
107 bbtkDebugMessageInc("Kernel",9,"* Delete Connections"<<std::endl);
108 ConnectionListType::iterator j;
109 for ( j = mConnectionList.begin(); j != mConnectionList.end(); ++j )
111 bbtkDebugMessageInc("Kernel",9,"* Delete \""<<
112 (*j)->GetFullName()<<"\""<<std::endl);
114 bbtkDebugDecTab("Kernel",9);
116 bbtkDebugDecTab("Kernel",9);
119 bbtkDebugMessageInc("Kernel",9,"* Delete Black Boxes"<<std::endl);
120 BlackBoxMapType::iterator i;
121 for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i )
123 bbtkDebugMessageInc("Kernel",9,"* Delete \""<<i->first<<"\""<<std::endl);
124 i->second->bbDelete();
125 bbtkDebugDecTab("Kernel",9);
127 bbtkDebugDecTab("Kernel",9);
128 // bbtkDebugMessage("Kernel",9,"EO ComplexBlackBox::~ComplexBlackBox ["
129 // <<bbGetFullName()<<"]"<<std::endl);
132 this->bbDesallocateConnectors();
133 bbtkDebugDecTab("Kernel",9);
135 //=======================================================================
137 //=========================================================================
138 /// Allocates the i/o connectors of the black box
139 void ComplexBlackBox::bbAllocateConnectors()
141 bbtkDebugMessageInc("Kernel",8,
142 "ComplexBlackBox::bbAllocateConnectors() ["
143 <<bbGetFullName()<<"]"
147 const BlackBoxDescriptor::InputDescriptorMapType& imap
148 = bbGetDescriptor()->GetInputDescriptorMap();
149 BlackBoxDescriptor::InputDescriptorMapType::const_iterator i;
150 for ( i = imap.begin(); i != imap.end(); ++i )
152 bbtkDebugMessage("Kernel",8,"* Allocate \""<<i->first<<"\""<<std::endl);
153 // Redirect the connector to the internal box connector
154 // Cast the BBInputDescriptor into a ComplexBBInputDescriptor
155 ComplexBlackBoxInputDescriptor* d =
156 (ComplexBlackBoxInputDescriptor*)i->second;
157 // Get the internal box connector
158 BlackBoxInputConnector* c =
159 bbUnsafeGetBlackBox ( d->GetTarget() )
160 ->bbGetInputConnectorMap()[ d->GetInput() ];
162 bbGetInputConnectorMap()[i->second->GetName()] = c;
163 //new BlackBoxInputConnector();
167 const BlackBoxDescriptor::OutputDescriptorMapType& omap
168 = bbGetDescriptor()->GetOutputDescriptorMap();
169 BlackBoxDescriptor::OutputDescriptorMapType::const_iterator o;
170 for ( o = omap.begin(); o != omap.end(); ++o )
172 bbtkDebugMessage("Kernel",8,"* Allocate \""<<o->first<<"\""<<std::endl);
173 // Redirect the connector to the internal box connector
174 // Cast the BBOutputDescriptor into a ComplexBBOutputDescriptor
175 ComplexBlackBoxOutputDescriptor* d =
176 (ComplexBlackBoxOutputDescriptor*)o->second;
177 // Get the internal box connector
178 BlackBoxOutputConnector* c =
179 bbUnsafeGetBlackBox ( d->GetTarget() )
180 ->bbGetOutputConnectorMap()[ d->GetOutput() ];
182 bbGetOutputConnectorMap()[o->second->GetName()] = c;
183 //new BlackBoxOutputConnector();
185 bbtkDebugDecTab("Kernel",8);
187 //=========================================================================
190 //=========================================================================
191 /// Desallocates the i/o connectors of the black box
192 void ComplexBlackBox::bbDesallocateConnectors()
194 bbtkDebugMessageInc("Kernel",8,
195 "ComplexBlackBox::DesallocateConnectors()"
198 // The connectors have not been allocated by the complex box
199 // but by the internal boxes. Hence **DO NOT** desallocate !
200 // just clear the maps to avoid that
201 // BlackBox::bbDesallocateConnectors delete the connectors
202 bbGetInputConnectorMap().clear();
203 bbGetOutputConnectorMap().clear();
205 bbtkDebugDecTab("Kernel",8);
208 //=========================================================================
210 //=======================================================================
211 BlackBox* ComplexBlackBox::bbClone(const std::string& name)
213 bbtkDebugMessageInc("Kernel",9,
214 "ComplexBlackBox::bbClone(\""<<name<<"\") ["
215 <<bbGetFullName()<<"]"<<std::endl);
217 ComplexBlackBox* CBB = new ComplexBlackBox(*this,name);
219 bbtkDebugDecTab("Kernel",9);
223 //=======================================================================
225 //=======================================================================
226 /// Main processing method of the box.
227 /// Executes the box so that its outputs are up-to-date on exit
228 void ComplexBlackBox::bbExecute(bool force)
230 bbtkDebugMessageInc("Process",1,
231 "ComplexBlackBox::bbExecute() ["
232 <<bbGetFullName()<<"]"<<std::endl);
235 Wx::BeginBusyCursor();
237 if (mExecutionList.size() != 0)
240 std::vector<std::string>::const_iterator i;
241 for (i=mExecutionList.begin();
242 i!=mExecutionList.end();
245 bbtkDebugMessage("Process",2," -> Executing '"<<*i<<"'"<<std::endl);
246 mBlackBoxMap[*i]->bbExecute(force);
251 std::map<std::string, BlackBox*>::iterator i;
252 for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i)
254 i->second->bbExecute(force);
261 bbtkDebugDecTab("Process",1);
264 //==================================================================
266 //==================================================================
267 void ComplexBlackBox::bbSetModifiedStatus(BlackBoxInputConnector* c)
269 bbtkDebugMessage("Process",3,
270 "ComplexBlackBox::bbSetModifiedStatus("
271 <<c<<") ["<<bbGetFullName()<<"]"<<std::endl);
273 c->GetBlackBox()->bbSetModifiedStatus(c);
275 bbtkDebugMessage("Process",3,
276 "EO ComplexBlackBox::bbSetModifiedStatus("
277 <<c<<") ["<<bbGetFullName()<<"]"<<std::endl);
279 //==================================================================
281 //==================================================================
282 void ComplexBlackBox::bbAddToExecutionList( const std::string& name )
284 bbtkDebugMessageInc("Kernel",9,
285 "ComplexBlackBox::bbAddToExecutionList(\""
287 <<bbGetFullName()<<"]"<<std::endl);
289 mExecutionList.push_back( name );
291 bbtkDebugDecTab("Kernel",9);
294 //==================================================================
296 //==================================================================
297 IOStatus ComplexBlackBox::bbBackwardUpdate(Connection* caller)
299 bbtkDebugMessageInc("Process",1,
300 "ComplexBlackBox::bbBackwardUpdate("
301 <<(caller?caller->GetFullName():"0")<<") ["
302 <<bbGetFullName()<<"]"<<std::endl);
306 bbtkInternalError("ComplexBlackBox::bbBackwardUpdate called with caller=0");
309 if (bbGetExecuting())
311 bbtkWarning(bbGetFullName()<<" : Cyclic execution stopped");
314 bbSetExecuting(true);
316 IOStatus s = UPTODATE;
317 const BlackBoxDescriptor::OutputDescriptorMapType& omap
318 = bbGetDescriptor()->GetOutputDescriptorMap();
319 BlackBoxDescriptor::OutputDescriptorMapType::const_iterator i
320 = omap.find(caller->GetBlackBoxFromOutput());
323 // Cast the BBOutputDescriptor into a ComplexBBOutputDescriptor
324 ComplexBlackBoxOutputDescriptor* d =
325 (ComplexBlackBoxOutputDescriptor*)i->second;
326 // Get the internal box
327 BlackBox* b = bbUnsafeGetBlackBox ( d->GetTarget() );
328 // Calls BackwardUpdate on it
329 bbtkDebugMessageInc("Process",2,"Internal box connected to output : "<<d->GetTarget()<<std::endl);
330 // Because internal box can also be a complex box we have to
331 // temporarily change the connection BlackBoxFromOutput to the
334 // std::string oldout = caller->GetBlackBoxFromOutput();
335 // std::cout << "oldout = "<<oldout<<std::endl;
336 // std::cout << "tmpout = "<<d->GetOutput()<<std::endl;
337 // caller->SetBlackBoxFromOutput(d->GetOutput());
339 Connection newcaller(*caller);
340 newcaller.SetBlackBoxFromOutput(d->GetOutput());
341 IOStatus s1 = b->bbBackwardUpdate(&newcaller);
343 // restore old output
344 // caller->SetBlackBoxFromOutput(oldout);
346 // ??? STATUS OF CBBs ???
347 // ??? Here it is only the final status of the boxes connected to the output
348 if (s1==MODIFIED) s=MODIFIED;
349 bbtkDebugDecTab("Process",2);
353 bbtkError("Connection '"<<caller->GetFullName()<<"' does not point to a valid output of the complex box !");
355 bbtkDebugDecTab("Process",1);
357 bbSetExecuting(false);
361 //==================================================================
364 //==================================================================
365 Data ComplexBlackBox::bbGetOutput( const std::string &name )
367 bbtkDebugMessageInc("Data",7,
368 "ComplexBlackBox::bbGetOutput(\""<<name<<"\") ["
369 <<bbGetFullName()<<"]"<<std::endl);
371 ComplexBlackBoxOutputDescriptor* d =
372 (ComplexBlackBoxOutputDescriptor*)
373 bbGetDescriptor()->GetOutputDescriptor(name);
375 Data p = bbGetBlackBox(d->GetTarget())->bbGetOutput(d->GetOutput());
378 bbtkDebugDecTab("Data",7);
381 //==================================================================
383 //==================================================================
384 /// Gets the input Data of a given name
385 Data ComplexBlackBox::bbGetInput( const std::string &name )
387 bbtkDebugMessageInc("Data",7,
388 "ComplexBlackBox::bbGetInput(\""<<name<<"\") ["
389 <<bbGetFullName()<<"]"<<std::endl);
391 ComplexBlackBoxInputDescriptor* d =
392 (ComplexBlackBoxInputDescriptor*)
393 bbGetDescriptor()->GetInputDescriptor(name);
395 Data p = bbGetBlackBox(d->GetTarget())->bbGetInput(d->GetInput());
397 bbtkDebugDecTab("Data",7);
400 //==================================================================
402 //==================================================================
403 /// Sets the data of the output called <name>
404 void ComplexBlackBox::bbSetOutput( const std::string &name, Data data)
406 bbtkDebugMessageInc("Data",7,
407 "ComplexBlackBox::bbSetOutput(\""<<name<<"\",data) ["
408 <<bbGetFullName()<<"]"<<std::endl);
410 ComplexBlackBoxOutputDescriptor* d =
411 (ComplexBlackBoxOutputDescriptor*)
412 bbGetDescriptor()->GetOutputDescriptor(name);
414 bbGetBlackBox(d->GetTarget())->bbSetOutput(d->GetOutput(),data);
416 bbtkDebugDecTab("Data",7);
418 //==================================================================
420 //==================================================================
421 /// Sets the data of the input called <name>
422 void ComplexBlackBox::bbSetInput( const std::string &name, Data data,
425 bbtkDebugMessageInc("Data",7,
426 "ComplexBlackBox::bbSetInput(\""<<name<<"\",data) ["
427 <<bbGetFullName()<<"]"<<std::endl);
429 ComplexBlackBoxInputDescriptor* d = (ComplexBlackBoxInputDescriptor*)
430 bbGetDescriptor()->GetInputDescriptor(name);
432 bbGetBlackBox(d->GetTarget())->bbSetInput(d->GetInput(),data,setModified);
434 bbtkDebugDecTab("Data",7);
436 //==================================================================
439 //==================================================================
440 /// Sets the data of the input called <name>
441 void ComplexBlackBox::bbBruteForceSetInputPointer( const std::string &name,
445 bbtkDebugMessageInc("Data",7,
446 "ComplexBlackBox::bbBruteForceSetInputPointer('"
447 <<name<<"',"<<data<<") ["
448 <<bbGetFullName()<<"]"<<std::endl);
450 ComplexBlackBoxInputDescriptor* d = (ComplexBlackBoxInputDescriptor*)
451 bbGetDescriptor()->GetInputDescriptor(name);
453 bbGetBlackBox(d->GetTarget())->bbBruteForceSetInputPointer(d->GetInput(),
457 bbtkDebugDecTab("Data",7);
459 //==================================================================
461 //==================================================================
462 /// Adds the black box to the complex box
463 void ComplexBlackBox::bbAddBlackBox( BlackBox* b)
465 bbtkDebugMessageInc("Kernel",7,
466 "ComplexBlackBox::AddBlackBox(\""<<b->bbGetName()
468 <<bbGetFullName()<<"]"<<std::endl);
470 if ( bbUnsafeGetBlackBox(b->bbGetName()) )
472 bbtkError("a black box called \""<<b->bbGetName()
473 <<"\" already exists");
475 b->bbSetParent(this);
476 mBlackBoxMap[b->bbGetName()] = b;
478 bbtkDebugDecTab("Kernel",7);
480 //==================================================================
482 //==================================================================
483 /// Adds the black box to the complex box (unsafe)
484 void ComplexBlackBox::bbUnsafeAddBlackBox( BlackBox* b)
486 bbtkDebugMessageInc("Kernel",7,
487 "ComplexBlackBox::UnsafeAddBlackBox(\""<<b->bbGetName()
489 <<bbGetFullName()<<"]"<<std::endl);
491 b->bbSetParent(this);
492 mBlackBoxMap[b->bbGetName()] = b;
494 bbtkDebugDecTab("Kernel",7);
496 //==================================================================
498 //==================================================================
499 /// Removes the black box from the complex box
500 void ComplexBlackBox::bbRemoveBlackBox( const std::string& name )
502 bbtkDebugMessageInc("Kernel",7,
503 "ComplexBlackBox::RemoveBlackBox(\""<<name<<"\") ["
504 <<bbGetFullName()<<"]"<<std::endl);
506 bbtkError("ComplexBlackBox::RemoveBlackBox not implemented");
508 bbtkDebugDecTab("Kernel",7);
510 //==================================================================
512 //==================================================================
513 /// Adds the connection to the complex box
514 void ComplexBlackBox::bbAddConnection( Connection* c)
516 bbtkDebugMessageInc("Kernel",7,
517 "ComplexBlackBox::AddConnection(\""<<"..."<<"\") ["
518 <<bbGetFullName()<<"]"<<std::endl);
520 mConnectionList.push_back(c);
522 bbtkDebugDecTab("Kernel",7);
524 //==================================================================
525 // void RemoveConnection( );
527 //==================================================================
528 /// Returns the black box with name <name>
529 BlackBox* ComplexBlackBox::bbGetBlackBox( const std::string& name )
531 bbtkDebugMessageInc("Kernel",9,
532 "ComplexBlackBox::GetBlackBox(\""<<name<<"\") ["
533 <<bbGetFullName()<<"]"<<std::endl);
535 BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
536 if ( i == mBlackBoxMap.end() )
538 bbtkError("the black box \""<<name<<"\" does not exist");
541 bbtkDebugDecTab("Kernel",9);
544 //==================================================================
546 //==================================================================
547 /// Returns the black box with name <name> : does not throw an exception
548 /// if it does not exist but return a null pointer
549 BlackBox* ComplexBlackBox::bbUnsafeGetBlackBox( const std::string& name )
551 bbtkDebugMessageInc("Kernel",9,
552 "ComplexBlackBox::UnsafeGetBlackBox(\""<<name<<"\") ["
553 <<bbGetFullName()<<"]"
556 BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
557 if ( i == mBlackBoxMap.end() )
559 bbtkDebugDecTab("Kernel",9);
563 bbtkDebugDecTab("Kernel",9);
567 //==================================================================
569 //==================================================================
570 void ComplexBlackBox::bbPrintBlackBoxes()
572 bbtkDebugMessageInc("Kernel",9,
573 "ComplexBlackBox::PrintBlackBoxes() ["
574 <<bbGetFullName()<<"]"
577 BlackBoxMapType::iterator i;
578 for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i )
580 bbtkMessage("Help",1,i->second->bbGetFullName()<<std::endl);
583 bbtkDebugDecTab("Kernel",9);
585 //==================================================================
589 //=========================================================================
591 void ComplexBlackBox::bbWriteDotInputOutputName(FILE *ff,bool inputoutput,int detail, int level)
595 fprintf(ff,"%s_IN_%p",bbGetTypeName().c_str(),this);
597 fprintf(ff,"%s_OUT_%p",bbGetTypeName().c_str(),this);
600 //=========================================================================
603 //=========================================================================
604 BlackBox *ComplexBlackBox::bbFindBlackBox(const std::string &blackboxname)
606 BlackBox *blackbox=NULL;
607 std::string subname="";
608 std::string restname="";
609 std::string delimiters(">");
610 // Skip delimiters at beginning.
611 std::string::size_type lastPos = blackboxname.find_first_not_of(delimiters, 0);
612 // Find first "non-delimiter".
613 std::string::size_type pos = blackboxname.find_first_of(delimiters, lastPos);
615 // Found a token, add it to the vector.
616 subname = blackboxname.substr(lastPos, pos - lastPos);
617 restname = blackboxname.substr(lastPos+pos - lastPos+1, 999);
619 if (restname==subname)
624 BlackBoxMapType::iterator i = mBlackBoxMap.find(subname);
625 if ( i == mBlackBoxMap.end() )
631 blackbox = i->second;
634 blackbox = blackbox->bbFindBlackBox(restname);
639 //=========================================================================
641 //=========================================================================
642 void ComplexBlackBox::bbInsertHTMLGraph( std::ofstream& s,
646 const std::string& output_dir,
650 std::string directory(output_dir);
652 if (output_dir.length() == 0)
654 // Don't pollute the file store with "temp_dir" directories ...
655 std::string default_temp_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
656 directory = default_temp_dir + "/" + "temp_dir";
659 std::string simplefilename (this->bbGetTypeName()+"_"+this->bbGetName());
660 std::string simplefilename_png (simplefilename+".png");
661 std::string filename (directory+"/"+simplefilename);
662 std::string filename_png (filename+".png");
663 std::string filename_cmap (filename+".cmap");
664 std::string filename_dot (filename+".dot");
666 std::string filename_png2 ("\"" + filename_png + "\"");
667 std::string filename_cmap2 ("\"" + filename_cmap + "\"");
668 std::string filename_dot2 ("\"" + filename_dot + "\"");
671 std::string command1 ("dot -T png -o "
672 + filename_png2 + " " + filename_dot2);
673 std::string command1a("dot -T cmap -o "
674 + filename_cmap2 + " " + filename_dot2);
676 // 1. Generating .dot file
678 ff = fopen(filename_dot.c_str(),"w");
679 fprintf(ff,"digraph bbtk_graph{\n");
680 fprintf(ff,"rankdir=LR%s\n",";");
681 fprintf(ff,"node [shape=record]%s\n",";");
683 this->bbWriteDotFileBlackBox(ff,this,detail,level,
690 // 2. Executing .dot file -> png
691 system( command1.c_str() );
692 // 3. Executing .dot file -> cmap
693 system( command1a.c_str() );
695 // 4. HTML code insertion
697 (s) << "<center><img src=\"" << simplefilename_png
698 << "\" border=\"0\" usemap=\"#map_"<< simplefilename
699 <<"\" alt=\"\"></center>\n";
702 (s) << "<map name=\"map_"<< simplefilename <<"\">\n";
705 ff2=fopen(filename_cmap.c_str(),"r");
718 //=========================================================================
721 //=========================================================================
722 /// Write Graphviz-dot description in file
723 void ComplexBlackBox::bbWriteDotFileBlackBox(FILE *ff,
724 BlackBox *parentblackbox,
725 int detail, int level,
730 std::string valueStr("");
731 Package *package = this->bbGetDescriptor()->GetPackage();
736 tmp1 = this->bbGetDescriptor()->GetPackage()->GetDocRelativeURL();
738 tmp1 = this->bbGetDescriptor()->GetPackage()->GetDocURL();
745 std::string tmp2=bbGetTypeName();
746 std::string url(tmp1 + "#" + tmp2 );
747 fprintf( ff , "subgraph cluster_%s_%p {\n",bbGetName().c_str(),this);
749 if (!( (bbGetTypeName()=="workspace") && (bbGetName()=="workspacePrototype")) )
751 fprintf( ff , " URL = \"%s\" %s",url.c_str(),";");
754 std::string boxname="["+bbGetTypeName()+"]";
755 if (this!=parentblackbox)
763 boxname = bbGetName();
764 boxname = boxname + " [" +this->bbGetDescriptor()->GetPackage()->GetName()+"::"+ bbGetTypeName() + "]";
768 fprintf( ff , " label = \"%s\"%s\n", boxname.c_str() ,";");
772 // fprintf( ff , " style=filled%s\n",";");
773 // fprintf( ff , " color=grey%s\n",";");
774 fprintf( ff , " node [style=filled]%s\n",";");
775 fprintf( ff , " fillcolor=grey%s\n",";");
776 fprintf( ff , " edge [color=blue]%s\n",";");
780 std::string labelStr1;
781 std::string labelStr2;
782 labelStr1 = boxname + "\\n(output)" ;
783 labelStr2 = " | {{ ";
786 OutputConnectorMapType::iterator i;
788 const BlackBoxDescriptor::OutputDescriptorMapType& omap = this->bbGetDescriptor()->GetOutputDescriptorMap();
789 BlackBoxDescriptor::OutputDescriptorMapType::const_iterator o;
790 for ( o = omap.begin(); o != omap.end(); ++o )
794 labelStr2=labelStr2+" | ";
797 if (instanceOrtype==true)
799 valueStr = this->bbGetOutputAsString(o->second->GetName()/*
802 labelStr2=labelStr2+"<"+o->second->GetName().c_str()+"> " + valueStr + o->second->GetName().c_str();
805 labelStr2 = labelStr2+ " } }";
811 labelStr1 = labelStr1 + labelStr2;
816 bbWriteDotInputOutputName(ff,false,detail,level);
817 fprintf( ff , " [shape=record, style=filled,fillcolor=grey,color=red,label=\"%s\"]%s\n",labelStr1.c_str(),";" );
822 labelStr1 = boxname + "\\n(input)" ;
823 labelStr2 = " | {{ ";
825 InputConnectorMapType::iterator ii;
827 const BlackBoxDescriptor::InputDescriptorMapType& imap = this->bbGetDescriptor()->GetInputDescriptorMap();
828 BlackBoxDescriptor::InputDescriptorMapType::const_iterator iii;
829 for ( iii = imap.begin(); iii != imap.end(); ++iii )
833 labelStr2=labelStr2+" | ";
836 if (instanceOrtype==true)
838 valueStr = this->bbGetInputAsString(iii->second->GetName()/*,factory*/) + " = ";
840 labelStr2=labelStr2+"<"+iii->second->GetName().c_str()+"> " + valueStr + iii->second->GetName().c_str();
844 labelStr2 = labelStr2+ " } }";
847 labelStr1 = labelStr1 + labelStr2;
851 bbWriteDotInputOutputName(ff,true,detail,level);
852 fprintf( ff , " [shape=record, style=filled,fillcolor=grey,color=red,label=\"%s\"]%s\n",labelStr1.c_str(),";" );
857 BlackBoxMapType::iterator j;
858 for ( j = mBlackBoxMap.begin(); j != mBlackBoxMap.end(); ++j )
862 j->second->bbWriteDotFileBlackBox(ff,parentblackbox,detail,
869 fprintf( ff , "}\n\n");
871 fprintf( ff , " edge[color=blue]%s\n",";");
875 // Relation Input with the inside BlackBox of the this ComplexBlackbox
876 ComplexBlackBoxDescriptor::InputDescriptorMapType::iterator xx;
877 ComplexBlackBoxDescriptor::InputDescriptorMapType idmt=bbGetDescriptor()->GetInputDescriptorMap();
878 for ( xx = idmt.begin(); xx != idmt.end(); ++xx )
880 ComplexBlackBoxInputDescriptor *cbbid = (ComplexBlackBoxInputDescriptor*)xx->second;
883 bbWriteDotInputOutputName(ff,true,detail,level);
886 fprintf(ff,":%s",cbbid->GetName().c_str() );
889 BlackBox *bb = bbGetBlackBox( cbbid->GetTarget() );
890 bb->bbWriteDotInputOutputName(ff,true,detail,level);
893 fprintf(ff,":%s \n", cbbid->GetInput().c_str() );
903 // Relation Output ComplexBlackBox
904 ComplexBlackBoxDescriptor::OutputDescriptorMapType::iterator yy;
905 ComplexBlackBoxDescriptor::OutputDescriptorMapType odmt=bbGetDescriptor()->GetOutputDescriptorMap();
906 for ( yy = odmt.begin(); yy != odmt.end(); ++yy )
908 ComplexBlackBoxOutputDescriptor *cbbod = (ComplexBlackBoxOutputDescriptor*)yy->second;
910 BlackBox *bb = bbGetBlackBox( cbbod->GetTarget() );
911 bb->bbWriteDotInputOutputName(ff,false,detail,level);
914 fprintf(ff,":%s", cbbod->GetOutput().c_str() );
917 bbWriteDotInputOutputName(ff,false,detail,level);
920 fprintf(ff,":%s",cbbod->GetName().c_str() );
929 // Relation from the out side of this ComplexBlackBox with its Inputs
930 if (this!=parentblackbox) {
931 for ( ii = bbGetInputConnectorMap().begin();
932 ii != bbGetInputConnectorMap().end(); ++ii )
936 Connection* con = ii->second->GetConnection();
938 BlackBox *a=con->GetBlackBoxFrom();
939 BlackBox *b=con->GetBlackBoxTo();
941 a->bbWriteDotInputOutputName(ff,false,detail,level);
944 fprintf(ff,":%s",con->GetBlackBoxFromOutput().c_str());
947 b->bbWriteDotInputOutputName(ff,true,detail,level);
950 fprintf(ff,":%s",con->GetBlackBoxToInput().c_str());
952 fprintf(ff,"%s\n",";");
956 } // if parentblackbox
958 //=========================================================================
965 //=======================================================================
966 /// Generates the list of the packages of which its depends
967 /// (cause an internal box belongs to it)
968 void ComplexBlackBox::GetPackagesDependencies(std::vector<Package*>& deps)
971 BlackBoxMapType::iterator i;
972 for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i )
974 deps.push_back(i->second->bbGetDescriptor()->GetPackage());
978 //=======================================================================