LORENE
base_vect.C
1/*
2 * Methods of class Base_vect
3 *
4 * (see file bse_vect.h for documentation)
5 *
6 */
7
8/*
9 * Copyright (c) 2000-2001 Eric Gourgoulhon
10 *
11 * This file is part of LORENE.
12 *
13 * LORENE is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * LORENE is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with LORENE; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 *
27 */
28
29
30
31
32/*
33 * $Id: base_vect.C,v 1.6 2016/12/05 16:17:44 j_novak Exp $
34 * $Log: base_vect.C,v $
35 * Revision 1.6 2016/12/05 16:17:44 j_novak
36 * Suppression of some global variables (file names, loch, ...) to prevent redefinitions
37 *
38 * Revision 1.5 2014/10/13 08:52:39 j_novak
39 * Lorene classes and functions now belong to the namespace Lorene.
40 *
41 * Revision 1.4 2014/10/06 15:12:57 j_novak
42 * Modified #include directives to use c++ syntax.
43 *
44 * Revision 1.3 2002/10/16 14:36:31 j_novak
45 * Reorganization of #include instructions of standard C++, in order to
46 * use experimental version 3 of gcc.
47 *
48 * Revision 1.2 2001/12/04 21:27:52 e_gourgoulhon
49 *
50 * All writing/reading to a binary file are now performed according to
51 * the big endian convention, whatever the system is big endian or
52 * small endian, thanks to the functions fwrite_be and fread_be
53 *
54 * Revision 1.1.1.1 2001/11/20 15:19:28 e_gourgoulhon
55 * LORENE
56 *
57 * Revision 2.2 2000/02/09 13:24:12 eric
58 * REFONTE COMPLETE DE LA CLASSE
59 * L'identification n'est plus base sur un membre statique (numero
60 * d'instance) mais sur les caracteres physiques (rot_phi, etc...)
61 * Ajout des constructeurs par copie et lecture de fichier.
62 *
63 * Revision 2.1 2000/01/10 15:43:11 eric
64 * Methode change_basis (bidon).
65 *
66 * Revision 2.0 2000/01/10 12:43:21 eric
67 * *** empty log message ***
68 *
69 *
70 * $Header: /cvsroot/Lorene/C++/Source/Base_vect/base_vect.C,v 1.6 2016/12/05 16:17:44 j_novak Exp $
71 *
72 */
73
74// Headers C
75#include <cstdlib>
76#include <cstring>
77
78// Headers Lorene
79#include "headcpp.h"
80#include "base_vect.h"
81#include "utilitaires.h"
82
83 //--------------//
84 // Constructors //
85 //--------------//
86
87// Standard constructor without name
88// ---------------------------------
89namespace Lorene {
91
92 set_name("") ;
93
94}
95
96// Standard constructor with name
97// ------------------------------
98Base_vect::Base_vect(const char* name_i){
99
100 set_name(name_i) ;
101
102}
103
104
105// Copy constructor
106// ----------------
108
109 set_name(bvect_i.name) ;
110
111}
112
113// Constructor from file
114// ---------------------
116
117 fread(name, sizeof(char), 100, fich) ;
118
119}
120
121
122 //--------------//
123 // Destructor //
124 //--------------//
125
127
128 // does nothing
129
130}
131
132 //-------------------------//
133 // Manipulation of name //
134 //-------------------------//
135
136
137void Base_vect::set_name(const char* name_i) {
138
139 strncpy(name, name_i, 100) ;
140
141}
142
143const char* Base_vect::get_name() const {
144
145 return name ;
146
147}
148
149 //------------//
150 // Outputs //
151 //------------//
152
153void Base_vect::sauve(FILE* fich) const {
154
155 int ident = identify() ;
156 fwrite_be(&ident, sizeof(int), 1, fich) ;
157
158 fwrite(name, sizeof(char), 100, fich) ;
159
160}
161
162
163
164
165ostream& operator<<(ostream& ost, const Base_vect& bvect) {
166 ost << bvect.get_name() << endl ;
167 bvect >> ost ;
168 return ost ;
169}
170
171
172
173 //----------------------//
174 // Comparison operator //
175 //----------------------//
176
177bool Base_vect::operator!=(const Base_vect& bi) const {
178
179 return !(bi == *this) ;
180
181}
182
183}
Base_vect()
Standard constructor.
Definition base_vect.C:90
bool operator!=(const Base_vect &) const
Comparison operator (difference).
Definition base_vect.C:177
virtual int identify() const =0
Returns a number to identify the sub-classe of Base_vect the object belongs to.
const char * get_name() const
Returns the basis name.
Definition base_vect.C:143
virtual void sauve(FILE *) const
Save in a file.
Definition base_vect.C:153
void set_name(const char *name_i)
Sets the basis name.
Definition base_vect.C:137
virtual ~Base_vect()
Destructor.
Definition base_vect.C:126
friend ostream & operator<<(ostream &, const Base_vect &)
Display.
Definition base_vect.C:165
char name[100]
Name of the basis.
Definition base_vect.h:110
int fwrite_be(const int *aa, int size, int nb, FILE *fich)
Writes integer(s) into a binary file according to the big endian convention.
Definition fwrite_be.C:73
Lorene prototypes.
Definition app_hor.h:67