Changeset 2849 in Sophya for trunk/SophyaLib/HiStats/basedtable.h


Ignore:
Timestamp:
Nov 21, 2005, 12:08:55 PM (20 years ago)
Author:
ansari
Message:

Ajout de la classe DataTableRow , modifs/ajout interface BaseDataTable - Reza 21/11/2005

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/HiStats/basedtable.h

    r2831 r2849  
    1212#include <string>
    1313#include <vector>
     14#include <map>
    1415
    1516#include <complex>
     
    2425//  Forward class declaration for Fits handler
    2526template <class T>  class FitsHandler;
     27
     28//! Class for representing and manipulating DataTable rows. 
     29class DataTableRow {
     30public:
     31//! Constructor - For use by BaseDataTable class
     32  DataTableRow( vector<string>& colnames );
     33//! Copy constructor
     34  DataTableRow( DataTableRow const & a );
     35//! Returns the value for column \b k. No bound checking performed
     36  inline MuTyV      operator[]  (sa_size_t k)  const { return mtv_[k]; }
     37//! Returns a reference to the value of column \b k. No bound checking performed
     38  inline MuTyV&     operator[]  (sa_size_t k)  { return mtv_[k]; }
     39//! Returns the value for column \b colname.
     40  inline MuTyV      operator[]  (string const& colname)  const { return get(colname); }
     41//! Returns a reference to the value of column \b k.
     42  inline MuTyV&     operator[]  (string const& colname)   { return get(colname); }
     43//! Returns the value for column \b colname.
     44  inline MuTyV      operator[]  (const char* colname)  const
     45  { string sc(colname); return get(sc); }
     46//! Returns a reference to the value of column \b k.
     47  inline MuTyV&     operator[]  (const char* colname)   
     48  { string sc(colname); return get(sc); }
     49//! Returns the value for column \b colname.
     50  MuTyV      get(string const& colname) const;
     51//! Returns a reference to the value of column \b k.
     52  MuTyV&     get(string const& colname);
     53//! Acces to the MuTyV pointer
     54  inline sa_size_t  Size() const { return size_; }
     55//! Acces to the MuTyV pointer
     56  inline MuTyV const *     MTVPtr() const { return mtv_; }
     57//! Acces to the MuTyV pointer
     58  inline MuTyV*     MTVPtr() { return mtv_; }
     59//! prints the object content on the output stream
     60  ostream&   Print(ostream& os) const;
     61protected:
     62  MuTyV * mtv_;
     63  sa_size_t size_;
     64  map<string , sa_size_t> nm2idx_;
     65};
     66
     67/*! Prints the DataTableRow object content on the output stream ( */
     68inline ostream& operator << (ostream& s, DataTableRow const & row)
     69  {  row.Print(s);  return(s);  }
    2670
    2771//! Interface definition for classes handling data in a table.
     
    109153  // Acces to various counts and parameters
    110154  //! Return the number of lines (rows) in the table)
     155  inline sa_size_t  NRows() const { return mNEnt ; }
     156  //! Return the number of lines (rows) in the table)
    111157  inline sa_size_t  NEntry() const { return mNEnt ; }
     158  //! Return the number of columns in the tables (number of cells in a row) 
     159  inline sa_size_t  NCols() const   { return mNames.size() ; }
    112160  //! Return the number of columns in the tables (number of cells in a row) 
    113161  inline sa_size_t  NVar() const   { return mNames.size() ; }
     
    119167  inline sa_size_t  NbSegments() const   { return mNSeg ; }
    120168
    121   // Filling data structures (adding lines)
    122   virtual sa_size_t AddLine(const r_8* data);
    123   virtual sa_size_t AddLine(const MuTyV * data);
    124 
     169  //! Return a compatible DataTableRow object (with table column names)
     170  virtual DataTableRow  EmptyRow();
     171
     172  // Filling data structures (adding lines/rows)
     173  virtual sa_size_t AddRow(const r_8* data);
     174  // Filling data structures (adding lines/rows)
     175  virtual sa_size_t AddRow(const MuTyV * data);
     176  // Filling data structures (adding lines/rows)
     177  virtual sa_size_t AddRow(DataTableRow const & data);
     178
     179  //! Alias for AddRow()
     180  inline sa_size_t  AddLine(const r_8* data)
     181  { return AddRow(data); }
     182  //! Alias for AddRow()
     183  inline sa_size_t  AddLine(const MuTyV * data)
     184  { return AddRow(data); }
    125185  //! Alias for AddLine()
     186  inline sa_size_t  AddLine(DataTableRow const & data)
     187  { return AddRow(data); }
     188
     189  //! Alias for AddRow() - Kept for backward compatibility with NTuple class interface.
    126190  inline sa_size_t  Fill(const r_8* data)
    127   { return AddLine(data); }
    128   //! Alias for AddLine()
    129   inline sa_size_t  Fill(const MuTyV * data);
    130      
     191  { return AddRow(data); }
     192
     193  // Pour etendre la table -     
    131194  virtual sa_size_t Extend();
    132195
    133   //! Return the information stored in line \b n of the table
    134   virtual MuTyV *   GetLine(sa_size_t n) const ;
     196  //! Return the information stored in row \b n of the table in \b row object
     197  virtual DataTableRow&   GetRow(sa_size_t n, DataTableRow& row) const ;
     198  //! Return the information stored in line (row) \b n of the table
     199  virtual MuTyV *   GetRow(sa_size_t n) const ;
     200  //! Return the information stored in line \b n of the table. Alias of GetLine
     201  inline  MuTyV *   GetLine(sa_size_t n) const
     202  { return GetRow(n); }
    135203
    136204  //! Return the information stored in column \b k of the table, converted to double
Note: See TracChangeset for help on using the changeset viewer.