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
00024 namespace hippodraw {
00025
00033 class MDL_HIPPOPLOT_API NTuple : public DataSource
00034 {
00035
00036 private:
00037
00042 int m_i_count;
00043
00048 mutable int m_i_current;
00049
00052 bool m_i_enabled;
00053
00058 std::vector< std::vector<double> *> m_data;
00059
00063 mutable std::vector < double > m_row;
00064
00067 NTuple & operator= ( const NTuple & rhs );
00068
00075 void resizeColumns ( size_t new_size );
00076
00077 public:
00078
00081 explicit NTuple ( const std::string & name );
00082
00088 explicit NTuple ( const char * name );
00089
00092 explicit NTuple ( const std::vector < std::string > & labels );
00093
00097 explicit NTuple ( const NTuple & nt);
00098
00102 explicit NTuple ( const DataSource * ds );
00103
00108 explicit NTuple ( unsigned int n );
00109
00120 explicit NTuple ( bool dummy );
00121
00124 NTuple ();
00125
00128 virtual ~NTuple();
00129
00132 virtual void copy ( const DataSource & rhs );
00133
00136 virtual void append ( const DataSource * source );
00137
00142 virtual void clear();
00143
00146 virtual bool empty () const;
00147
00150 virtual unsigned int rows () const;
00151
00157 virtual void addRow ( const std::vector<double> & v );
00158
00162 virtual void insertRow ( unsigned int index,
00163 const std::vector < double > & v );
00164
00170 virtual void eraseRow ( unsigned int index );
00171
00177 virtual const std::vector < double > & getRow ( unsigned int index ) const;
00178
00179 virtual void reserve ( unsigned int count );
00180
00190 virtual int addColumn ( const std::string &,
00191 const std::vector < double > & column );
00192
00199 virtual void replaceColumn ( unsigned int index,
00200 const std::vector< double > & data );
00201
00208 void replaceRow ( unsigned int i,
00209 const std::vector < double > & data );
00210
00211
00219 void setLabels ( const std::vector<std::string> & v );
00220
00221
00222 virtual double
00223 operator [] ( std::vector < unsigned int > & indices ) const;
00224
00225 virtual double valueAt ( unsigned int row, unsigned int column ) const;
00226
00227 virtual const std::vector< double > &
00228 getColumn ( unsigned int index ) const;
00229
00235 virtual std::vector< double > & getColumn ( unsigned int index );
00236
00237 const std::vector< double > & getColumn ( const std::string & label ) const;
00238
00239 virtual unsigned int indexOfMinElement ( unsigned int index ) const;
00240 virtual unsigned int indexOfMaxElement ( unsigned int index ) const;
00241
00244 virtual double minElement ( unsigned int index ) const;
00245
00248 virtual double maxElement ( unsigned int index ) const;
00249
00252 double columnMin( const std::string & name ) const;
00253
00256 double columnMax( const std::string & name ) const;
00257
00258 virtual void notifyObservers () const;
00259
00263 void setIntervalEnabled ( bool yes = true );
00264
00268 bool isIntervalEnabled () const;
00269
00275 void setIntervalCount ( int number );
00276
00279 unsigned int getIntervalCount ( ) const;
00280
00284 virtual bool fillRange ( unsigned int column, Range & ) const;
00285 virtual double sum ( unsigned int column ) const;
00286
00287 };
00288
00289 }
00290
00291 #endif // NTUPLE_H