00001
00002
00014 #ifndef NTUPLE_H
00015 #define NTUPLE_H
00016
00017 #ifdef _MSC_VER
00018 # pragma warning(disable:4217)
00019 # pragma warning(disable:4290) // exception spec ignored except to indicate
00020 #endif
00021
00022 #include "DataSource.h"
00023
00035 class MDL_HIPPOPLOT_API NTuple : public DataSource
00036 {
00037
00038 private:
00039
00044 int m_i_count;
00045
00050 mutable int m_i_current;
00051
00054 bool m_i_enabled;
00055
00060 std::vector< std::vector<double> *> m_data;
00061
00065 mutable std::vector < double > m_row;
00066
00069 NTuple & operator= ( const NTuple & rhs );
00070
00077 void resizeColumns ( size_t new_size );
00078
00079 public:
00080
00083 explicit NTuple ( const std::string & name );
00084
00090 explicit NTuple ( const char * name );
00091
00094 explicit NTuple ( const std::vector < std::string > & labels );
00095
00099 explicit NTuple ( const NTuple & nt);
00100
00104 explicit NTuple ( const DataSource * ds );
00105
00110 explicit NTuple ( unsigned int n );
00111
00122 explicit NTuple ( bool dummy );
00123
00126 NTuple ();
00127
00130 virtual ~NTuple();
00131
00134 virtual void copy ( const DataSource & rhs );
00135
00139 virtual void clear();
00140
00143 virtual bool empty () const;
00144
00147 virtual unsigned int rows () const;
00148
00154 virtual void addRow ( const std::vector<double> & v );
00155
00159 virtual void insertRow ( unsigned int index,
00160 const std::vector < double > & v );
00161
00167 virtual void eraseRow ( unsigned int index );
00168
00174 virtual const std::vector < double > & getRow ( unsigned int index ) const;
00175
00176 virtual void reserve ( unsigned int count );
00177
00187 int addColumn ( const std::string &,
00188 const std::vector < double > & column );
00189
00196 void replaceColumn ( unsigned int index,
00197 const std::vector< double > & data );
00198
00204 void replaceColumn ( const std::string & label,
00205 const std::vector < double > & data );
00206
00207
00214 void replaceRow ( unsigned int i,
00215 const std::vector < double > & data );
00216
00217
00225 void setLabels ( const std::vector<std::string> & v );
00226
00227
00228 virtual double
00229 operator [] ( std::vector < unsigned int > & indices ) const;
00230
00231 virtual double valueAt ( unsigned int row, unsigned int column ) const;
00232
00233 virtual const std::vector< double > &
00234 getColumn ( unsigned int index ) const;
00235
00241 virtual std::vector< double > & getColumn ( unsigned int index );
00242
00243 const std::vector< double > & getColumn ( const std::string & label ) const;
00244
00245 virtual unsigned int indexOfMinElement ( unsigned int index ) const;
00246 virtual unsigned int indexOfMaxElement ( unsigned int index ) const;
00247
00250 virtual double minElement ( unsigned int index ) const;
00251
00254 virtual double maxElement ( unsigned int index ) const;
00255
00258 double columnMin( const std::string & name ) const;
00259
00262 double columnMax( const std::string & name ) const;
00263
00264 virtual void notifyObservers () const;
00265
00269 void setIntervalEnabled ( bool yes = true );
00270
00274 bool isIntervalEnabled () const;
00275
00281 void setIntervalCount ( int number );
00282
00285 unsigned int getIntervalCount ( ) const;
00286
00290 virtual bool fillRange ( unsigned int column, Range & ) const;
00291 virtual double sum ( unsigned int column ) const;
00292
00293 };
00294
00295 #endif // NTUPLE_H