In Section 3.2.1, we had Bocca create skeleton .sidl files for the Integration and FunctionPort . Now we need to flesh out the ports by actually specifying the methods they contain.
| $ | bocca edit Integration |
The SIDL code for Integration looks like this:
// DO-NOT-DELETE bocca.splicer.begin(demo.comment)
// Insert-UserCode-Here {demo.comment} (Insert your package comments here)
// DO-NOT-DELETE bocca.splicer.end(demo.comment)
package demo version 0.0 {
// DO-NOT-DELETE bocca.splicer.begin(demo.Integration.comment)
// Insert-UserCode-Here {demo.Integration.comment} (Insert your port comments here)
// DO-NOT-DELETE bocca.splicer.end(demo.Integration.comment)
interface Integration extends gov.cca.Port
{
// DO-NOT-DELETE bocca.splicer.begin(demo.Integration.methods)
// Insert-UserCode-Here {demo.Integration.methods} (Insert your port methods here)
// DO-NOT-DELETE bocca.splicer.end(demo.Integration.methods)
}
}
Insert the march method:
// DO-NOT-DELETE bocca.splicer.begin(demo.comment)
// Insert-UserCode-Here {demo.comment} (Insert your package comments here)
// DO-NOT-DELETE bocca.splicer.end(demo.comment)
package demo version 0.0 {
// DO-NOT-DELETE bocca.splicer.begin(demo.Integration.comment)
// Insert-UserCode-Here {demo.Integration.comment} (Insert your port comments here)
// DO-NOT-DELETE bocca.splicer.end(demo.Integration.comment)
interface Integration extends gov.cca.Port
{
// DO-NOT-DELETE bocca.splicer.begin(demo.Integration.methods)
double march(in double lowBound, in double upBound, in int count);
// DO-NOT-DELETE bocca.splicer.end(demo.Integration.methods)
}
}
After you quit the editor, bocca edit then automatically updates the components that depend on the port edited:
Updating makefiles (for demo.Integration, demo.Driver, demo.Integrator)... Using Babel to validate the SIDL for port demo.Integration ... Babel updating the cxx implementation of component demo.Driver ... Babel updating the cxx implementation of component demo.Integrator ...
Next edit the file FunctionPort.sidl:
$
bocca edit FunctionPort
Add two methods, init and evaluate so that function looks like this:
// DO-NOT-DELETE bocca.splicer.begin(demo.comment)
// Insert-UserCode-Here {demo.comment} (Insert your package comments here)
// DO-NOT-DELETE bocca.splicer.end(demo.comment)
package demo version 0.0 {
// DO-NOT-DELETE bocca.splicer.begin(demo.FunctionPort.comment)
// Insert-UserCode-Here {demo.FunctionPort.comment} (Insert your port comments here)
// DO-NOT-DELETE bocca.splicer.end(demo.FunctionPort.comment)
interface FunctionPort extends gov.cca.Port
{
// DO-NOT-DELETE bocca.splicer.begin(demo.FunctionPort.methods)
void init(in array<double,1> params);
double evaluate(in double x);
// DO-NOT-DELETE bocca.splicer.end(demo.FunctionPort.methods)
}
}
Again quit the editor and the dependent components are updated as indicated by this output from bocca edit:
Updating makefiles (for demo.FunctionPort, demo.Integrator, demo.Function)... Using Babel to validate the SIDL for port demo.FunctionPort ... Babel updating the cxx implementation of component demo.Integrator ... Babel updating the cxx implementation of component demo.Function ...
These files contain the language-independent specification of the ports and their methods, expressed using SIDL. When you type make all of the the new method information is propagated to the language-dependent implementation files using Babel . Of course the methods will be unimplemented but the components will build anyway. So let's do that now:
$
make && make check
make[1]: Entering directory `/home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo'
# =======================================================================
# No SIDL files in external/sidl, skipping build for external
# =======================================================================
# =======================================================================
# Building in ports/, languages: cxx
# =======================================================================
## Building ports...
[c] using Babel to generate cxx client code for demo.FunctionPort...
[c] creating library: libdemo.FunctionPort-cxx.la...
15,16c15,16
<
< // Insert-UserCode-Here {demo.FunctionPort.methods} (Insert your port methods here)
---
> void init(in array<double,1> params);
> double evaluate(in double x);
[c] installing modified demo.FunctionPort.sidl in /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/share/cca.
[c] building /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/share/cca/demo/demo.FunctionPort_depl.xml ... 20968
[c] using Babel to generate cxx client code for demo.Integration...
[c] creating library: libdemo.Integration-cxx.la...
15,16c15
<
< // Insert-UserCode-Here {demo.Integration.methods} (Insert your port methods here)
---
> double march(in double lowBound, in double upBound, in int count);
[c] installing modified demo.Integration.sidl in /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/share/cca.
[c] building /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/share/cca/demo/demo.Integration_depl.xml ... 21278
# =======================================================================
# Building in components/clients/, languages: cxx
# =======================================================================
## Building clients...
# =======================================================================
# Building in components/, languages: cxx
# =======================================================================
[s] Building class/component demo.Driver:
[s] using Babel to generate cxx implementation code from demo.Driver.sidl...
[s] compiling sources...
[s] creating class/component library: libdemo.Driver.la ...
[s] finished libtooling: components/demo.Driver/libdemo.Driver.la ...
[s] building /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/share/cca/demo/demo.Driver_depl.xml ...
[s] creating Ccaffeine test script (components/tests/instantiation.gen.rc)...
[s] Building class/component demo.Function:
[s] using Babel to generate cxx implementation code from demo.Function.sidl...
[s] compiling sources...
[s] creating class/component library: libdemo.Function.la ...
[s] finished libtooling: components/demo.Function/libdemo.Function.la ...
[s] building /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/share/cca/demo/demo.Function_depl.xml ...
[s] creating Ccaffeine test script (components/tests/instantiation.gen.rc)...
[s] Building class/component demo.Integrator:
[s] using Babel to generate cxx implementation code from demo.Integrator.sidl...
[s] compiling sources...
[s] creating class/component library: libdemo.Integrator.la ...
[s] finished libtooling: components/demo.Integrator/libdemo.Integrator.la ...
[s] building /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/share/cca/demo/demo.Integrator_depl.xml ...
[s] creating Ccaffeine test script (components/tests/instantiation.gen.rc)...
[s] Building class/component demo.emptyComponent:
doing nothing -- library is up-to-date.
Build summary:
SUCCESS building demo.Driver
SUCCESS building demo.Function
SUCCESS building demo.Integrator
### To test instantiation of successfully built components, run 'make check' ###
################ Finished building everything #################
####### You can run some simple tests with 'make check' #######
make[1]: Leaving directory `/home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo'
make[1]: Entering directory `/home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo'
make --no-print-directory --no-builtin-rules -C components check
### Test library load and instantiation for the following languages: cxx
Running instantiation tests only
###
LDPATH=/home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/lib:/usr/local/ACTS/cca/lib:/usr/local/ACTS/cca/lib:/usr/local/packages/java-1.6.0_14/jre/lib/i386/client:/usr/local/packages/java-1.6.0_14/jre/lib/i386/server::/usr/local/packages/java-1.6.0_14/jre/lib/i386::/usr/local/ACTS/cca/lib:/usr/local/ACTS/CCAtk/components/TauPerformance-1.7.3:/tau/i386_linux/lib/bindings-mpi-python-pdt:/usr/local/packages/ptoolsrte-0.31/packages/python-2.5.2/lib/python2.5:/usr/local/packages/ptoolsrte-0.31/packages/python-2.5.2/lib/python2.5/lib-dynload:/usr/local/packages/ptoolsrte-0.31/packages/python-2.5.2/lib/python2.5/site-packages:/usr/local/packages/ptoolsrte-0.31/packages/wx-2.8.9.1/lib:/usr/local/packages/ptoolsrte-0.31/packages/Mesa-7.2/lib64:/usr/local/packages/ptoolsrte-0.31/packages/boost/lib:/usr/local/packages/ptoolsrte-0.31/packages/python-2.5.2/lib:/usr/local/packages/openmpi/lib:/usr/local/packages/papi/lib:/usr/local/packages/vampirtrace/lib:/usr/local/packages/vampir-server/lib:/usr/local/packages/perfsuite/lib:/usr/local/packages/tau/i386_linux/lib:/usr/local/packages/dyninstAPI/i386-unknown-linux2.4/lib:/usr/local/packages/periscope/lib
###
PYTHONPATH=/usr/local/ACTS/cca/lib/python2.5/site-packages:/home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/lib/python2.5/site-packages:/usr/local/ACTS/cca/lib/cca-spec-babel-0_8_6-babel-1.4.0/python2.5/site-packages:/tau/i386_linux/lib/bindings-mpi-python-pdt:/usr/local/packages/ptoolsrte-0.31/packages/python-2.5.2/lib/python2.5:/usr/local/packages/ptoolsrte-0.31/packages/python-2.5.2/lib/python2.5/lib-dynload:/usr/local/packages/ptoolsrte-0.31/packages/python-2.5.2/lib/python2.5/site-packages:/usr/local/packages/ptoolsrte-0.31/packages/wx-2.8.9.1/lib:/usr/local/packages/ptoolsrte-0.31/packages/Mesa-7.2/lib64:/usr/local/packages/ptoolsrte-0.31/packages/boost/lib:
###
CLASSPATH=/usr/local/ACTS/cca/lib/sidl-1.4.0.jar:/usr/local/ACTS/cca/lib/sidlstub_1.4.0.jar:/usr/local/ACTS/cca/lib/cca-spec.jar:/home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/install/lib/java:
###
Test script: /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/components/tests/instantiation.gen.rc
Log file: /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/components/tests/instantiation.gen.rc.log
SUCCESS:
==> Instantiation tests passed for all built components (see /home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo/components/tests/instantiation.gen.rc.log).
make --no-print-directory --no-builtin-rules check-user
make[1]: Leaving directory `/home/livetau/workshop-acts/cca/WORK/tutorial-src/doc/scratch/cxx/demo'
The methods you inserted into the SIDL port specifications have now been inserted into your already generated components. At this point we are ready to insert the actual implementation into the bodies of these methods. Notice that up to this point, you created the skeleton for an entire application without having to write any code at all, except for the SIDL for the ports. Finally, it is time to implement the components' functionality in the programming language of your choice.
2010-08-11