DataSource.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 
00014 #ifndef DataSource_H
00015 #define DataSource_H
00016 
00017 #ifdef _MSC_VER
00018 #include <msdevstudio/MSconfig.h>
00019 #endif
00020 
00021 #include "pattern/Observable.h"
00022 
00023 #include <string>
00024 #include <vector>
00025 
00026 #ifndef _MSC_VER
00027 #include <inttypes.h>
00028 #endif
00029 
00030 namespace hippodraw {
00031   class Range;
00032 
00033 
00055 class MDL_HIPPOPLOT_API DataSource : public Observable
00056 {
00057 
00058  private:
00059 
00066   std::string m_ds_name;
00067 
00070   std::string m_title;
00071 
00074   std::vector<std::string> m_labels;
00075 
00082   bool m_is_null;
00083 
00084 protected:
00085 
00088   mutable std::vector < double > m_array;
00089 
00096   std::vector < unsigned int > m_shape;
00097 
00100   std::vector < std::string > m_dups;
00101 
00104   DataSource ( const std::vector < std::string > & labels );
00105 
00107   DataSource ( const std::string & name );
00108 
00114   DataSource ( const char * name );
00115 
00119   DataSource ( const DataSource & nt);
00120 
00131   DataSource ( bool dummy );
00132 
00135   DataSource ();
00136 
00140   virtual void copyPrivate ( const DataSource & other );
00141 
00144   virtual void addLabel ( const std::string & label );
00145 
00149   bool isValidColumn ( unsigned int index ) const;
00150 
00156   virtual void checkWidth ( const DataSource * source );
00157 
00158  public:
00159 
00162   virtual ~DataSource();
00163 
00167   bool isNull () const;
00168 
00171   void setName ( const std::string & name );
00172 
00175   const std::string & getName () const;
00176 
00182   inline unsigned int columns() const;
00183 
00186   virtual unsigned int rows () const = 0;
00187 
00190   virtual bool empty () const = 0;
00191 
00194   const std::string & title() const;
00195 
00198   virtual void setTitle ( const std::string & title );
00199 
00204   bool isValidLabel ( const std::string & label ) const;
00205 
00212   virtual void throwIfInvalidLabel ( const std::string & label ) const;
00213 
00217   void throwIfInvalidRowSize ( const std::vector < double > & row );
00218 
00225   virtual bool setLabelAt ( const std::string & s, unsigned int index );
00226 
00229   virtual void setLabels ( const std::vector<std::string> & v );
00230 
00234   virtual double valueAt ( unsigned int row, unsigned int column ) const = 0;
00235 
00239   virtual double valueAtNoCache ( unsigned int row, unsigned int column ) const;
00240 
00243   virtual const std::vector < double > &
00244   getColumn ( const std::string & name ) const;
00245 
00248   virtual const std::vector < double > & 
00249   getColumn ( unsigned int column ) const;
00250 
00253   virtual const std::vector < double > & getRow ( unsigned int ) const = 0;
00254 
00257   virtual const std::vector < std::string > & getLabels () const;
00258 
00263   virtual const std::string & getLabelAt ( unsigned int index ) const;
00264 
00273   virtual int indexOf ( const std::string & label ) const;
00274 
00281   virtual void setShape ( std::vector < unsigned int > & shape );
00282 
00285   virtual const std::vector < unsigned int > & getShape () const;
00286 
00294   virtual void fillShape ( std::vector < int > & v,
00295                            unsigned int column ) const;
00296 
00304   virtual void fillShape ( std::vector < int > & v,
00305                            const std::string & label ) const;
00306 
00310   unsigned int getRank () const;
00311 
00320   virtual void replaceColumn ( const std::string & label,
00321                                const std::vector < double > & array );
00322 
00327   virtual void replaceColumn ( unsigned int index,
00328                                const std::vector < double > & array );
00329 
00338   virtual void replaceColumn ( const std::string & label,
00339                                const std::vector < double > & data,
00340                                const std::vector < intptr_t > & shape );
00341 
00349   virtual int addColumn ( const std::string & label,
00350                           const std::vector < double > & data,
00351                           const std::vector < intptr_t > & shape );
00352 
00359   virtual int addColumn ( const std::string & label,
00360                           const std::vector < double > & data );
00361 
00367   virtual bool fillRange ( unsigned int column, Range & ) const;
00368 
00372   virtual unsigned int indexOfMaxElement ( unsigned int index ) const;
00373 
00377   virtual unsigned int indexOfMinElement ( unsigned int index ) const;
00378 
00379 
00383   virtual double sum ( unsigned int column ) const;
00384 
00389   virtual bool isMultiDimensional ( const std::string & column ) const;
00390   
00395   virtual bool isUseable ( const std::string & column ) const;
00396 
00400   virtual bool setReleventIndex( const std::string & column,
00401                                  const std::vector< unsigned int >& index );
00402 
00405   virtual void clear () = 0;
00406 
00410   virtual void reserve ( unsigned int count ) = 0;
00411 
00416   virtual void addRow ( const std::vector < double > & row );
00417 
00421   virtual void eraseRow ( unsigned int index );
00422 
00423   virtual double 
00424   operator [] (  std::vector < unsigned int > & indices ) const = 0;
00425 
00426 
00429   const std::vector < std::string > & getDuplicatedLabels () const;
00430 
00437   virtual void append ( const DataSource * source );
00438 
00444   virtual double * doubleArrayAt ( unsigned int row,
00445                                    unsigned int column ) const;
00446 
00447 
00451   virtual void expandIfNeeded( const std::vector<std::string> & labels ) const;
00452 
00453 };
00454 
00455 inline
00456 unsigned int
00457 DataSource::
00458 columns () const
00459 {
00460   return static_cast < unsigned int > ( m_labels.size() );
00461 }
00462 
00463 } // namespace hippodraw
00464 
00465 #endif // DataSource_H

Generated for HippoDraw Class Library by doxygen