#include "datatable.h" #include "sopnamsp.h" #include "strutil.h" #include "pexceptions.h" #include "fiosegdb.h" /*! \class SOPHYA::DataTable \ingroup HiStats This class can be used to organize data in table (row-column) form. Each column holds homogeneous data (same data type), while different columns can be used for different data types (integer, float, string ...). The whole data set is kept in memory. \sa SOPHYA::MuTyV \sa SOPHYA::BaseDataTable \sa SOPHYA::SegDataBlock \code #include "datatable.h" // ... DataTable dt(64); dt.AddFloatColumn("X0_f"); dt.AddFloatColumn("X1_f"); dt.AddDoubleColumn("X0X0pX1X1_d"); double x[5]; for(int i=0; i<63; i++) { x[0] = (i%9)-4.; x[1] = (i/9)-3.; x[2] = x[0]*x[0]+x[1]*x[1]; dt.AddLine(x); } // Printing table info cout << dt ; // Saving object into a PPF file POutPersist po("dtable.ppf"); po << dt ; \endcode */ //! Default constructor - optional specification of block (or segment) size DataTable::DataTable(sa_size_t segsz) : BaseDataTable(segsz) { } //! copy constructor /*! The copy constructur shares the data if \b share=true. Otherwise, the Clone() method is called to make a complete copy. */ DataTable::DataTable(DataTable const & a, bool share) : BaseDataTable(a.SegmentSize()) { if (share) Share(a); else Clone(a); mNEnt = a.mNEnt; mNSeg = a.mNSeg; if (a.mInfo) mInfo = new DVList(*(a.mInfo)); } //! Copy the table structure from \b a and shares the data (columns content) void DataTable::Share(DataTable const & a) { // On copie la structure de table CopyStructure(a); // Et on partage les donnees des colonnes for (size_t kk=0; kk 0) throw ParmError("DataTable::AddColumn() Table contains already data "); CheckColName(cnom); sa_size_t ser; sa_size_t idx = NVar(); switch (ft) { case IntegerField : ser = mICols.size(); mICols.push_back(SegDataBlock(mSegSz)); mIColIdx.push_back(idx); mIColsP.push_back(NULL); for(sa_size_t kk=0; kk(mSegSz)); mLColIdx.push_back(idx); mLColsP.push_back(NULL); for(sa_size_t kk=0; kk(mSegSz)); mFColIdx.push_back(idx); mFColsP.push_back(NULL); for(sa_size_t kk=0; kk(mSegSz)); mDColIdx.push_back(idx); mDColsP.push_back(NULL); for(sa_size_t kk=0; kk >(mSegSz)); mYColIdx.push_back(idx); mYColsP.push_back(NULL); for(sa_size_t kk=0; kk >(mSegSz)); mZColIdx.push_back(idx); mZColsP.push_back(NULL); for(sa_size_t kk=0; kk(mSegSz)); mSColIdx.push_back(idx); mSColsP.push_back(NULL); for(sa_size_t kk=0; kk