next up previous
Next: 5.7.1 Dynamic runtime inclusion Up: 5 Implementation Previous: 5.6.4 Synchronisation of cameras


5.7 Adding Modules

There are several steps involved in adding a module to the Stereocam system. These will now be outlined for a hypothetical module, InputFoo. The steps are the same for Output and Process modules, all references to Input should simply be changed to Output or Process, as appropriate.

  1. Obtain the module source code. This should be in the form of two files, a C++ header file InputFoo.hh and the source code file InputFoo.cc, which together completely define and implement the class InputFoo which inherits from the Input class. The layout and structure should be similar to existing Input modules and the Input base classes.

    1. If the module is being written, perhaps the easiest way to obtain this skeletal structure is by copying an existing Input module. The interior code of the old module can then be removed and replaced with the implementation for the new module.
  2. Add the module to the Makefile so that it will be included in future compilations. This involves editing the Makefile and adding a line

    input_obj_files += InputFoo.o

    near the similar lines. If the module requires extra libraries to be linked in, add them with lines of the form

    LINK += -llibname

    where libname is the name of the library to be linked. Similarly, extra library search directories can be added with

    LIBS += -L/usr/local/package/lib

    and extra include directories can be added with

    CFLAGS += -I/usr/local/package/include
    CXXFLAGS += -I/usr/local/package/include
  3. Add the module to the FactoryInput class, to allow it to be selected from the main program. This involves editing the FactoryInput.cc file and added two sections. The first is

    #include ``InputFoo.hh''

    to get the declarations for the new module. The second is in the main if-else-if ladder of the FactoryInput::choose routine, where the existing code should be mimicked to provide names which create an instance of the InputFoo class, for example,

    } else if (name == ``foo'' || name == ``bar'') { 
    i = new InputFoo(args); 
  4. Run GNU make (or gmake) to recompile the system; the new module should then be available.



Subsections
next up previous
Next: 5.7.1 Dynamic runtime inclusion Up: 5 Implementation Previous: 5.6.4 Synchronisation of cameras
Kevin Pulo
2000-08-22