Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 class Range;
00027 
00047 class MDL_HIPPOPLOT_API DataSource : public Observable
00048 {
00049 
00050  private:
00051 
00059   std::string m_ds_name;
00060 
00063   std::string m_title;
00064 
00067   std::vector<std::string> m_labels;
00068 
00075   bool m_is_null;
00076 
00077 protected:
00078 
00081   mutable std::vector < double > m_array;
00082 
00089   std::vector < unsigned int > m_shape;
00090 
00091 //   /** The number of rows in the data source.
00092 //    */
00093 //   int m_rows;
00094 
00097   DataSource ( const std::vector < std::string > & labels );
00098 
00100   DataSource ( const std::string & name );
00101 
00107   DataSource ( const char * name );
00108 
00112   DataSource ( const DataSource & nt);
00113 
00124   DataSource ( bool dummy );
00125 
00128   DataSource ();
00129 
00133   virtual void copyPrivate ( const DataSource & other );
00134 
00137   virtual void addLabel ( const std::string & label );
00138 
00142   bool isValidColumn ( unsigned int index ) const;
00143 
00144  public:
00145 
00148   virtual ~DataSource();
00149 
00153   bool isNull () const;
00154 
00157   void setName ( const std::string & name );
00158 
00161   const std::string & getName () const;
00162 
00168   inline unsigned int columns() const;
00169 
00172   virtual unsigned int rows () const = 0;
00173 
00176   virtual bool empty () const = 0;
00177 
00180   const std::string & title() const;
00181 
00184   void setTitle ( const std::string & title );
00185 
00190   bool isValidLabel ( const std::string & label ) const;
00191 
00198   virtual void throwIfInvalidLabel ( const std::string & label ) const;
00199 
00203   void throwIfInvalidRowSize ( const std::vector < double > & row );
00204 
00211   virtual bool setLabelAt ( const std::string & s, unsigned int index );
00212 
00215   virtual void setLabels ( const std::vector<std::string> & v );
00216 
00220   virtual double valueAt ( unsigned int row, unsigned int column ) const = 0;
00221 
00224   virtual const std::vector < double > &
00225   getColumn ( const std::string & name ) const;
00226 
00229   virtual const std::vector < double > & 
00230   getColumn ( unsigned int column ) const;
00231 
00234   virtual const std::vector < double > & getRow ( unsigned int ) const = 0;
00235 
00238   virtual const std::vector < std::string > & getLabels () const;
00239 
00244   virtual const std::string & getLabelAt ( unsigned int index ) const;
00245 
00249 //   virtual bool isFilled ( const std::string & label ) const = 0;
00250 
00255   virtual int indexOf ( const std::string & label ) const;
00256 
00263   virtual void setShape ( std::vector < unsigned int > & shape );
00264 
00267   const std::vector < unsigned int > & getShape () const;
00268 
00272   unsigned int getRank () const;
00273 
00279   virtual bool fillRange ( unsigned int column, Range & ) const;
00280 
00284   virtual unsigned int indexOfMaxElement ( unsigned int index ) const;
00285 
00289   virtual unsigned int indexOfMinElement ( unsigned int index ) const;
00290 
00291 
00295   virtual double sum ( unsigned int column ) const;
00296 
00299   virtual bool isMultiDimensional ( const std::string & column ) const;
00300   
00304   virtual bool setReleventIndex( const std::string & column,
00305                                  const std::vector< unsigned int >& index );
00306 
00309   virtual void clear () = 0;
00310 
00314   virtual void reserve ( unsigned int count ) = 0;
00315 
00321   virtual void addRow ( const std::vector < double > & row ) = 0;
00322 
00323   virtual double 
00324   operator [] (  std::vector < unsigned int > & indices ) const = 0;
00325 
00326 
00327 };
00328 
00329 inline
00330 unsigned int
00331 DataSource::
00332 columns () const
00333 {
00334   return static_cast < unsigned int > ( m_labels.size() );
00335 }
00336 
00337 
00338 #endif // DataSource_H

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3