Edit the file functions_CubeFunction_Impl.hh in the directory student-src/components/functions/c++. You will need to add the declaration for the gov::cca::Services object to the private object state. This will be done inside the Babel splicer block functions.CubeFunction._implementation. We will call this variable myServices. Upon completion, this splicer block should look like this:
... // DO-NOT-DELETE splicer.begin(functions.CubeFunction._implementation) // Put additional implementation details here... gov::cca::Services myServices; // DO-NOT-DELETE splicer.end(functions.CubeFunction._implementation) ...
Edit the file functions_CubeFunction_Impl.cc in the directory student-src/components/functions/c++ to provide the implementation details. First, you'll need to edit the body of the setServices method (between the Babel splicer blocks functions.CubeFunction.setServices). Upon completion, this part of the file should look like this:
... // DO-NOT-DELETE splicer.begin(functions.CubeFunction.setServices) // insert implementation here myServices = services; gov::cca::TypeMap tm = services.createTypeMap(); if(tm._is_nil()) { fprintf(stderr, "Error:: %s:%d: gov::cca::TypeMap is nil\n", __FILE__, __LINE__); exit(1); } gov::cca::Port p = self; // Babel required casting if(p._is_nil()) { fprintf(stderr, "Error:: %s:%d: Error casting self to gov::cca::Port \n", __FILE__, __LINE__); exit(1); } services.addProvidesPort(p, "FunctionPort", "function.FunctionPort", tm); gov::cca::ComponentRelease cr = self; // Babel required casting services.registerForRelease(cr); return; // DO-NOT-DELETE splicer.end(functions.CubeFunction.setServices) ...
Next you will need to edit the implementation for the method evaluate inside the Babel splicer block functions.CubeFunction.evaluate. After adding the implementation for this method, the body should look like this
... // DO-NOT-DELETE splicer.begin(functions.CubeFunction.evaluate) // insert implementation here return x*x*x; // DO-NOT-DELETE splicer.end(functions.CubeFunction.evaluate) ...
To build the newly written component into a usable library, type make in the directory student-src/components/functions/c++. This will compile, link, and install the new component into a library that is installed in the directory student-src/components/lib.
![]() |
Note |
|---|---|
|
In this step, the makefile automatically generated the .cca file needed by the Ccaffeine and Babel runtime systems to identify and locate babel components. This file can also be generated manually by executing the following command in the directory student-src/components/lib: $CCA/bin/genSCLCCA.sh cca \ `pwd`/libfunctionsCubeFunction-c++.so functions.CubeFunction \ cubeFunction dynamic private now \ > functions.CubeFunction.cca
|
|