PyDataSource.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 
14 #ifndef _PyDataSource_H
15 #define _PyDataSource_H
16 
17 #include <exception>
18 #include <string>
19 #include <vector>
20 
21 #ifndef _MSC_VER
22 #include <inttypes.h>
23 #endif
24 
25 namespace boost {
26  namespace python {
27  namespace numeric {
28  class array;
29  }
30  }
31 }
32 
33 namespace hippodraw {
34 
35  class DataSource;
36 
44 {
45 
46 private:
47 
51  void checkRank ( boost::python::numeric::array array );
52 
53 public:
54 
56  PyDataSource();
57 
59  PyDataSource(const std::string & dataSource);
60 
64  PyDataSource ( const std::string & name, DataSource * source );
65 
66  virtual ~PyDataSource();
67 
73  void static extractVector ( boost::python::numeric::array array,
74  std::vector<double> & col );
75 
79  template < typename T >
80  void static copy_direct ( boost::python::numeric::array array,
81  std::vector<double > & col );
82 
87 
89  const DataSource & dataSource() const { return *m_dataSource; }
90 
91  unsigned int columns() const;
92 
93  unsigned int rows() const;
94 
96  const std::string & getTitle () const;
97 
98  void setTitle(const std::string & title);
99 
102  void setName(const std::string & name);
103 
105  const std::vector<std::string> & getLabels() const;
106 
108  const std::vector<double> & getColumn(const std::string & name) const;
110  const std::vector<double> & getColumn(unsigned int index) const;
111 
113  void replaceColumn(const std::string &,
114  const std::vector<double> & col);
115 
117  void replaceColumn(unsigned int index,
118  const std::vector<double> & col);
119 
122  void replaceColumn ( const std::string &,
123  boost::python::numeric::array array );
124 
127  void replaceColumn ( unsigned int index,
128  boost::python::numeric::array array);
129 
131  int addColumn( const std::string & label,
132  const std::vector<double> & col );
133 
140  int addColumn( const std::string & label,
141  boost::python::numeric::array array );
142 
144  void clear();
145 
148  bool hasColumn(const std::string & name) const;
149 
152  std::string registerNTuple();
153 
156  void registerNTuple( const std::string & name );
157 
161  boost::python::numeric::array
162  columnAsNumArray( const std::string & label ) const;
163 
167  boost::python::numeric::array
168  columnAsNumArray( unsigned int index ) const;
169 
172  void saveColumn ( const std::string & label,
173  const std::vector < double > & v,
174  const std::vector < intptr_t > & shape );
175 
179  void saveColumnFromNumArray( const std::string & label,
180  boost::python::numeric::array array );
181 
185  void saveColumnFromNumArray( unsigned int index,
186  boost::python::numeric::array array );
187 
188 
191  void saveColumnFrom ( const std::string & label,
192  const std::vector < double > & array );
193 
196  void addRow ( const std::vector < double > & array );
197 
200  void append ( const DataSource * source );
201 
204  void append ( const PyDataSource * source );
205 
206  class StopIteration : public std::exception {
207  public:
208  StopIteration(const std::string & what) : m_what(what) {}
209  ~StopIteration() throw() {}
210  const char * what() const throw() {
211  return m_what.c_str();
212  }
213  private:
214  const std::string m_what;
215  };
216 
217 
218 private:
219 
221  std::string m_type;
222 
225 
226 };
227 
228 } // namespace hippodraw
229 
230 #endif // _PyDataSource_H

Generated for HippoDraw Class Library by doxygen