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