Changeset 490 in Sophya for trunk/SophyaLib/NTools/ntuple.h


Ignore:
Timestamp:
Oct 21, 1999, 5:25:53 PM (26 years ago)
Author:
ansari
Message:

Merge avec PEIDA++ (~V 3.8) et nettoyage pour nouveau PPersist Reza+cmv 21/10/99

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/NTools/ntuple.h

    r475 r490  
     1// This may look like C code, but it is really -*- C++ -*-
    12// Class NTuple
    23//  CMV+Reza     Juillet 97
    34//  CEA-DAPNIA      LAL-IN2P3/CNRS
    4 //  added overloading of operator =      F. Touze, Guy Le Meur 19-OCT-99
    55
    66#ifndef NTUPLE_H_SEEN
    77#define NTUPLE_H_SEEN
     8
     9#include "objfio.h"
    810
    911#include <iostream.h>
     
    1113#include <vector>
    1214
    13 #if defined(__KCC__)
    14 using std::string ;
    15 #include <vector.h>
    16 #endif
    17 
     15#include "ntupintf.h"
    1816#include "ppersist.h"
    1917#include "dvlist.h"
    2018
     19namespace PlanckDPC {
    2120
    22 class NTuple : public PPersist {
     21class NTuple : public AnyDataObj , public NTupleInterface {
    2322public:
    24   enum {classId = ClassId_NTuple };
     23//  enum {classId = ClassId_NTuple };
    2524
    2625                    NTuple(int nvar, char** noms, int blk=512);
    2726                    NTuple();
     27                    NTuple(const NTuple& NT);
    2828                    NTuple(char* flnm);
    2929  virtual           ~NTuple();
    3030
    31   NTuple &operator=(const NTuple &ntpl);
    32 
     31  NTuple&           operator = (const NTuple& NT);
     32 
    3333  void              Fill(r_4* x);
    3434
    35   inline int_4      NEntry() { return(mNEnt); }
    36   inline int_4      NVar() { return(mNVar); }
    37   inline int_4      BLock() { return(mBlk); }
     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() ?
    3839
    3940  float             GetVal(int n, int k)   const;
    40   inline float      GetVal(int n, char* nom) const
    41                          { return(GetVal(n, IndexNom(nom)) ); }
     41  inline float      GetVal(int n, const char* nom) const
     42                            { return(GetVal(n, IndexNom(nom)) ); }
    4243  int               IndexNom(const char* nom)  const ;
    4344  char*             NomIndex(int k) const;
    44   string            VarList_C(const char* nomx=NULL)  const;
    4545
    4646  r_4*              GetVec(int n, r_4* ret=NULL)  const ;
    4747  r_8*              GetVecD(int n, r_8* ret=NULL)  const ;
    4848
    49   void              GetMinMax(int k, float& min, float& max)   const ;
    50   inline void       GetMinMax(const char* nom, float& min, float& max)  const
    51                          { GetMinMax(IndexNom(nom), min, max); }
    52 
     49// Impression, I/O
    5350  void              Print(int num, int nmax=1)  const ;
    5451  void              Show(ostream& os) const;
     
    5754  DVList&           Info();
    5855
    59   int_4             ClassId() const        { return classId; }
    60   static PPersist*  Create()               { return new NTuple;}
     56// Remplissage depuis fichier ASCII
     57  int               FillFromASCIIFile(string const& fn, float defval=0.);
    6158
    62   virtual void      WriteSelf(POutPersist&) const;
    63   virtual void      ReadSelf(PInPersist&);
    6459
     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; 
     73
     74//  Pour la gestion de persistance
     75  friend class ObjFileIO<NTuple> ;
    6576
    6677private:
     
    8192  {  nt.Show(s);  return(s);  }
    8293
     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
    83102#ifdef __MWERKS__
    84103__MSL_FIX_ITERATORS__(r_4*);
    85104#endif
    86105
     106} // namespace PlanckDPC
     107
    87108#endif
    88109 
Note: See TracChangeset for help on using the changeset viewer.