base_vect.C

00001 /*
00002  *  Methods of class Base_vect
00003  *
00004  *   (see file bse_vect.h for documentation)
00005  *
00006  */
00007 
00008 /*
00009  *   Copyright (c) 2000-2001 Eric Gourgoulhon
00010  *
00011  *   This file is part of LORENE.
00012  *
00013  *   LORENE is free software; you can redistribute it and/or modify
00014  *   it under the terms of the GNU General Public License as published by
00015  *   the Free Software Foundation; either version 2 of the License, or
00016  *   (at your option) any later version.
00017  *
00018  *   LORENE is distributed in the hope that it will be useful,
00019  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  *   GNU General Public License for more details.
00022  *
00023  *   You should have received a copy of the GNU General Public License
00024  *   along with LORENE; if not, write to the Free Software
00025  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  */
00028 
00029 
00030 char base_vect_C[] = "$Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect.C,v 1.3 2002/10/16 14:36:31 j_novak Exp $" ;
00031 
00032 /*
00033  * $Id: base_vect.C,v 1.3 2002/10/16 14:36:31 j_novak Exp $
00034  * $Log: base_vect.C,v $
00035  * Revision 1.3  2002/10/16 14:36:31  j_novak
00036  * Reorganization of #include instructions of standard C++, in order to
00037  * use experimental version 3 of gcc.
00038  *
00039  * Revision 1.2  2001/12/04 21:27:52  e_gourgoulhon
00040  *
00041  * All writing/reading to a binary file are now performed according to
00042  * the big endian convention, whatever the system is big endian or
00043  * small endian, thanks to the functions fwrite_be and fread_be
00044  *
00045  * Revision 1.1.1.1  2001/11/20 15:19:28  e_gourgoulhon
00046  * LORENE
00047  *
00048  * Revision 2.2  2000/02/09  13:24:12  eric
00049  * REFONTE COMPLETE DE LA CLASSE
00050  * L'identification n'est plus base sur un membre statique (numero
00051  * d'instance) mais sur les caracteres physiques (rot_phi, etc...)
00052  * Ajout des constructeurs par copie et lecture de fichier.
00053  *
00054  * Revision 2.1  2000/01/10  15:43:11  eric
00055  * Methode change_basis (bidon).
00056  *
00057  * Revision 2.0  2000/01/10  12:43:21  eric
00058  * *** empty log message ***
00059  *
00060  *
00061  * $Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect.C,v 1.3 2002/10/16 14:36:31 j_novak Exp $
00062  *
00063  */
00064 
00065 // Headers C
00066 #include <stdlib.h>
00067 #include <string.h>
00068 
00069 // Headers Lorene
00070 #include "headcpp.h"
00071 #include "base_vect.h"
00072 #include "utilitaires.h"
00073 
00074             //--------------//
00075             // Constructors //
00076             //--------------//
00077 
00078 // Standard constructor without name
00079 // ---------------------------------
00080 Base_vect::Base_vect(){
00081     
00082     set_name("") ; 
00083     
00084 }
00085 
00086 // Standard constructor with name
00087 // ------------------------------
00088 Base_vect::Base_vect(const char* name_i){
00089     
00090     set_name(name_i) ; 
00091     
00092 }
00093 
00094 
00095 // Copy constructor
00096 // ----------------
00097 Base_vect::Base_vect(const Base_vect& bvect_i){
00098         
00099     set_name(bvect_i.name) ; 
00100     
00101 }
00102 
00103 // Constructor from file
00104 // ---------------------
00105 Base_vect::Base_vect(FILE* fich){
00106         
00107     fread(name, sizeof(char), 100, fich) ;      
00108     
00109 }
00110 
00111 
00112             //--------------//
00113             //  Destructor  //
00114             //--------------//
00115 
00116 Base_vect::~Base_vect(){
00117     
00118     // does nothing
00119         
00120 }
00121 
00122             //-------------------------//
00123             //  Manipulation of name   //
00124             //-------------------------//
00125             
00126             
00127 void Base_vect::set_name(const char* name_i) {
00128 
00129     strncpy(name, name_i,  100) ; 
00130     
00131 }
00132 
00133 const char* Base_vect::get_name() const {
00134     
00135     return name ; 
00136     
00137 }
00138 
00139             //------------//
00140             //  Outputs   //
00141             //------------//
00142 
00143 void Base_vect::sauve(FILE* fich) const {
00144 
00145     int ident = identify() ; 
00146     fwrite_be(&ident, sizeof(int), 1, fich) ;   
00147         
00148     fwrite(name, sizeof(char), 100, fich) ;     
00149    
00150 }
00151     
00152 
00153 
00154 
00155 ostream& operator<<(ostream& ost, const Base_vect& bvect)  {
00156     ost << bvect.get_name() << endl ; 
00157     bvect >> ost ;
00158     return ost ;
00159 }
00160 
00161 
00162 
00163             //----------------------//
00164             // Comparison operator  //
00165             //----------------------//
00166             
00167 bool Base_vect::operator!=(const Base_vect& bi) const {
00168     
00169     return !(bi == *this) ; 
00170     
00171 }
00172 

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