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

PyDataSource.h

Go to the documentation of this file.
00001 /* -*- mode: c++ -*- */
00002 
00014 #ifndef _PyDataSource_H
00015 #define _PyDataSource_H
00016 
00017 #ifdef HAVE_CONFIG_H
00018 #include "config.h"
00019 #endif
00020 
00021 #include <exception>
00022 #include <string>
00023 #include <vector>
00024 
00025 #include <boost/python.hpp>
00026 
00027 class DataSource;
00028 
00035 class PyDataSource {
00036 
00037 public:
00038 
00040    PyDataSource();
00041 
00043    PyDataSource(const std::string & dataSource);
00044 
00048    PyDataSource ( const std::string & name, DataSource * source );
00049 
00050    ~PyDataSource();
00051 
00053    const DataSource & dataSource() const { return *m_dataSource; }
00054 
00055    unsigned int columns() const;
00056 
00057    unsigned int rows() const;
00058 
00060    const std::string & getTitle () const;
00061 
00062    void setTitle(const std::string & title);
00063 
00065    void setName(const std::string & name);
00066 
00068    const std::vector<std::string> & getLabels() const;
00069 
00071    const std::vector<double> & getColumn(const std::string & name) const;
00072 
00074    const std::vector<double> & getColumn(unsigned int index) const;
00075 
00077    void replaceColumn(const std::string &,
00078                       const std::vector<double> & col);
00079 
00081    void replaceColumn(unsigned int index, 
00082                       const std::vector<double> & col);
00083 
00084 #ifdef HAVE_NUMARRAY
00085 
00087    void replaceColumn ( const std::string &,
00088                         boost::python::numeric::array array );
00089 
00092    void replaceColumn ( unsigned int index, 
00093                         boost::python::numeric::array array);
00094 #endif
00095 
00097    int addColumn( const std::string & label,
00098                   const std::vector<double> & col );
00099 
00100 #ifdef HAVE_NUMARRAY
00101 
00102    int addColumn( const std::string & label, 
00103                   boost::python::numeric::array array );
00104 #endif
00105 
00107    void clear();
00108 
00110    bool hasColumn(const std::string & colname) const;
00111 
00113    std::string registerNTuple();
00114 
00116    void registerNTuple( const std::string & name );
00117 
00118 #ifdef HAVE_NUMARRAY
00119 
00122    boost::python::numeric::array
00123    columnAsNumArray( const std::string & label ) const;
00124 
00128    boost::python::numeric::array
00129    columnAsNumArray( unsigned int index ) const;
00130 
00134    void saveColumnFromNumArray( const std::string & label,
00135                                 boost::python::numeric::array array );
00136 
00140    void saveColumnFromNumArray( unsigned int index,
00141                                 boost::python::numeric::array array );
00142 #endif // HAVE_NUMARRAY
00143 
00144    class StopIteration : public std::exception {
00145    public:
00146       StopIteration(const std::string & what) : m_what(what) {}
00147       ~StopIteration() throw() {}
00148       const char * what() const throw() {
00149          return m_what.c_str();
00150       }
00151    private:
00152       const std::string m_what;
00153    };
00154 
00155 private:
00156 
00158    std::string m_type;
00159 
00161    DataSource * m_dataSource;
00162 
00163 };
00164 
00165 #endif // _PyDataSource_H

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3