source: Sophya/trunk/SophyaLib/HiStats/ntuple.h@ 2682

Last change on this file since 2682 was 2682, checked in by ansari, 20 years ago

remplacement de int par sa_size_t ds la classe interface NTuple (gestion de tres grand NTuple > 109 entrees - Reza 21/4/2005

File size: 3.6 KB
Line 
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>
12#include <string>
13#include <vector>
14
15#include "ntupintf.h"
16#include "ppersist.h"
17#include "dvlist.h"
18
19namespace SOPHYA {
20
21// Forward class declaration for Fits handler
22class FITS_NTuple;
23
24class NTuple : public AnyDataObj , public NTupleInterface {
25
26public:
27 NTuple();
28 NTuple(int nvar, char** noms, int blk=512, bool fgdouble=true);
29 NTuple(const NTuple& NT);
30 //A virer NTuple(char* flnm);
31 virtual ~NTuple();
32
33 NTuple& operator = (const NTuple& NT);
34
35 void Fill(r_4* x);
36 void Fill(r_8* x);
37
38 inline int_4 NEntry() const { return(mNEnt); }
39 inline int_4 NVar() const { return(mNVar); }
40 inline int_4 BLock() const { return(mBlk); }
41// $CHECK$ Reza 21/10/99 Pourquoi faire BLock() ?
42
43 float GetVal(int n, int k) const;
44 inline float GetVal(int n, const char* nom) const
45 { return(GetVal(n, IndexNom(nom)) ); }
46 int IndexNom(const char* nom) const ;
47 char* NomIndex(int k) const;
48
49 r_4* GetVec(int n, r_4* ret=NULL) const ;
50 r_8* GetVecD(int n, r_8* ret=NULL) const ;
51
52// Impression, I/O
53 void Print(int num, int nmax=1) const ;
54 void Show(ostream& os) const;
55 inline void Show() const { Show(cout); }
56
57 DVList& Info();
58
59// Remplissage depuis fichier ASCII
60 int FillFromASCIIFile(string const& fn, float defval=0.);
61
62
63// Declaration de l interface NTuple
64 virtual sa_size_t NbLines() const ;
65 virtual sa_size_t NbColumns() const ;
66 virtual r_8 * GetLineD(sa_size_t n) const ;
67 virtual r_8 GetCell(sa_size_t n, sa_size_t k) const ;
68 virtual r_8 GetCell(sa_size_t n, string const & nom) const ;
69 virtual void GetMinMax(sa_size_t k, double& min, double& max) const ;
70 virtual void GetMinMax(string const & nom, double& min, double& max) const ;
71 virtual sa_size_t ColumnIndex(string const & nom) const ;
72 virtual string ColumnName(sa_size_t k) const;
73 virtual string VarList_C(const char* nomx=NULL) const ;
74 virtual string LineHeaderToString() const;
75 virtual string LineToString(sa_size_t n) const;
76
77// Pour la gestion de persistance
78 friend class ObjFileIO<NTuple> ;
79
80 // pour fichiers FITS
81 friend class FITS_NTuple;
82
83private:
84 void Clean();
85
86 int_4 mNVar, mNEnt, mBlk, mNBlk;
87 r_4* mVar;
88 r_8* mVarD;
89 vector<string> mNames;
90
91 bool mFgDouble; // true -> les donnees sont gardees en double
92 vector<r_4*> mPtr; // Pointeur de tableau float
93 vector<r_8*> mPtrD; // Pointeur de tableau double
94
95 DVList* mInfo; // Infos (variables) attachees au NTuple
96
97};
98
99/*! Prints table information on stream \b s (nt.Show(s)) */
100inline ostream& operator << (ostream& s, NTuple const & nt)
101 { nt.Show(s); return(s); }
102
103/*! Writes the object in the POutPersist stream \b os */
104inline 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 */
107inline PInPersist& operator >> (PInPersist& is, NTuple & obj)
108{ ObjFileIO<NTuple> fio(&obj); is.SkipToNextObject(); 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
Note: See TracBrowser for help on using the repository browser.