base_vect_from_file.C

00001 /*
00002  * Methods for Base_vect and file manipulation
00003  *
00004  * (see file base_vect.h for documentation)
00005  */
00006 
00007 /*
00008  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00009  *
00010  *   This file is part of LORENE.
00011  *
00012  *   LORENE is free software; you can redistribute it and/or modify
00013  *   it under the terms of the GNU General Public License as published by
00014  *   the Free Software Foundation; either version 2 of the License, or
00015  *   (at your option) any later version.
00016  *
00017  *   LORENE is distributed in the hope that it will be useful,
00018  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *   GNU General Public License for more details.
00021  *
00022  *   You should have received a copy of the GNU General Public License
00023  *   along with LORENE; if not, write to the Free Software
00024  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00028 char base_vect_from_file_C[] = "$Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect_from_file.C,v 1.3 2002/10/16 14:36:31 j_novak Exp $" ;
00029 
00030 /*
00031  * $Id: base_vect_from_file.C,v 1.3 2002/10/16 14:36:31 j_novak Exp $
00032  * $Log: base_vect_from_file.C,v $
00033  * Revision 1.3  2002/10/16 14:36:31  j_novak
00034  * Reorganization of #include instructions of standard C++, in order to
00035  * use experimental version 3 of gcc.
00036  *
00037  * Revision 1.2  2001/12/04 21:27:52  e_gourgoulhon
00038  *
00039  * All writing/reading to a binary file are now performed according to
00040  * the big endian convention, whatever the system is big endian or
00041  * small endian, thanks to the functions fwrite_be and fread_be
00042  *
00043  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00044  * LORENE
00045  *
00046  * Revision 2.0  2000/02/09  13:25:23  eric
00047  * *** empty log message ***
00048  *
00049  *
00050  * $Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect_from_file.C,v 1.3 2002/10/16 14:36:31 j_novak Exp $
00051  *
00052  */
00053 
00054 // Headers C
00055 #include <stdlib.h>
00056 
00057 // Header Lorene
00058 #include "headcpp.h"
00059 #include "base_vect.h"
00060 #include "utilitaires.h"
00061 
00062         //--------------------------------------//
00063         //  Identification virtual functions    //
00064         //--------------------------------------//
00065 
00066 
00067 int Base_vect_cart::identify() const    { return 1; }
00068 
00069 int Base_vect_spher::identify() const   { return 2; }
00070 
00071 
00072 
00073         //--------------------------------------//
00074         //  Base_vect construction from a file  //
00075         //--------------------------------------//
00076 
00077 Base_vect* Base_vect::bvect_from_file(FILE* fich) {
00078     
00079     Base_vect* p_bvect ; 
00080     
00081     // Type (class) of vectorial basis identificator ; 
00082     int identificator ;     
00083     fread_be(&identificator, sizeof(int), 1, fich) ;        
00084 
00085     switch(identificator) {
00086     
00087     case 1 : {
00088         p_bvect = new Base_vect_cart(fich) ; 
00089         break ; 
00090     }
00091     
00092     case 2 : {
00093         p_bvect = new Base_vect_spher(fich) ; 
00094         break ; 
00095     }
00096     
00097     default : {
00098         cout << "Base_vect::bvect_from_file : unknown type of Base_vect!" 
00099          << endl ; 
00100         cout << " identificator = " << identificator << endl ; 
00101         abort() ; 
00102         break ; 
00103     }
00104     
00105     }
00106     
00107     return p_bvect ; 
00108     
00109 }
00110 

Generated on Tue Feb 7 01:35:14 2012 for LORENE by  doxygen 1.4.6