]> Creatis software - bbtk.git/blob - kernel/doc/bbtkUsersGuide/bbtkUsersGuide.tex
cosmetics
[bbtk.git] / kernel / doc / bbtkUsersGuide / bbtkUsersGuide.tex
1 % ==========================================
2 \documentclass[11pt,final,a4paper]{article}
3 \input{config.tex}
4 \begin{document}
5 \title{The Black Box Toolkit\\User's Guide}
6 \date{\today}
7 \author{Laurent Guigues}
8 \maketitle
9 % ==========================================
10 \tableofcontents
11 % ==========================================
12
13
14 % ==========================================
15 %\section*{Abstract}
16 % ==========================================
17 \newpage
18 % ==========================================
19 \hrule
20 \section{What is {\bf bbtk} ?}
21 % ==========================================
22 \BBTK(\bbtkns) is a set of tools 
23 (\CPP libraries and executables) 
24 providing a \CPP framework for the definition 
25 of elementary processing \emph{units}, called {\bf black boxes}, 
26 and the definition and execution of processing \emph{chains} 
27 made up of these black boxes. 
28
29 % ==========================================
30 \subsection{The black box philosophy}
31 % ==========================================
32 \href{http://en.wikipedia.org/wiki/Black_box_\%28disambiguation\%29}{Wikipedia}
33 defines a {\bf black box} as 
34 \emph{``any component in a system in which only the input and output 
35 characteristics are of interest, without regard to its internal mechanism 
36 or structure''}. 
37 I would add something very important to this definition : 
38 not only the inputs and outputs are of interest but also 
39 \emph{what the box does} !
40 Hence, I would say that a black box is any \emph{\bf documented} 
41 component of a system, letting know the user 
42 \emph{\bf what} the box is supposed to do and 
43 \emph{\bf how to use it}
44 but not \emph{\bf how it does it}.
45
46 \BBTK provides a systematic framework 
47 to encapsulate (or ``wrap'') any 
48 existing \texttt{C} or \CPP processing code into an object 
49 (a black box) having a {\bf generic symbolic interface}, where 
50
51 \begin{itemize}
52 \item{\bf generic} means that the interface is \emph{the same} 
53 for all boxes. Hence one does not need to know which particular 
54 method allows, say, to set a particular input or 
55 get a particular output of the box. 
56 One can use a black box in a purely abstract way. 
57 \item{\bf symbolic} means that a particular 
58 input or output is referenced by a 'name', that is by a symbol 
59 which identifies the input or output. 
60 It also means that symbolic information (text!) is 
61 attached to a box: description of the box, author, 
62 description of its inputs and outputs, etc.
63 \end{itemize}
64
65 (in fact, genericity is achieved because the interface is symbolic. 
66 I let you think about this\dots)
67
68 Of course, symbolic data attached to box can be 
69 {\bf queried}: what are the inputs/outputs of the box ? 
70 what are their type ? their description ? etc.
71 This allows {\bf automatic documentation} of boxes. 
72
73 The abstract definition of black boxes is the most basic 
74 aspect of \BBTK architecture. 
75 Another key aspect is the groupement of black boxes into 
76 so called {\bf packages}, 
77 which are \emph{dynamic libraries} which can also 
78 be queried, in particular about the boxes they provide. 
79 The package structure then offers a mechanism which 
80 is like a \emph{'plug-in'} mechanism.
81 \BBTK provides the methods to load a package at run-time, 
82 and create instances of the boxes it contains. 
83
84 These two mechanisms (black boxes and packages) 
85 then gives the way to:
86
87 \begin{itemize}
88 \item The definition of an {\bf interpreted language}, 
89 which allows to manipulate packages and boxes very easily in symbolic way. 
90 \BBTK provides one: \bbi (the Black Box Interpreter). 
91 \item {\bf Automatic documentation} of existing packages. 
92 \texttt{html} documentation of packages is proposed by 
93 \bbi.
94 \end{itemize}
95
96 Finally, these different components allow {\bf efficient}:
97
98 \begin{itemize}
99 \item {\bf capitalization and reuse} of existing processing units, 
100 including {\bf documentation} 
101 \item {\bf testing, prototyping} in a very simple script language
102 \item {\bf inter-operability} between atomic processings which 
103 have been written by different persons, using different libraries, etc. 
104 \end{itemize}
105
106 % ==========================================
107 \subsection{\bbtk components}
108 % ==========================================
109 \BBTK includes:
110 \begin{itemize}
111 \item A \CPP {\bf\emph{library}} - called \bbtk - which defines a framework 
112 (abstract classes) to develop black boxes and to store them into 
113 dynamic libraries, called black box \emph{packages}.
114 \item Different {\bf\emph{black box packages}}:
115 \begin{itemize}
116 \item {\bf\emph{std}}: the 'standard' package including basic useful boxes.
117 \item {\bf\emph{wx}}: basic graphical interface elements (widgets: sliders, buttons, etc. based on the \texttt{wxWidgets} library).  
118 \item {\bf\emph{itk}}: the basic image processing package, based on the \texttt{itk} library.
119 \item {\bf\emph{vtk}}: the basic image and surfaces processing package, based on the \texttt{vtk} library.
120 \item {\bf\emph{wxvtk}}: widget boxes based on the \texttt{vtk} library.
121 \item {\bf\emph{itkvtk}}: boxes to convert \texttt{itk} structures into \texttt{vtk} structures and conversally. 
122 \end{itemize}
123 \item An {\bf\emph{interpreter}}, called \bbi, which allows to 
124 load black box packages and to define and execute 
125 processing chains by connecting various black boxes of the already loaded packages.
126 \item {\bf\emph{Utilities}}:
127 \begin{itemize}
128 \item \bbfy generates the \CPP code of a black box from a 
129 description file written in \texttt{xml}.
130 %\item \bbdoc generates the html documentation of a black box package 
131 %(author, description, description of its black boxes: 
132 %author, description, inputs, outputs, and so on).
133 \item \bbCreatePackage allows to create the basic file architecture 
134 to start the development of a new black box package.
135 \end{itemize} 
136 \end{itemize}
137
138 The general architecture of \BBTK 
139 is shown in figure \ref{bb-architecture}.
140
141 \begin{figure}[!ht]
142 \caption{\label{bb-architecture}\BBTK architecture}
143 \begin{center}
144 \includegraphics[width=0.6\textwidth]{bb-architecture.png}
145 \end{center}
146 \end{figure}
147
148 % ==========================================
149 \subsection{Structure of this guide}
150 % ==========================================
151
152 This guide is divided into two parts. 
153
154 The first part (\ref{bbi}) 
155 is devoted to the use of the \emph{black box interpreter} \bbi. 
156 This is the highest level of use of the toolkit, which 
157 allows to create and execute processing chains by connecting 
158 black boxes of existing packages. 
159
160 The second part (\ref{cpp}) explains how to 
161 use the black box toolkit framework in \CPP code, 
162 typically to develop large applications which 
163 involve complex graphical interfaces.
164  
165
166 % ==========================================
167 % ==========================================
168 % ==========================================
169 % ==========================================
170 % ==========================================
171 % ==========================================
172 \vspace{0.5cm}\hrule
173 \section{The black box interpreter (bbi)}
174 \label{bbi}
175 % ==========================================
176
177 % ==========================================
178 %\subsection{Structure of this part}
179 % ==========================================
180
181 Using the black box interpreter is very simple. 
182 Everything is done with only a few commands.
183 The philosophy of this part is also very simple: 
184 it introduces the \bbi commands using examples, 
185 starting with the most simple commands.  
186 The first section of this part 
187 (\ref{bbi-getting-started})
188 is designed like a tutorial, 
189 which progressively introduces all the concepts of \bbi. 
190 We suggest you run \bbi and follow the examples, 
191 to see how it works in practice. 
192 At the end of this section, 
193 you will be able to use \bbi and write 
194 own black box processing scripts. 
195
196 After this tutorial, 
197 the section \ref{bbi-more-on} 
198 (called \emph{more on...}) 
199 goes deeper into various issues of \bbi. 
200 Read it at your convenience, 
201 either linearly to learn more about \bbi, 
202 or in random order to get an answer 
203 to a particular question. 
204
205 Finally, the section \ref{bbi-reference}
206 summarizes all the commands of \bbi, 
207 their parameters and effect. 
208 Use it as a reference.
209
210 % ==========================================
211 \subsection{Getting started}
212 \label{bbi-getting-started}
213 % ==========================================
214 \subsubsection{Creating and executing black boxes}
215 % ==========================================
216
217 To run the black box interpreter, 
218 open a console and type \texttt{bbi} 
219 or double click on the application icon.
220 You get a window which looks like the one in figure 
221 \ref{bbi-fig-bbi-gui} 
222 (the exact appearance of \bbi is system and \bbtk version dependent)
223 \footnote{If you compiled \bbtk without \wx then \bbi does not have a 
224 graphical interface but a simple prompt}.
225
226 \begin{figure}[!ht]
227 \caption{\label{bbi-fig-bbi-gui}The black box interpreter interface}
228 \begin{center}
229 \includegraphics[width=0.7\textwidth]{bbi-gui.png}
230 \end{center}
231 \end{figure}
232
233 The 'Command' tab is subdivided into two parts : 
234 one single line zone at the bottom in which you can enter your commands and 
235 one multiple line zone in which \bbi prints out the result of your commands.
236
237
238 Try typing in the input zone (in this manual, 
239 the commands entered by the user will be preceded by a prompt '(>)') :
240 \begin{verbatim}
241 > help 
242 \end{verbatim}
243
244 you get the list of the commands of the interpreter:
245 \begin{verbatim}
246 Available commands:
247  author
248  category
249  config
250  connect
251  debug
252  define
253  delete
254  description
255  endefine
256  endpackage
257  exec
258  graph
259  help
260  include
261  index
262  input
263  kind
264  load
265  message
266  new
267  newgui
268  output
269  package
270  print
271  quit
272  reset
273  set
274  unload 
275 \end{verbatim}
276
277 To get help on a particular command type \texttt{help <command-name>},
278 for example:
279 \begin{verbatim}
280 > help quit
281 \end{verbatim}
282
283 gives:
284 \begin{verbatim}
285  quit: 
286    usage: quit
287     Quits the program (during script execution it stops the complete execution)
288 \end{verbatim}
289
290 The \texttt{help} command has multiple usages. 
291 It is used to get help on almost anything in \bbi !
292 Type \texttt{'help help'} to get help on the \texttt{help} command itself:
293 \begin{verbatim}
294 > help help
295  usage: 
296          (1) help 
297          (2) help <command name> 
298          (3) help packages [all]
299          (4) help <package name> [all]
300          (5) help <black box type> 
301          (6) help <black box name>
302   Effect:
303          (1) Lists all available commands;
304          (2) Prints help on a particular command; 
305          (3) Lists the packages loaded and their black boxes.
306              Add 'all' to list adaptors; 
307          (4) Prints short help on the black boxes of a package.
308              Add 'all' to include adaptors; 
309          (5) Prints full help on a black box type; 
310          (6) Prints information on the inputs, outputs and connections of a black box instance.
311 \end{verbatim}
312
313 At start \bbi does not know any black box. 
314 If you type \texttt{'help packages'}, which is 
315 the third form of the \texttt{help} command, you get:
316 \begin{verbatim}
317 > help packages
318 user
319   workspace
320 \end{verbatim}
321
322 which means that \bbi only knows one package 
323 (library of black boxes) called \texttt{user}
324 and which contains a black box called \texttt{workspace}.
325 The \texttt{user} package is an internal package to \bbi, 
326 which stores user-defined black box types. 
327 At start, it already contains 
328 one box, called \texttt{workspace}.
329 \texttt{workspace} is a special type of black box, 
330 called complex black box, whose purpose is 
331 to store other black boxes. 
332 Any black box you create in \bbi is stored 
333 in \texttt{workspace}  
334 (this will be explained in details in sections 
335 \ref{bbi-writing-scripts} and 
336 \ref{bbi-more-on-complex-black-boxes}). 
337
338 If you type \texttt{'help workspace'}, you get:
339 \begin{verbatim}
340 > help workspace
341 Complex Black Box <user::workspace>
342  User's workspace
343  By: bbi (internal)
344  Category(s) : complex box;
345  * No inputs
346  * No outputs
347  * No boxes
348 \end{verbatim}
349
350 In the text displayed, 
351 the \texttt{user::} prepended to the name \texttt{workspace} 
352 means that the box \texttt{workspace} 
353 belongs to the \texttt{user} package. 
354 Then comes a description and three lines which 
355 tell that \texttt{workspace} does not have any input 
356 nor output nor boxes yet.
357
358 In order to let \bbi know of some black boxes, 
359 you must load another package. 
360 The \texttt{std} package is the ``standard'' package, 
361 which contains basic useful black boxes. 
362
363 To load it, type:
364 \begin{verbatim}
365 > include std
366 \end{verbatim}
367
368 Then if you type:
369 \begin{verbatim}
370 > help packages
371 \end{verbatim}
372
373 you get something like:
374 \begin{verbatim}
375 std
376   Add 
377   ConcatStrings          
378   Configuration          
379   Div   
380   ...
381   StringRelay            
382   StringSelect    
383 user
384   workspace
385
386 \end{verbatim}
387
388 Now \bbi knows the package \texttt{std} and the black boxes it provides,
389 such as the \texttt{'Add'} box, the  \texttt{'ConcatStrings'}. Remark that the 
390 content of \texttt{std} may vary from one version to another 
391 as new black boxes might be added to it. 
392 If you type:  
393 \begin{verbatim}
394 > help Add
395 \end{verbatim}
396
397 You get:
398 \begin{verbatim}
399 Black Box <std::Add>
400   Adds its inputs
401   By : laurent.guigues@creatis.insa-lyon.fr
402   Categories : atomic box;math;
403   * Inputs : 
404      'BoxExecute'     <bbtk::Void> [signal] : Any signal received by this input executes the box
405      'BoxProcessMode' <String>     []       : Sets the processing mode of the box (Pipeline | Always | Reactive)
406      'In1'            <Double>     []       : First number to add
407      'In2'            <Double>     []       : Second number to add
408   * Outputs : 
409      'BoxChange'      <bbtk::Void> [signal] : Signals modifications of the box
410      'Out'            <Double>     []       : Result
411 \end{verbatim}
412
413 Like previously, 
414 the \texttt{std::} prepended to the name \texttt{Add} 
415 means that the box \texttt{Add} 
416 belongs to the \texttt{std} package. 
417 Then comes a description 
418 (the one which was provided by the author of the box), 
419 the author(s) of the box (usually e-mail adress(es)) and 
420 the categories to which the box belong. 
421 Finally comes the lists of inputs and outputs of the box.
422 For each input or output, \bbi provides 
423 its \emph{name} (between quotes, e.g. \texttt{'ProcessMode'}), 
424 its \emph{type} (between \texttt{<>}, e.g. \texttt{<Int>})
425 and a description.    
426 Remark that the box \texttt{Add} is not a 'complex' black box 
427 but an 'atomic' box, hence its help does not 
428 mention any information concerning possible internal boxes.
429
430 You can create an \emph{instance} of an \texttt{Add} box by 
431 the command \texttt{new}:
432 \begin{verbatim}
433 > new Add a
434 \end{verbatim}
435
436 The \texttt{'a'} at the end is the \emph{name} of the instance, 
437 which will be used to reference it later. 
438 It is important to distinguish a box \emph{types} 
439 and an \emph{instance} of a box type. 
440 The \texttt{Add} box of the package \texttt{std} is actually 
441 a \emph{box type} , like \texttt{int} is a data type 
442 in \texttt{C} langage. The \texttt{new} command allows to create 
443 an instance of a box type, exactly like \texttt{int i;} in 
444 a \texttt{C} code declares a variable of type \texttt{int} whose 
445 name is \texttt{i}. 
446 Of course, like in \texttt{C} Language, you can declare multiple boxes of the 
447 same type in \bbi. 
448
449 After the creation of the box \texttt{a}, type:
450 \begin{verbatim}
451 > help workspace
452 \end{verbatim}
453
454 you get:
455 \begin{verbatim}
456 Complex Black Box <user::workspace>
457  User's workspace
458  By: bbi (internal)
459  Category(s) : complex box;
460  * No inputs
461  * No outputs
462  * Boxes: 
463     'a' <std::Add>
464 \end{verbatim}
465
466 which means that \bbi workspace now contains a black box named \texttt{a},
467 of type \texttt{std::Add}.
468
469 Now look back at the help on \texttt{Add} boxes: 
470 you can see that this type of box has two inputs, 
471 with name \texttt{In1} and \texttt{In2},
472 and an output, with name \texttt{Out}.
473
474 You can set the input \texttt{In1} 
475 of the \texttt{Add} box \texttt{a} to the value $1$ 
476 by the command:
477 \begin{verbatim}
478 > set a.In1 1 
479 \end{verbatim}
480
481 Similarly, setting the input \texttt{In2} of \texttt{a} to the value $2$
482 is done with:
483 \begin{verbatim}
484 > set a.In2 2
485 \end{verbatim}
486  
487 And you print the output \texttt{Out} of the box \texttt{a} with:
488 \begin{verbatim}
489 > print "result=$a.Out$"
490 result=3
491 \end{verbatim}
492
493 In the string passed to the \texttt{print} command, 
494 each substring enclosed between a couple of \$ is considered 
495 as the name of an output of a box. 
496 To process this special substrings, \bbi does:
497 \begin{enumerate}
498 \item Processes the box if needed (see below)
499 \item Converts the output of the box to a string if possible 
500 (see below)
501 \item Substitutes the result in the string to print
502 \item postpone an implicit 'new line' character to the string
503 \end{enumerate}
504
505 Box processing is needed if:
506 \begin{itemize}
507 \item at least input has changed since last processing or
508 \item the input \texttt{'BoxProcessMode'} of the box is set to 
509 \texttt{'Always'}, which forces box reprocessing. 
510 \end{itemize}
511
512 Note that all boxes have the input \texttt{'BoxProcessMode'}. 
513
514 Another way to process the box \texttt{a} is to issue the command:
515 \begin{verbatim}
516 > exec a
517 \end{verbatim}
518
519 however this command does not display anything (except if the 
520 box itself displays something in its processing).
521 It just processes the box if needed. 
522 This command is used to execute boxes that do not have any output,  
523 such as boxes that write something to a file or, display a 
524 graphical interface, and so on. 
525
526 To exit \bbi, type:
527 \begin{verbatim}
528 > quit
529 Good bye !
530 \end{verbatim}
531
532 % ==========================================
533 \hrule
534 \paragraph{Summary}
535 %\hrule
536 \begin{itemize}
537 \item The \texttt{include} command allows to load a package.
538 \item \texttt{help} gives help on:
539 \begin{itemize} 
540 \item Available commands if you just type \texttt{help}.
541 \item A particular command if you type \texttt{help <command-name>}.
542 \item All available packages and their boxes (without description) if you type \texttt{help packages}.
543 \item A particular package and its boxes (with brief description) if you type \texttt{help <package-name>}.
544 \item A particular black box type (with full description) if you type \texttt{help <box-type-name>}. In particular, \texttt{help workspace} displays information on the content of the \texttt{'workspace'} black box, which stores the boxes created by the user (by \texttt{new}).
545 \end{itemize}
546 %\item \texttt{list} displays the list of black box instances created so far (by \texttt{new}).
547 \item \texttt{new} creates an instance of a black box. 
548 \item \texttt{set} sets the value of an input of a black box. 
549 \item In all \bbi, to reference the input called \texttt{i} 
550 of a black box called \texttt{b} you must type \texttt{'b.i'}. 
551 The same syntax holds for outputs.
552 \item \texttt{print} prints a string, substituting each substring of the form \$b.o\$ by the value of the output \texttt{o} of the black box \texttt{b}. Note that an
553 implicit trailing 'new line character' is added at the final string.
554 \item \texttt{exec} runs the process of a box if needed. 
555 \item \texttt{quit} quits \bbi.
556 \end{itemize}
557 \hrule
558 % ==========================================
559
560 % ==========================================
561 \subsubsection{Connecting black boxes}
562 \label{bbi-connecting-black-boxes}
563 % ==========================================
564
565 LG : THE GUIDE IS UP TO DATE UNTIL HERE
566
567 \BBTK allows to create 
568 and execute processing chains, 
569 also called \emph{pipelines}, 
570 by connecting black boxes.
571 This section explains how to do it with examples. 
572 Read section \ref{bbi-more-on-pipeline-processing} to get 
573 more information on pipeline processing.
574
575 First start \bbi and load the package \texttt{std}:
576 \begin{verbatim}
577 > include std
578 \end{verbatim}
579
580 Assume you want to compute $1+2+3$. You can do it by 
581 chaining two \texttt{Add} boxes, as shown in figure 
582 \ref{bbi-fig-connecting-black-boxes-1}. 
583
584 \begin{figure}[!ht]
585 \caption{\label{bbi-fig-connecting-black-boxes-1}
586 A simple pipeline which adds 3 numbers}
587 \begin{center}
588 \includegraphics[width=0.5\textwidth]{1plus2plus3.png}
589 \end{center}
590 \end{figure}
591
592 The \bbi instructions to create and execute this pipeline are:
593 \begin{verbatim}
594 > new Add a
595 > new Add b
596 > connect a.Out b.In1
597 > set a.In1 1
598 > set a.In2 2
599 > set b.In2 3
600 > print $b.Out$
601 6
602 \end{verbatim}
603
604 The first three commands build the pipeline, 
605 the next three set its inputs and the last one 
606 executes it and prints its output.
607  
608 The command \texttt{'connect a.Out b.In1'} ``plugs'' the output 
609 \texttt{Out} of the box \texttt{a} into the input \texttt{In1} of the 
610 box \texttt{b}. 
611 Once the boxes connected, the processing of the two boxes are chained:
612 getting the output of \texttt{b} requires getting its inputs, 
613 hence getting the output of \texttt{a} which is connected to it. 
614 This pipeline mechanism can recurse into arbitrary long 
615 chains of boxes (see \ref{bbi-more-on-pipeline-processing} 
616 for details).
617
618 Of course, to be able to connect two boxes, 
619 the output and the input must be compatibles. 
620 You can always connect an output to an input of the \emph{same} type, 
621 but you can do more, thanks to particular black boxes called {\bf adaptors}.
622
623 An adaptor is a black box which has at least one input, called \texttt{In}, 
624 and at least one ouput called \texttt{Out} and whose role is to convert 
625 a data of the type of \texttt{In} 
626 into a data of the type of \texttt{Out} (other inputs or outputs may serve 
627 to parameter the adaptor or retreive other usefull information).
628
629 In \bbi, if you type:
630 \begin{verbatim}
631 > load std
632 > help std all
633 \end{verbatim}
634 you get:
635 \begin{verbatim}
636  Package std v1.0.0 - laurent.guigues@creatis.insa-lyon.fr
637  Basic useful black boxes
638  Black boxes: 
639    Add                                    : Adds its inputs
640    Cast<double,float>                [DA] : Casts a double into a float
641    Cast<double,int>                  [DA] : Casts a double into a int
642     ... 
643    Convert<unsigned int,string>      [DA] : Converts a unsigned int into a s...
644    Convert<unsigned short,string>    [DA] : Converts a unsigned short into a...
645    Print                                  : Prints its input to standard out...
646 >
647 \end{verbatim}
648
649 The \texttt{Cast<?,?>} and \texttt{Convert<?,?>} boxes are \emph{default adaptors}, which is signaled by the tag \texttt{[DA]} before their descriptions.
650
651 Once you have loaded the package \texttt{std}, you can 
652 plug an output of type \texttt{char} into an input of type \texttt{double}. 
653 When \bbi encounters the \texttt{connect} command, 
654 it looks for an adequate \emph{adaptor} in the  loaded packages. 
655 In our case, as the package \texttt{std} provides the 
656 \texttt{Cast<char,double>} adaptor, \bbi automatically creates an 
657 instance of this adaptor and place it \emph{between} 
658 the output and the input you want to connect 
659 (however this adaptor is hidden to you, 
660 it is embedded into the created connection and does not appear 
661 as an existing black box). 
662 When the pipeline is processed the 
663 adaptor converts the output data into the required input type, 
664 in a totally transparent way.
665 In our example, the \texttt{Cast<char,double>} adaptor 
666 would simply cast the value of the \texttt{char} into a \texttt{double}, 
667 however arbitrarily complex type conversion can be done.
668
669 Question: 
670 if two adaptors with the same input and output types exist 
671 in the packages loaded, 
672 which one is chosen by \bbi at connection ? 
673 -> Role of default adaptors
674
675 Note that the \texttt{set} and \texttt{print} commands of \bbi 
676 work with adaptors from \texttt{string} to the type of the input to set 
677 or from the type of the output to print to \texttt{string}. 
678 Hence in order to \texttt{set} or \texttt{print} values the adequate 
679 adaptors must be available in the packages currently loaded.
680  
681 % ==========================================
682 \hrule
683 \paragraph{Summary}
684 %\hrule
685 \begin{itemize}
686 \item The \texttt{connect} command allows to connect two black boxes
687 \item You can connect two black boxes if (and only if): 
688 \begin{itemize}
689 \item The output and the input are of the same type, or
690 \item There is an adaptor black box in the packages loaded which 
691 converts data of the output type into data of the input type
692 \end{itemize}
693 \item \texttt{help <package name>} does not display the adaptors of the package. To see them use: \texttt{help <package name> all}.
694 including adaptors
695 \end{itemize}
696 \hrule
697 % ==========================================
698
699 % ==========================================
700 \subsubsection{Creating complex black boxes}
701 \label{bbi-complex-black-boxes}
702 % ==========================================
703
704 Remember the pipeline of figure 
705 \ref{bbi-fig-connecting-black-boxes-1}, which 
706 computed the sum of three doubles ?
707 You can view it as a whole and define 
708 a new black box type, which will be a \emph{complex black box}, 
709 having three inputs and one output, 
710 as shown in figure \ref{bbi-fig-complex-black-box-1}.
711
712 \begin{figure}[!ht]
713 \caption{\label{bbi-fig-complex-black-box-1}
714 Creating the complex black box \texttt{Add3}}
715 \begin{center}
716 \includegraphics[width=0.5\textwidth]{Add3.png}
717 \end{center}
718 \end{figure}
719
720 The \bbi commands to define this complex black box are 
721 the following:
722
723 \begin{verbatim}
724 > load std
725 >
726 > define Add3
727 >
728 > new Add a
729 > new Add b
730 > connect a.Out b.In1
731 >
732 > author "myself"
733 > description "adds 3 doubles"
734 > input x a.In1 "first double to add"
735 > input y a.In2 "second double to add"
736 > input z b.In2 "third double to add"
737 > output result b.Out "output"
738 >
739 > endefine
740 \end{verbatim}
741
742 Explainations:
743
744 As we will use \texttt{Add} boxes, we need to load the package \texttt{std}, which is done in first line.
745
746 The command \texttt{define} then starts the definition 
747 of the complex box type, which will be called \texttt{Add3}. 
748
749 The next three lines define the pipeline, 
750 exactly in the same way than outside a complex box definition. 
751
752 The commands \texttt{author}, \texttt{description}, \texttt{input} 
753 and \texttt{output} are commands specific to complex boxes definition:
754
755 \texttt{author} and \texttt{description} are used for the documentation 
756 of the new box. You can provide multiple \texttt{author} or 
757 \texttt{description} commands, the arguments of the commands will 
758 be concatenated to produce the final author and description strings.
759
760 \texttt{input} and \texttt{output} are used to define the inputs and outputs 
761 of the new complex box. 
762 Their syntax is the same: for each new input/output you need to say 
763 to which internal input/output it corresponds and to provide 
764 a help string documenting the input/output.
765 In our example, we define that the box \texttt{Add3} has 
766 three inputs: \texttt{x}, \texttt{y} and \texttt{z}. 
767 The input \texttt{x} corresponds to the input \texttt{In1} of the 
768 internal box \texttt{a}. 
769 In the same way, the external input \texttt{y} 
770 corresponds to the internal input \texttt{a.In2}, and 
771 the external input \texttt{In3} to \texttt{b.In2}. 
772 The only output of the new box is called \texttt{result}
773 and corresponds to \texttt{b.Out}. 
774 The figure \ref{bbi-fig-complex-black-box-1} 
775 illustrates the external to internal 
776 input/output correspondence.
777
778 Finally, the \texttt{endefine} command ends the definition of the 
779 new box type.
780
781 After this definition, if you ask for help 
782 on packages, you get:
783 \begin{verbatim}
784 > help packages
785 std
786   Add
787   ...
788 user
789   Add3
790   workspace
791 \end{verbatim}
792
793 The \texttt{user} package now contains a new black box type, called 
794 \texttt{Add3}. If you ask for help on this type of box, you get:
795 \begin{verbatim}
796 > help Add3
797 Complex Black Box <user::Add3>
798  adds 3 doubles
799  By: myself
800  * Inputs: 
801     'x'      <double>: first double to add
802     'y'      <double>: second double to add
803     'z'      <double>: third double to add
804  * Outputs: 
805     'result' <double>: output
806  * Boxes: 
807     'a' <std::Add>
808     'b' <std::Add>
809 \end{verbatim}
810
811 and you can use it like any other box, for example type:
812
813 \begin{verbatim}
814 > new Add3 a
815 > set a.x 1
816 > set a.y 2
817 > set a.z 3
818 > print $a.result$
819 6
820 \end{verbatim}
821
822
823 % ==========================================
824 \hrule
825 \paragraph{Summary}
826 %\hrule
827 \begin{itemize}
828 \item The \texttt{define/endefine} commands allows to define complex black box types, i.e. types of black boxes made up of other black boxes. 
829 Inside a \texttt{define/endefine} block:
830 \begin{itemize}
831 \item The \texttt{author} and \texttt{description} commands allow to document the new type of box
832 \item The \texttt{input} and \texttt{output} commands allow to define the inputs and outputs of the new type of box, that is to which inputs and outputs 
833 of internal boxes they correspond.  
834 \end{itemize}
835 \end{itemize}
836 \hrule
837 % ==========================================
838
839 % ==========================================
840 \subsubsection{Writing scripts}
841 \label{bbi-writing-scripts}
842 % ==========================================
843
844 Once you have defined a new type of complex box, you 
845 may like to reuse it. To do this, you can simply 
846 write the \bbi commands defining the new box 
847 into a text file and afterwards include that file in \bbi. 
848 Doing this, you start writing \bbi scripts.
849 The conventionnal extension for such scripts is \texttt{bbs} 
850 (black box script).
851
852 For example, the \texttt{Add3} complex box we previously worked on 
853 can be defined in the \texttt{Add3.bbs} file:
854
855 \begin{file}{Add3.bbs}
856 \begin{verbatim}
857 # Defines the Add3 black box which adds 3 doubles 
858 load std
859
860 define Add3
861   # I am the author 
862   author "myself"
863   description "adds 3 doubles"
864   # Pipeline creation
865   new Add a
866   new Add b
867   connect a.Out b.In1
868   # Inputs definition
869   input x a.In1 "first double to add
870   input y a.In2 "second double to add
871   input z b.In2 "third double to add"
872   # Output definition
873   output result b.Out "output"
874 endefine
875 \end{verbatim}
876 \end{file}
877
878 Lines starting with a \texttt{\#} character are ignored, they 
879 are considered as comments by \bbi.
880 To use this file in \bbi, use the \texttt{include} command:
881
882 \begin{verbatim}
883 > include Add3.bbs
884 > help Add3
885 Complex Black Box <user::Add3>
886  adds 3 doubles
887  By: myself
888  * Inputs: 
889     'x'      <double>: first double to add
890     'y'      <double>: second double to add
891     'z'      <double>: third double to add
892  * Outputs: 
893     'result' <double>: output
894  * Boxes: 
895     'a' <std::Add>
896     'b' <std::Add>
897 >
898 and so on ...
899 \end{verbatim}
900
901 If the file has the \texttt{bbs} extension, you can ommit it and just type:
902 \begin{verbatim}
903 > include Add3
904 \end{verbatim}
905
906 Of course, you can include script files in other script files, 
907 like in the following example:
908
909 \begin{file}{Add4.bbs}
910 \begin{verbatim}
911 # Defines the Add4 black box which adds 4 doubles 
912 include Add3
913
914 define Add4
915   author "myself"
916   description "adds 4 doubles"
917   new Add3 a
918   new Add b
919   connect a.Out b.In1
920   input In1 a.In1 "first double to add
921   input In2 a.In2 "second double to add
922   input In3 a.In3 "third double to add"
923   input In4 b.In2 "fourth double to add"
924   output Out b.Out "output"
925 endefine
926 \end{verbatim}
927 \end{file}
928
929 TO DO: 
930
931 - naming conventions:  one cbb per file with the same name
932 - search paths 
933
934 % ==========================================
935 \hrule
936 \paragraph{Summary}
937 %\hrule
938 \begin{itemize}
939 \item The \texttt{include} command allows to include a script file in \bbi.
940 \item Lines starting with a \texttt{\#} are treated as comments in \bbi scripts.
941 \end{itemize}
942 \hrule
943 % ==========================================
944
945 % ==========================================
946 \subsubsection{Creating command line applications}
947 \label{bbi-command-line-app}
948 % ==========================================
949
950 Now that you now how to create complex black boxes 
951 (with \texttt{define/endefine}), think 
952 back to the \texttt{workspace} object. 
953 Remember that it is also 
954 a \texttt{complex black box}. 
955 In fact what you are doing when you type \bbi commands 
956 outside a \texttt{define/endefine} block 
957 is to progressively define the \texttt{workspace} 
958 complex black box.
959 You can think of it like if at start 
960 \bbi was issuing a command \texttt{'define workspace'} 
961 and then letting you define the interior of the box 
962 \texttt{workspace}.
963
964 Remember that the command \texttt{inputs} 
965 allows to define an input of a complex box. 
966 Now, if you use the command \texttt{input} 
967 outside a \texttt{define/endefine} block then 
968 it defines an input of the \texttt{workspace} box, 
969 that is an input of the \emph{main program}. 
970 This input will then be connected to the 
971 parameters that the user passes to the command line.
972
973 For example, consider the script: 
974
975 \begin{file}{add.bbs}
976 \begin{verbatim}
977 load std
978 new Add a
979 input x a.In1 "first number to add"
980 input y a.In2 "second number to add"
981 print "x+y=$a.Out$"
982 \end{verbatim}
983 \end{file}
984
985 The third and fourth lines define two inputs \texttt{x} 
986 and \texttt{y}. When you execute this script, 
987 you can pass these two arguments on the command line, 
988 like this:
989
990 \begin{verbatim}
991 > bbi add x=1 y=1
992 x+y=2
993 \end{verbatim}
994
995 You can also invoke \bbi the option \texttt{-h}, 
996 which gives help on the \texttt{workspace} box:
997
998 \begin{verbatim}
999 > bbi add -h
1000  User's workspace
1001  By: bbi (internal)
1002  * Inputs: 
1003     'x' <double>: first number to add
1004     'y' <double>: second number to add
1005 \end{verbatim}
1006
1007 To get a better help, use the \texttt{description} 
1008 and \texttt{author} commands:
1009
1010 \begin{file}{add.bbs}
1011 \begin{verbatim}
1012 description "Adds two numbers"
1013 author "foo@bar.com"
1014 load std
1015 new Add a
1016 input x a.In1 "first number to add"
1017 input y a.In2 "second number to add"
1018 print "x+y=$a.Out$"
1019 \end{verbatim}
1020 \end{file}
1021
1022 Now if you ask for help on the \texttt{add} script, you get:
1023
1024 \begin{verbatim}
1025 > bbi add -h
1026  Adds two numbers
1027  By: foo@bar.com
1028  * Inputs: 
1029     'x' <double>: first number to add
1030     'y' <double>: second number to add
1031 \end{verbatim}
1032
1033 Rather than getting the inputs of a script 
1034 from the command line, you can ask \bbi to 
1035 prompt the user for the values, using the \texttt{-t}
1036 commutator:
1037
1038 \begin{verbatim}
1039 > bbi add -t
1040 x=[the program waits for user answer]2
1041 y=[the program waits for user answer]5
1042 x+y=7
1043 \end{verbatim}
1044
1045 If \bbi is compiled in graphical mode (with \wx), 
1046 you can also use the \texttt{-g} commutator. 
1047 \bbi then prompts the user in graphical mode, 
1048 displaying a dialog box for each input,
1049 like in fig. \ref{bb-input-dialog-box}.
1050
1051 \begin{figure}[!ht]
1052 \caption{\label{bb-input-dialog-box}Input dialog box}
1053 \begin{center}
1054 \includegraphics[width=0.6\textwidth]{enter-the-value-of-x.png}
1055 \end{center}
1056 \end{figure}
1057
1058 % ==========================================
1059 \hrule
1060 \paragraph{Summary}
1061 %\hrule
1062 \begin{itemize}
1063 \item The \texttt{input}, \texttt{description} and \texttt{author} commands,
1064 when they are used outside a \texttt{define/endefine} block allow 
1065 to define the inputs, description and author of the main program.
1066 \item Inputs of the main program can be passed on the command line 
1067 using the syntax \texttt{<input-name>=<value>}. 
1068 No white space is allowed, if the value or the input name 
1069 contains white spaces, enclose them 
1070 between double quotes, e.g. \texttt{"parameter with white spaces = gnu's not unix"}.
1071 \item The \texttt{-h} option of \bbi prints help on the main program.
1072 \item The \texttt{-t} option of \bbi orders the program to prompt for its inputs in text mode.
1073 \item The \texttt{-g} option of \bbi orders the program to prompt for its inputs in graphical mode.
1074 \end{itemize}
1075 \hrule
1076 % ==========================================
1077
1078 % ==========================================
1079 \subsubsection{Using graphical interface boxes (widget boxes)}
1080 \label{bbi-widget}
1081 % ==========================================
1082
1083 If \bbi is compiled in graphical mode 
1084 (option \texttt{BUILD\_bbi\_GRAPHICAL} of \cmake, requires \wx),
1085 then you can use special black boxes which are 
1086 graphical interface components (widgets). 
1087 Basic components are provided in the package \texttt{wx}, 
1088 such as buttons, sliders, file open/save dialogs, etc.
1089
1090 As first example, type the following commands in \bbi:
1091 \begin{verbatim}
1092 > load wx 
1093 > new TextCtrl t
1094 > print $t.Out$\n
1095 \end{verbatim}
1096
1097 When you type \texttt{enter} after the last line, 
1098 a window pops up in which you can entrer a text.
1099 When you close the window, the text you entered is printed by 
1100 the \texttt{print} command.
1101
1102 Type \texttt{help wx}, you get something like:
1103 \begin{verbatim}
1104 Package wx v1.0.0- info-dev@creatis.insa-lyon.fr
1105  Basic graphical interface elements (slider, button ...) based on wxWidgets
1106  Black boxes: 
1107    Button               : Button that gives a string
1108    ColourSelectorButton : 
1109    ColourSelector       : Colour Selector widget (wxColourDialog)
1110    CommandButton        :
1111    DirectorySelector    :
1112    FileSelector         : FileDialog widget (wxFileDialog)
1113    InputText            : TextCtrl widget (wxTextCtrl)
1114    LayoutLine           : Sizer widget (wxSizer)
1115    LayoutSplit          : Split widget (wxSplitterWindow)
1116    NoteBook             :
1117    OutputText           : wxWidget Static text
1118    RadioButton          : RadioButton group widget (wxRadioButton) 0-9 entries
1119    Slider               : Slider widget (wxSlider)
1120
1121 \end{verbatim}
1122
1123 You can reproduce the same experiment as above using a 
1124 \texttt{Slider} or a \texttt{FileDialog} rather than a \texttt{TextCtrl}.
1125 See the files \texttt{test*.bbs} in the \texttt{scripts/test} directory.
1126
1127 There are two kind of widgets: ``terminal'' widgets and ``container'' widgets.
1128 The \texttt{TextCtrl}, \texttt{FileDialog} or \texttt{Slider} widgets 
1129 are ``terminal'' widgets. 
1130 ``container'' widgets are of another kind: they are made to 
1131 contain other widgets in order to build larger dialog boxes. 
1132 For example, the \texttt{Split} widget is a container which 
1133 ``splits'' horizontally a window into two parts, 
1134 each part including another widget. 
1135 The size of the two parts can be adjusted by the user thanks 
1136 to a ``handle''.
1137
1138 The script \texttt{scripts/test/testSplit.bbs} demonstrate its use. 
1139 Run it: it displays a window with two sliders. 
1140 Move the sliders and close the window. 
1141 The final positions of the sliders are printed out. 
1142 Now edit the file to see how this is done:
1143
1144 \begin{file}{scripts/test/testSplit.bbs}
1145 \begin{verbatim}
1146 load std
1147 load wx
1148
1149 new Slider s1
1150 new Slider s2
1151
1152 new Split s
1153 connect s.Child s1.Parent
1154 connect s.Child s2.Parent
1155
1156 print s1=$s1.Out$\\n
1157 print s2=$s2.Out$\\n
1158 \end{verbatim}
1159 \end{file}
1160
1161 First, the two sliders \texttt{s1} and \texttt{s2} are created.
1162 A \texttt{Split} box \texttt{s} is also created. 
1163 The \texttt{connect} commands then ``includes'' the sliders in the 
1164 split ``container''. 
1165 The input \texttt{Parent} is common to all widget boxes: 
1166 every widget can be inserted into another widget. 
1167 The output \texttt{Child} is specific of \emph{container} 
1168 widgets 
1169 (in \bbi type \texttt{help Slider}: 
1170 you will see the input \texttt{Parent}; 
1171 type \texttt{help Split}: 
1172 you will see the input \texttt{Parent} 
1173 and the output \texttt{Child}). 
1174 When you connect the \texttt{Child} output of a container 
1175 to the \texttt{Parent} input of a widget, 
1176 you order to include the widget in the container.
1177 Of course, the order of connection is important. 
1178 In our case, the slider \texttt{s1} is included first, 
1179 then the slider \texttt{s2}: \texttt{s1} will be placed 
1180 on top of \texttt{s2} (the \texttt{Split} box is 
1181 implemented that way, but this is arbitrary choice).
1182
1183 For the moment, there are only \emph{two} container widgets in the \texttt{wx} package: 
1184 the \texttt{Split} widget we just described and the \texttt{Sizer} 
1185 widget, which can have multiple children and 
1186 divides its window into as much parts as children, 
1187 each part of equal size. 
1188 The orientation of the sizer can be changed by the input \texttt{Orientation}.
1189 See the example \texttt{test/testSizer.bbs}.
1190 With only those two containers you can already create 
1191 complex dialog boxes (of course containers can be nested, which 
1192 leads to tree-like structures of widgets). 
1193 See the script \texttt{test/testSizerSplit.bbs} for an example.
1194
1195 One word about a special widget in the package \texttt{wx}: 
1196 the \texttt{Button}... to be continued.
1197
1198
1199 TO DO: 
1200 \begin{enumerate}
1201 \item Make a tour of ``complex'' widgets of wxvtk 
1202 \item Explain the role of ProcessMode to update widgets
1203 \item Explain the creation of complex widgets (containers, contained...)
1204 \item Explain the ``control'' mechanism in bbi (switch exec commands, e.g. Button)
1205 \end{enumerate}
1206
1207
1208 % ==========================================
1209 \subsection{More on ...}
1210 \label{bbi-more-on}
1211 % ==========================================
1212
1213 % ==========================================
1214 \subsubsection{Black box packages}
1215 \label{bbi-more-on-packages}
1216 % ==========================================
1217
1218 % ==========================================
1219 \subsubsection{Pipeline processing}
1220 \label{bbi-more-on-pipeline-processing}
1221 % ==========================================
1222
1223 % ==========================================
1224 \subsubsection{Complex black boxes}
1225 \label{bbi-more-on-complex-black-boxes}
1226
1227 %\subsubsection{Advanced issues}
1228 %\paragraph{Reducing the number of inputs of a box}
1229
1230 % ==========================================
1231 \subsubsection{Errors}
1232 \label{bbi-more-on-errors}
1233
1234 % ==========================================
1235 \subsubsection{\bbtk configuration file and search pathes}
1236 \label{bbi-more-on-configuration}
1237
1238 At start, \bbi tries to open an \texttt{xml} 
1239 configuration file named \texttt{bbtk\_config.xml}. 
1240 The search order is 
1241 \begin{enumerate}
1242 \item The current directory
1243 \item The subdir \texttt{.bbtk} of the user's home directory. 
1244 \begin{itemize} 
1245 \item On \texttt{Unix}, the home directory is the
1246 one stored by the environnement variable \texttt{HOME}, 
1247 typically \texttt{/home/username}.
1248 \item On \texttt{Windows}, the home directory is 
1249 the user's profile directory stored by the environnement 
1250 variable \texttt{USERPROFILE}, 
1251 typically \texttt{C:\\...}.
1252 \end{itemize}
1253 \item If none of these two pathes contains the file then it creates 
1254 a new one in the \texttt{.bbtk} directory. 
1255 \end{enumerate}
1256
1257 Once created, you can edit the \texttt{bbtk\_config.xml} file located 
1258 in your \texttt{.bbtk} directory. It contains:
1259
1260 \begin{file}{bbtk\_config.xml}
1261 \begin{verbatim}
1262 <?xml version="1.0" encoding="iso-8859-1"?>
1263 <config>
1264   <bbtk_url> http://www.creatis.insa-lyon.fr/software/bbtk </bbtk_url>
1265   <bbs_path> </bbs_path>     
1266   <package_path> </package_path> 
1267   <data_path> </data_path>
1268 </config>
1269 \end{verbatim}
1270 \end{file}
1271
1272 You can add pathes to 
1273 \begin{itemize}
1274 \item A custom folder in which to search for \texttt{.bbs} scripts (\texttt{include} command of \bbi) by adding an \texttt{xml} tag: 
1275 \texttt{<bbs\_path>complete\_path\_to\_folder<\/bbs\_path>}.
1276 \item A custom folder in which to search for packages (\texttt{load} command of \bbi) by adding an \texttt{xml} tag: 
1277 \texttt{<package\_path>complete\_path\_to\_folder<\/package\_path>}.
1278 \end{itemize}
1279
1280 % ==========================================
1281 \subsection{Language reference}
1282 \label{bbi-reference}
1283 % ==========================================
1284
1285
1286
1287
1288
1289 % ==========================================
1290 \begin{table}[!ht]
1291 \caption{\label{bbi-reference-box}
1292 \bbi pipeline creation and execution related commands.}
1293 \small
1294 \begin{tabular}{|lcm{6cm}|}
1295 \hline
1296 Command & Parameters & Effect \\ \hline
1297
1298 \texttt{new} & \texttt{<boxtype>} \texttt{<box-name>}& 
1299 Creates a box of type \texttt{boxtype} and name  
1300 \texttt{box-name}.
1301 \\ \hline
1302
1303 \texttt{delete} & \texttt{<box-name>} & 
1304 Destroys the box named \texttt{box-name}.
1305 \\ \hline 
1306
1307 \texttt{connect} & \texttt{<box1.output>} \texttt{<box2.input>} & 
1308 Connects the output 
1309 \texttt{output} of the box named \texttt{box1} 
1310 to the input \texttt{input} of the box named \texttt{box2} \\ \hline 
1311
1312 \texttt{set} & \texttt{<box.input>} \texttt{<value>} &
1313 Sets the input \texttt{input} of 
1314 the box named \texttt{box} to the value \texttt{value}.
1315 There must exist an \texttt{adaptor} 
1316 in the packages loaded which converts a \texttt{std::string} 
1317 to the type of the input \texttt{input}.
1318  \\ \hline 
1319
1320 \texttt{print} & \texttt{<string>} & 
1321 Prints the string after substituting each token of the form \texttt{\$box.output\$} by the adaptation to string of the value of the 
1322 output \texttt{output} of the box named \texttt{box}. 
1323 There must exist an \texttt{adaptor} 
1324 in the packages loaded which converts 
1325 the type of the output \texttt{output}
1326 to a \texttt{std::string}.
1327 \\ \hline 
1328
1329 \texttt{exec} & \texttt{<box-name>} & 
1330 Executes the box named \texttt{box-name}.
1331 If needed the boxes 
1332 connected to its inputs 
1333 are also processed recursively (pipeline processing).\\ \hline 
1334 \end{tabular}
1335 \end{table}
1336 % ==========================================
1337
1338
1339
1340 % ==========================================
1341 \begin{table}[!ht]
1342 \caption{\label{bbi-reference-interpreter}\bbi intepreter related commands.}
1343 \small
1344 \begin{tabular}{|lcm{6cm}|}
1345 \hline
1346 Command & Parameters & Effect \\ \hline
1347
1348
1349 \texttt{help} & - & 
1350 Prints help on available commands \\ \hline 
1351
1352 & \texttt{<command-name>} & 
1353 Prints help on the command \texttt{command-name} \\ \hline 
1354
1355 & \texttt{packages} & 
1356 Prints help on available packages and their box types 
1357 (without description)\\ \hline 
1358
1359 & \texttt{<package-name>} & 
1360 Prints help on the package \texttt{package-name} and its boxes 
1361 (with brief description). 
1362 The package must have been previously loaded
1363 \\ \hline 
1364
1365 & \texttt{<box-type>} & 
1366 Prints help (with full description) on the type of box 
1367 \texttt{box-type}. 
1368 The box type must belong to a package which has been previously loaded
1369 \\ \hline 
1370
1371 \texttt{include} & \texttt{<file-name>} & 
1372 Includes and executes the content of the file named \texttt{file-name} 
1373 exactly like if you were typing its content at the place were the 
1374 \texttt{include} command is.
1375 \\ \hline 
1376
1377 \texttt{load} & \texttt{<package-name>} & 
1378 Loads the package \texttt{package-name}\\ \hline 
1379
1380 \texttt{unload} & \texttt{<package-name>}& 
1381 Unloads the package \texttt{package-name}. 
1382 The package must have been previously loaded. 
1383 No box of a type defined in this package must still exist.
1384 \\ \hline 
1385
1386 \texttt{message} & \texttt{<category>} \texttt{<level>} & 
1387 Sets the level of verbosity of \bbi for the category of messages 
1388 \texttt{category} to \texttt{level}.
1389 %See \ref{verbosity}.
1390 \\ \hline 
1391
1392 \texttt{config} & - & Displays the Configuration parameters\\ \hline 
1393
1394 \texttt{reset} & - & Deletes all boxes and unloads all packages so 
1395 that \bbi gets back to its initial state \\ \hline 
1396
1397 \texttt{quit} & - & Exits the interpreter\\ \hline 
1398
1399 \end{tabular}
1400 \end{table}
1401 % ==========================================
1402
1403
1404
1405
1406
1407 % ==========================================
1408 \begin{table}[!ht]
1409 \caption{\label{bbi-reference-complex-box}
1410 \bbi complex black box definition related commands.}
1411 \small
1412 \begin{tabular}{|lcm{6cm}|}
1413 \hline
1414 Command & Parameters & Effect \\ \hline
1415
1416
1417 \texttt{define} & \texttt{<box-type>} & 
1418 Starts the definition of a complex black box of type  
1419 \texttt{box-type}\\ \hline 
1420
1421 \texttt{endefine} & - & 
1422 Ends the definition of a complex black box type\\ \hline 
1423
1424
1425 \texttt{author} & \texttt{<string>} & 
1426 Sets the author(s) of the complex black box currently being defined \\ \hline 
1427
1428 \texttt{description} & \texttt{<string>} & 
1429 Sets the description of the complex black box currently being defined 
1430 \\ \hline 
1431
1432
1433 \texttt{input} & \texttt{<name>} \texttt{<box.input>} \texttt{<help>} & 
1434 Defines a new input for the current complex black box, 
1435 named \texttt{name}. 
1436 It is defined as corresponding to 
1437 the input \texttt{input} of the box \texttt{box}. 
1438 \texttt{<help>} is the help string for the new input.
1439 The box \texttt{box} must already have been created in the complex box 
1440 and of course have an input named \texttt{input}.
1441 \\ \hline 
1442
1443
1444 \texttt{output} & \texttt{<name>} \texttt{<box.output>} \texttt{<help>} & 
1445 Defines a new output for the current complex black box, 
1446 named \texttt{name}. 
1447 It is defined as corresponding to 
1448 the output \texttt{output} of the box \texttt{box}. 
1449 \texttt{<help>} is the help string for the new output.
1450 The box \texttt{box} must already have been created in the complex box and of course have an output named \texttt{output}. 
1451 \\ \hline 
1452
1453
1454 \end{tabular}
1455 \end{table}
1456 % ==========================================
1457
1458
1459
1460
1461 % ==========================================
1462 \vspace{0.5cm}\hrule
1463 \section{Using black boxes in \CPP programs}
1464 \label{cpp}
1465 % ==========================================
1466
1467
1468
1469
1470 %\bibliography{all}
1471
1472
1473
1474 %\section{Conclusion}
1475 \end{document}
1476