source: Sophya/trunk/SophyaLib/NTools/ntuple.h@ 690

Last change on this file since 690 was 552, checked in by ansari, 26 years ago

namespace changed to SOPHYA cmv 5/11/99

File size: 3.0 KB
RevLine 
[490]1// This may look like C code, but it is really -*- C++ -*-
[220]2// Class NTuple
3// CMV+Reza Juillet 97
4// CEA-DAPNIA LAL-IN2P3/CNRS
5
6#ifndef NTUPLE_H_SEEN
7#define NTUPLE_H_SEEN
8
[490]9#include "objfio.h"
10
[220]11#include <iostream.h>
12#include <string>
13#include <vector>
14
[490]15#include "ntupintf.h"
[220]16#include "ppersist.h"
17#include "dvlist.h"
18
[552]19namespace SOPHYA {
[220]20
[490]21class NTuple : public AnyDataObj , public NTupleInterface {
[220]22public:
[490]23// enum {classId = ClassId_NTuple };
[220]24
25 NTuple(int nvar, char** noms, int blk=512);
26 NTuple();
[490]27 NTuple(const NTuple& NT);
[220]28 NTuple(char* flnm);
29 virtual ~NTuple();
30
[490]31 NTuple& operator = (const NTuple& NT);
32
[220]33 void Fill(r_4* x);
34
[490]35 inline int_4 NEntry() const { return(mNEnt); }
36 inline int_4 NVar() const { return(mNVar); }
37 inline int_4 BLock() const { return(mBlk); }
38// $CHECK$ Reza 21/10/99 Pourquoi faire BLock() ?
[220]39
40 float GetVal(int n, int k) const;
[490]41 inline float GetVal(int n, const char* nom) const
42 { return(GetVal(n, IndexNom(nom)) ); }
[220]43 int IndexNom(const char* nom) const ;
44 char* NomIndex(int k) const;
45
46 r_4* GetVec(int n, r_4* ret=NULL) const ;
[297]47 r_8* GetVecD(int n, r_8* ret=NULL) const ;
[220]48
[490]49// Impression, I/O
[220]50 void Print(int num, int nmax=1) const ;
51 void Show(ostream& os) const;
52 inline void Show() const { Show(cout); }
53
54 DVList& Info();
55
[490]56// Remplissage depuis fichier ASCII
57 int FillFromASCIIFile(string const& fn, float defval=0.);
[220]58
59
[490]60// Declaration de l interface NTuple
61 virtual uint_4 NbLines() const ;
62 virtual uint_4 NbColumns() const ;
63 virtual r_8 * GetLineD(int n) const ;
64 virtual r_8 GetCell(int n, int k) const ;
65 virtual r_8 GetCell(int n, string const & nom) const ;
66 virtual void GetMinMax(int k, double& min, double& max) const ;
67 virtual void GetMinMax(string const & nom, double& min, double& max) const ;
68 virtual int ColumnIndex(string const & nom) const ;
69 virtual string ColumnName(int k) const;
70 virtual string VarList_C(const char* nomx=NULL) const ;
71 virtual string LineHeaderToString() const;
72 virtual string LineToString(int n) const;
[220]73
[490]74// Pour la gestion de persistance
75 friend class ObjFileIO<NTuple> ;
76
[220]77private:
78 void Clean();
79
80 int_4 mNVar, mNEnt, mBlk, mNBlk;
81 r_4* mVar;
[297]82 r_8* mVarD;
[220]83 char* mNames;
84
85 vector<r_4*> mPtr;
86
87 DVList* mInfo; // Infos (variables) attachees au NTuple
88
89};
90
91inline ostream& operator << (ostream& s, NTuple const & nt)
92 { nt.Show(s); return(s); }
93
[490]94inline POutPersist& operator << (POutPersist& os, NTuple & obj)
95{ ObjFileIO<NTuple> fio(&obj); fio.Write(os); return(os); }
96inline PInPersist& operator >> (PInPersist& is, NTuple & obj)
97{ ObjFileIO<NTuple> fio(&obj); fio.Read(is); return(is); }
98
99// Classe pour la gestion de persistance
100// ObjFileIO<NTuple>
101
[220]102#ifdef __MWERKS__
103__MSL_FIX_ITERATORS__(r_4*);
104#endif
105
[552]106} // namespace SOPHYA
[490]107
[220]108#endif
109
Note: See TracBrowser for help on using the repository browser.