next up previous
Next: Demangling the template names Up: Notes on using the Previous: Typedef Bug

Creating a templates file

When linking the aips++ system will have a large number of template instantiations already done for you. However there may be some template instantiations you will have to create for yourself. This is done with a personal template instantiation list. To do this create a file called templates. This should be in the directory containing the test program for the class you are currently working on. gmake will see this file and ``knows'' how to create the templates you have specified.

The templates file should contain entries like:

0010 trial/Arrays/Convolver.cc template class Convolver<Float, Complex>
1000 aips/Arrays/ArrayMath.cc template operator*(const Array<Float> &, const Float &)

The entries are:

Ident. number:
The exact number is arbitrary but it should be a unique number for each .cc file, and should be (by convention) a 4 digit number
template file(s):
The .cc file containing the template. If using templates like myClass< Array<Float> > you should also include a .h file containing the definitions of the template arguments. In this example
trial/Utilities/myClass.cc aips/Arrays/Array.h
template:
A keyword separating the filenames from the required template.
required template:
This states which specific template is required to be instantiated. It can either be a class or a global function. An example of each is shown above.

See the system template instantiation list in:
.../code/{aips,trial}/implement/_ReposFiller/templates for further examples and a listing of the system generated templates. These templates are the ones necessary to link the aips++ applications.

Templates that are used by the test programs should not be put in the system file (unless there is an overriding reason), but stored in separate templates files that exist in the test directories. This keeps the aips++ libraries at a manageable size and avoids excessive link times.

If your templates file is getting long and unmanageable there is a utility called reident to sort/uniq, re-sequence and ``canonicalise''gif the templates file.

In the default modegif reident will check if there are duplicates and if necessary changes idents to ensure they're all unique. Idents of 0000 are always replaced.

Its output is always to the file called templates (and input and output can be the same file) so I usually type

reident templates
where I have already appended my changes to an already existing file called templates.

reident can also merge multiple template files together so that

reident templates templates.additions
will merge both input files into the output file.

The shell comment character # can be used to comment entries in your templates file.


next up previous
Next: Demangling the template names Up: Notes on using the Previous: Typedef Bug

Ralph Marson
Wed Aug 28 17:15:27 MDT 1996