1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
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 |
|
---|
9 | #include "objfio.h"
|
---|
10 |
|
---|
11 | #include <iostream.h>
|
---|
12 | #include <string>
|
---|
13 | #include <vector>
|
---|
14 |
|
---|
15 | #include "ntupintf.h"
|
---|
16 | #include "ppersist.h"
|
---|
17 | #include "dvlist.h"
|
---|
18 |
|
---|
19 | namespace SOPHYA {
|
---|
20 |
|
---|
21 | // Forward class declaration for Fits handler
|
---|
22 | class FITS_XNTuple;
|
---|
23 |
|
---|
24 | class NTuple : public AnyDataObj , public NTupleInterface {
|
---|
25 |
|
---|
26 | public:
|
---|
27 | // enum {classId = ClassId_NTuple };
|
---|
28 |
|
---|
29 | NTuple(int nvar, char** noms, int blk=512);
|
---|
30 | NTuple();
|
---|
31 | NTuple(const NTuple& NT);
|
---|
32 | NTuple(char* flnm);
|
---|
33 | virtual ~NTuple();
|
---|
34 |
|
---|
35 | NTuple& operator = (const NTuple& NT);
|
---|
36 |
|
---|
37 | void Fill(r_4* x);
|
---|
38 |
|
---|
39 | inline int_4 NEntry() const { return(mNEnt); }
|
---|
40 | inline int_4 NVar() const { return(mNVar); }
|
---|
41 | inline int_4 BLock() const { return(mBlk); }
|
---|
42 | // $CHECK$ Reza 21/10/99 Pourquoi faire BLock() ?
|
---|
43 |
|
---|
44 | float GetVal(int n, int k) const;
|
---|
45 | inline float GetVal(int n, const char* nom) const
|
---|
46 | { return(GetVal(n, IndexNom(nom)) ); }
|
---|
47 | int IndexNom(const char* nom) const ;
|
---|
48 | char* NomIndex(int k) const;
|
---|
49 |
|
---|
50 | r_4* GetVec(int n, r_4* ret=NULL) const ;
|
---|
51 | r_8* GetVecD(int n, r_8* ret=NULL) const ;
|
---|
52 |
|
---|
53 | // Impression, I/O
|
---|
54 | void Print(int num, int nmax=1) const ;
|
---|
55 | void Show(ostream& os) const;
|
---|
56 | inline void Show() const { Show(cout); }
|
---|
57 |
|
---|
58 | DVList& Info();
|
---|
59 |
|
---|
60 | // Remplissage depuis fichier ASCII
|
---|
61 | int FillFromASCIIFile(string const& fn, float defval=0.);
|
---|
62 |
|
---|
63 |
|
---|
64 | // Declaration de l interface NTuple
|
---|
65 | virtual uint_4 NbLines() const ;
|
---|
66 | virtual uint_4 NbColumns() const ;
|
---|
67 | virtual r_8 * GetLineD(int n) const ;
|
---|
68 | virtual r_8 GetCell(int n, int k) const ;
|
---|
69 | virtual r_8 GetCell(int n, string const & nom) const ;
|
---|
70 | virtual void GetMinMax(int k, double& min, double& max) const ;
|
---|
71 | virtual void GetMinMax(string const & nom, double& min, double& max) const ;
|
---|
72 | virtual int ColumnIndex(string const & nom) const ;
|
---|
73 | virtual string ColumnName(int k) const;
|
---|
74 | virtual string VarList_C(const char* nomx=NULL) const ;
|
---|
75 | virtual string LineHeaderToString() const;
|
---|
76 | virtual string LineToString(int n) const;
|
---|
77 |
|
---|
78 | // Pour la gestion de persistance
|
---|
79 | friend class ObjFileIO<NTuple> ;
|
---|
80 |
|
---|
81 | // pour fichiers FITS
|
---|
82 | friend class FITS_NTuple;
|
---|
83 |
|
---|
84 |
|
---|
85 | private:
|
---|
86 | void Clean();
|
---|
87 |
|
---|
88 | int_4 mNVar, mNEnt, mBlk, mNBlk;
|
---|
89 | r_4* mVar;
|
---|
90 | r_8* mVarD;
|
---|
91 | char* mNames;
|
---|
92 |
|
---|
93 | vector<r_4*> mPtr;
|
---|
94 |
|
---|
95 | DVList* mInfo; // Infos (variables) attachees au NTuple
|
---|
96 |
|
---|
97 | };
|
---|
98 |
|
---|
99 | /*! Prints table information on stream \b s (nt.Show(s)) */
|
---|
100 | inline ostream& operator << (ostream& s, NTuple const & nt)
|
---|
101 | { nt.Show(s); return(s); }
|
---|
102 |
|
---|
103 | /*! Writes the object in the POutPersist stream \b os */
|
---|
104 | inline POutPersist& operator << (POutPersist& os, NTuple & obj)
|
---|
105 | { ObjFileIO<NTuple> fio(&obj); fio.Write(os); return(os); }
|
---|
106 | /*! Reads the object from the PInPersist stream \b is */
|
---|
107 | inline PInPersist& operator >> (PInPersist& is, NTuple & obj)
|
---|
108 | { ObjFileIO<NTuple> fio(&obj); fio.Read(is); return(is); }
|
---|
109 |
|
---|
110 | // Classe pour la gestion de persistance
|
---|
111 | // ObjFileIO<NTuple>
|
---|
112 |
|
---|
113 |
|
---|
114 |
|
---|
115 | #ifdef __MWERKS__
|
---|
116 | __MSL_FIX_ITERATORS__(r_4*);
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | } // namespace SOPHYA
|
---|
120 |
|
---|
121 | #endif
|
---|
122 |
|
---|