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

Last change on this file since 4072 was 3572, checked in by cmv, 17 years ago

char* -> const char* pour regler les problemes de deprecated string const... + comparaison unsigned signed + suppression EVOL_PLANCK rz+cmv 07/02/2009

File size: 4.5 KB
RevLine 
[763]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
[2322]11#include <iostream>
[763]12#include <string>
13#include <vector>
14
15#include "ntupintf.h"
16#include "ppersist.h"
17#include "dvlist.h"
18
19namespace SOPHYA {
20
[869]21// Forward class declaration for Fits handler
[2663]22class FITS_NTuple;
[3392]23// Forward class declaration for Thread-safe operations
24class ThSafeOp;
[869]25
[2808]26//! Class for creation and management of double or float data sets in a table
[763]27class NTuple : public AnyDataObj , public NTupleInterface {
[846]28
[763]29public:
[3112]30 NTuple();
31 NTuple(int nvar, char** noms, int blk=512, bool fgdouble=true);
[3572]32 NTuple(int nvar, const char** noms, int blk=512, bool fgdouble=true);
[3112]33 NTuple(vector<string>& noms, int blk=512, bool fgdouble=true);
34 NTuple(const NTuple& NT);
35 virtual ~NTuple();
[763]36
[3392]37 // Activate/deactivate thread-safe Fill operation
38 void SetThreadSafe(bool fg=true);
39 //! Return true if Fill operations are thread-safe
40 inline bool IsThreadSafe() const { return ((mThS)?true:false); }
41
[3112]42 NTuple& operator = (const NTuple& NT);
[763]43
44 void Fill(r_4* x);
[2663]45 void Fill(r_8* x);
[2808]46 //! Return the number of lines (rows) in the table)
47 inline int_4 NEntry() const { return(mNEnt); }
48 //! Return the number of columns in the tables (number of cells in a row)
[763]49 inline int_4 NVar() const { return(mNVar); }
[2808]50 //! Return the bloc size
[763]51 inline int_4 BLock() const { return(mBlk); }
52// $CHECK$ Reza 21/10/99 Pourquoi faire BLock() ?
53
[2808]54 //! Return the content of the cell for line (row) \b n , column \b k
[763]55 float GetVal(int n, int k) const;
[2808]56 //! Return the content of the cell for line (row) \b and column name \b nom
[763]57 inline float GetVal(int n, const char* nom) const
58 { return(GetVal(n, IndexNom(nom)) ); }
59 int IndexNom(const char* nom) const ;
60 char* NomIndex(int k) const;
[2808]61 //! Return the content of line \b n as a vector of r_4 (float)
[763]62 r_4* GetVec(int n, r_4* ret=NULL) const ;
[2808]63 //! Return the content of line \b n as a vector of r_8 (double)
[763]64 r_8* GetVecD(int n, r_8* ret=NULL) const ;
65
66// Impression, I/O
67 void Print(int num, int nmax=1) const ;
68 void Show(ostream& os) const;
69 inline void Show() const { Show(cout); }
70
[2808]71 //! Return the associated DVList object
[763]72 DVList& Info();
73
74// Remplissage depuis fichier ASCII
75 int FillFromASCIIFile(string const& fn, float defval=0.);
76
77
78// Declaration de l interface NTuple
[2682]79 virtual sa_size_t NbLines() const ;
80 virtual sa_size_t NbColumns() const ;
81 virtual r_8 * GetLineD(sa_size_t n) const ;
82 virtual r_8 GetCell(sa_size_t n, sa_size_t k) const ;
83 virtual r_8 GetCell(sa_size_t n, string const & nom) const ;
84 virtual void GetMinMax(sa_size_t k, double& min, double& max) const ;
[763]85 virtual void GetMinMax(string const & nom, double& min, double& max) const ;
[2682]86 virtual sa_size_t ColumnIndex(string const & nom) const ;
87 virtual string ColumnName(sa_size_t k) const;
[763]88 virtual string VarList_C(const char* nomx=NULL) const ;
89 virtual string LineHeaderToString() const;
[2682]90 virtual string LineToString(sa_size_t n) const;
[763]91
92// Pour la gestion de persistance
93 friend class ObjFileIO<NTuple> ;
94
[1046]95 // pour fichiers FITS
[2663]96 friend class FITS_NTuple;
[869]97
[763]98private:
[3572]99 void Initialize(int nvar, int blk, bool fgdouble);
[763]100 void Clean();
101
102 int_4 mNVar, mNEnt, mBlk, mNBlk;
103 r_4* mVar;
104 r_8* mVarD;
[2663]105 vector<string> mNames;
[763]106
[2663]107 bool mFgDouble; // true -> les donnees sont gardees en double
108 vector<r_4*> mPtr; // Pointeur de tableau float
109 vector<r_8*> mPtrD; // Pointeur de tableau double
[763]110
111 DVList* mInfo; // Infos (variables) attachees au NTuple
112
[3392]113 ThSafeOp* mThS; // != NULL -> Thread safe operations
[763]114};
115
[1413]116/*! Prints table information on stream \b s (nt.Show(s)) */
[763]117inline ostream& operator << (ostream& s, NTuple const & nt)
118 { nt.Show(s); return(s); }
119
[1405]120/*! Writes the object in the POutPersist stream \b os */
[763]121inline POutPersist& operator << (POutPersist& os, NTuple & obj)
122{ ObjFileIO<NTuple> fio(&obj); fio.Write(os); return(os); }
[1405]123/*! Reads the object from the PInPersist stream \b is */
[763]124inline PInPersist& operator >> (PInPersist& is, NTuple & obj)
[2479]125{ ObjFileIO<NTuple> fio(&obj); is.SkipToNextObject(); fio.Read(is); return(is); }
[763]126
127// Classe pour la gestion de persistance
128// ObjFileIO<NTuple>
129
[846]130
[763]131} // namespace SOPHYA
132
133#endif
134
Note: See TracBrowser for help on using the repository browser.