Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 803
News FAQ
Search Home


next up previous contents index
Next: The functions Up: An advanced example Previous: The main program

The include file

This file containd the .h module. The working part of this file is really only two lines long but the required "boiler-plate" takes up the first 25 lines (approximately). This text must be included with every file that is intended for the AIPS++ system (i.e. that could be distributed outside of NRAO).

This include file may be found in $AIPSROOT/code/trial/implememnt/test/FileIO.h.

  1  //# FileIO.h: this defines ileIO functions, which ...
  2  //# Copyright (C) 1996,1999,2001
  3  //# Associated Universities, Inc. Washington DC, USA.
  4  //#
  5  //# This library is free software; you can redistribute it and/or modify it
  6  //# under the terms of the GNU Library General Public License as published by
  7  //# the Free Software Foundation; either version 2 of the License, or (at your
  8  //# option) any later version.
  9  //#
 10  //# This library is distributed in the hope that it will be useful, but WITHOUT
 11  //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
 13  //# License for more details.
 14  //#
 15  //# You should have received a copy of the GNU Library General Public License
 16  //# along with this library; if not, write to the Free Software Foundation,
 17  //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
 18  //#
 19  //# Correspondence concerning AIPS++ should be addressed as follows:
 20  //#        Internet email: aips2-request@nrao.edu.
 21  //#        Postal address: AIPS++ Project Office
 22  //#                        National Radio Astronomy Observatory
 23  //#                        520 Edgemont Road
 24  //#                        Charlottesville, VA 22903-2475 USA
 25  //#
 26  //#
 27  //# $Id: IntroPrg.tex,v 19.0 2003/07/16 04:18:22 aips2adm Exp $
 28
 29  #if !defined (AIPS_FILEIO_H)
 30  #define AIPS_FILEIO_H
 31
 32  #if defined(_AIX)
 33  #pragma implementation ("AsciiFileIO.cc")
 34  #endif
 35
 36  #include <aips/aips.h>
 37  #include <aips/Arrays/ArrayIO.h>
 38
 39  //# Forward Declarations
 40
 41  // <summary>
 42  Input/output using ASCII format
 43  // </summary>
 44
 45  // <use visibility=local>   or   <use visibility=export>
 46
 47  // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
 48  // </reviewed>
 49
 50  // <prerequisite>
 51  //   <li> SomeClass
 52  //   <li> SomeOtherClass
 53  //   <li> some concept
 54  // </prerequisite>
 55  //
 56  // <etymology>
 57  // </etymology>
 58  //
 59  // <synopsis>
 60  // </synopsis>
 61  //
 62  // <example>
 63  // </example>
 64  //
 65  // <motivation>
 66  // </motivation>
 67  //
 68  // <templating arg=T>
 69  //    <li>
 70  //    <li>
 71  // </templating>
 72  //
 73  // <thrown>
 74  //    <li>
 75  //    <li>
 76  // </thrown>
 77  //
 78  // <todo asof="yyyy/mm/dd">
 79  //   <li> add this feature
 80  //   <li> fix this bug
 81  //   <li> start discussion of this possible extension
 82  // </todo>
 83
 84 template <class T>
 85    void
 86    readAsciiFile(const char *filein, Matrix<T> &mat){
 87       readAsciiMatrix(mat, filein);
 88    }
 89 template <class T>
 90    void
 91    readAsciiFile(const char *filein, Vector<T> &vec){
 92       readAsciiVector(vec, filein);
 93    }
 94 
 95 //
 96 
 97 template <class T>
 98    void
 99    writeAsciiFile(const char *fileout, const Matrix<T> &mat){
100       writeAsciiMatrix(mat, fileout);
101    }
102 template <class T>
103    void
104    writeAsciiFile(const char *fileout, const Vector<T> &vec){
105       writeAsciiVector(vec, fileout);
106    }
107  #endif
1-27-
Boilerplate which is to be included in each module.

29-30-
The code begins with a label that identifies this file. The macros if ! defined and define prevent the code from being loaded more than once in a given program. (Note the endif macro at the end.)

34-
Every header file MUST include this line which, in turn, must NOT be included with the code for the function.

35-
The Matrix class is included because this header file describes functions that take a Matrix as an argument.

39-82-
These lines are the documentation template for each class. Cxx2html will read these lines and produce formated HTML for your class/functions. A more complete description maybe found in the Programmer's Reference Manual If you ever want to check you're code in then you must fill them in.

84-86-
These lines (which, you will note, are a single statement) declare the function ReadsAsciiFile to be a template i.e. to be defined once for multiple types of argument. The symbol uses here to represent the argument type is the letter T (declared in the pointed brackets with the keyword class). The function itself is like any other function declaration except that the Matrix argument is defined for the multiple types represented by the letter T.

The implications of this are important. Since the class is only specified later on (when the routine is called) the compiler cannot create ahead of time a module that will be linked with the calling code. So even though we will place these routines in a library, it really is a source library and every time a module is used it must be compiled at that time!

87-89-
The lines declare the second function WriteAsciiFile.

91-
This matches the test for label declaration on line 31.


next up previous contents index
Next: The functions Up: An advanced example Previous: The main program   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2004-08-30