<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>HippoDraw Class Library</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="hippoApp.ico"> </head><body> <!-- Generated by Doxygen 1.6.2 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_bd46360b4c6a7cd846adf95fa79d46e4.html">python</a> </div> </div> <div class="contents"> <h1>PyDataSource.cxx</h1><a href="PyDataSource_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00013"></a>00013 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span> <a name="l00014"></a>00014 <span class="preprocessor"></span><span class="comment">// for root and cfitsio</span> <a name="l00015"></a>00015 <span class="preprocessor">#include "config.h"</span> <a name="l00016"></a>00016 <span class="preprocessor">#endif</span> <a name="l00017"></a>00017 <span class="preprocessor"></span> <a name="l00018"></a>00018 <span class="comment">// For truncation warning</span> <a name="l00019"></a>00019 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00020"></a>00020 <span class="preprocessor"></span><span class="preprocessor">#include "msdevstudio/MSconfig.h"</span> <a name="l00021"></a>00021 <span class="preprocessor">#endif</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00023"></a>00023 <span class="comment">// include first to avoid _POSIX_C_SOURCE warning.</span> <a name="l00024"></a>00024 <span class="preprocessor">#include <boost/python.hpp></span> <a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="PyDataSource_8h.html" title="hippodraw::PyDataSource class interface">PyDataSource.h</a>"</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="ListTuple_8h.html" title="hippodraw::ListTuple class interface.">ListTuple.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="PyApp_8h.html" title="hippodraw::PyApp class interface.">PyApp.h</a>"</span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="preprocessor">#include "<a class="code" href="DataSourceController_8h.html" title="DataSourceController class interface.">datasrcs/DataSourceController.h</a>"</span> <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="NTuple_8h.html" title="hippodraw::NTuple class interface.">datasrcs/NTuple.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="string__convert_8h.html" title="The namespace for conversion to string.">pattern/string_convert.h</a>"</span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="NumArrayTuple_8h.html" title="hippodraw::NumArrayTuple class interface.">numarray/NumArrayTuple.h</a>"</span> <a name="l00037"></a>00037 <span class="preprocessor">#include "<a class="code" href="num__util_8h.html">numarray/num_util.h</a>"</span> <a name="l00038"></a>00038 <span class="preprocessor">#endif</span> <a name="l00039"></a>00039 <span class="preprocessor"></span> <a name="l00040"></a>00040 <span class="preprocessor">#ifdef HAVE_CFITSIO</span> <a name="l00041"></a>00041 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="FitsNTuple_8h.html" title="hippodraw::FitsNTuple class interface.">fits/FitsNTuple.h</a>"</span> <a name="l00042"></a>00042 <span class="preprocessor">#endif</span> <a name="l00043"></a>00043 <span class="preprocessor"></span> <a name="l00044"></a>00044 <span class="preprocessor">#ifdef HAVE_ROOT</span> <a name="l00045"></a>00045 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="QtRootNTuple_8h.html" title="hippodraw::QtRootNTuple class interface.">root/QtRootNTuple.h</a>"</span> <a name="l00046"></a>00046 <span class="preprocessor">#endif</span> <a name="l00047"></a>00047 <span class="preprocessor"></span> <a name="l00048"></a>00048 <span class="keyword">using namespace </span>boost::python; <a name="l00049"></a>00049 <a name="l00050"></a>00050 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00051"></a>00051 <span class="preprocessor"></span><span class="keyword">namespace </span>{ <a name="l00052"></a>00052 <a name="l00056"></a>00056 <span class="keyword">template</span> < <span class="keyword">typename</span> T > <a name="l00057"></a>00057 <span class="keywordtype">void</span> copy_direct ( boost::python::numeric::array array, <a name="l00058"></a>00058 std::vector<double > & col ) <a name="l00059"></a>00059 { <a name="l00060"></a>00060 <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a21f40778b7db9343a6ca75ec2c41ccce" title="title">T</a> * <a class="code" href="namespacenum__util.html#a0c664ca7e08d03a2b3275f4f35efa933">data</a> = reinterpret_cast < <a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a21f40778b7db9343a6ca75ec2c41ccce" title="title">T</a> * > ( <a class="code" href="namespacenum__util.html#a0c664ca7e08d03a2b3275f4f35efa933">num_util::data</a> ( array ) ); <a name="l00061"></a>00061 <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">size</a> = <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">num_util::size</a> ( array ); <a name="l00062"></a>00062 std::copy ( data, data+ size, back_inserter( col ) ); <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <a name="l00070"></a>00070 <span class="keywordtype">void</span> extractVector ( boost::python::numeric::array array, <a name="l00071"></a>00071 std::vector<double> & col ) <a name="l00072"></a>00072 { <a name="l00073"></a>00073 PyArray_TYPES <a class="code" href="namespacenum__util.html#af7e893a8c6a5f6a426480fc85cda4fa1">type</a> = <a class="code" href="namespacenum__util.html#af7e893a8c6a5f6a426480fc85cda4fa1">num_util::type</a> ( array ); <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="keywordflow">if</span> ( <a class="code" href="namespacenum__util.html#a4187547181a3e6d65ba8ebd0e27763e1">num_util::iscontiguous</a> ( array ) && <a name="l00076"></a>00076 type != PyArray_NOTYPE ) { <a name="l00077"></a>00077 <span class="keywordflow">switch</span> ( type ) <a name="l00078"></a>00078 { <a name="l00079"></a>00079 <span class="preprocessor">#ifdef HAVE_NUMPY</span> <a name="l00080"></a>00080 <span class="preprocessor"></span> <span class="keywordflow">case</span> PyArray_BOOL: <a name="l00081"></a>00081 copy_direct < bool > ( array, col ); <a name="l00082"></a>00082 <span class="keywordflow">break</span>; <a name="l00083"></a>00083 <span class="preprocessor">#endif</span> <a name="l00084"></a>00084 <span class="preprocessor"></span> <span class="keywordflow">case</span> PyArray_CHAR: <a name="l00085"></a>00085 copy_direct < char > ( array, col ); <a name="l00086"></a>00086 <span class="keywordflow">break</span>; <a name="l00087"></a>00087 <a name="l00088"></a>00088 <span class="keywordflow">case</span> PyArray_SHORT : <a name="l00089"></a>00089 copy_direct < short > ( array, col ); <a name="l00090"></a>00090 <span class="keywordflow">break</span>; <a name="l00091"></a>00091 <a name="l00092"></a>00092 <span class="keywordflow">case</span> PyArray_INT : <a name="l00093"></a>00093 copy_direct < int > ( array, col ); <a name="l00094"></a>00094 <span class="keywordflow">break</span>; <a name="l00095"></a>00095 <a name="l00096"></a>00096 <span class="keywordflow">case</span> PyArray_UINT : <a name="l00097"></a>00097 copy_direct < unsigned int > ( array, col ); <a name="l00098"></a>00098 <span class="keywordflow">break</span>; <a name="l00099"></a>00099 <span class="keywordflow">case</span> PyArray_FLOAT : <a name="l00100"></a>00100 copy_direct < float > ( array, col ); <a name="l00101"></a>00101 <span class="keywordflow">break</span>; <a name="l00102"></a>00102 <span class="keywordflow">case</span> PyArray_DOUBLE : <a name="l00103"></a>00103 copy_direct < double > ( array, col ); <a name="l00104"></a>00104 <span class="keywordflow">break</span>; <a name="l00105"></a>00105 <a name="l00106"></a>00106 <span class="keywordflow">default</span>: <a name="l00107"></a>00107 std::string what ( <span class="stringliteral">"DataArray: Array type `"</span> ); <a name="l00108"></a>00108 what += <a class="code" href="namespacenum__util.html#a32710d433aec97899b77e185f1139dd0" title="Converts a PyArray_TYPE to its name in string.">num_util::type2string</a> ( type ); <a name="l00109"></a>00109 what += <span class="stringliteral">"' not supported."</span>; <a name="l00110"></a>00110 <span class="keywordflow">throw</span> std::runtime_error ( what ); <a name="l00111"></a>00111 <span class="keywordflow">break</span>; <a name="l00112"></a>00112 } <a name="l00113"></a>00113 } <a name="l00114"></a>00114 <span class="keywordflow">else</span> { <span class="comment">// not contiguous</span> <a name="l00115"></a>00115 <span class="keyword">const</span> numeric::array & my_array = array; <a name="l00116"></a>00116 <span class="keywordtype">int</span> <a class="code" href="namespacenum__util.html#a59851d76f9624ac3de899f818f9e0a6b">rank</a> = <a class="code" href="namespacenum__util.html#a59851d76f9624ac3de899f818f9e0a6b">num_util::rank</a> ( my_array ); <a name="l00117"></a>00117 <span class="keywordflow">if</span> ( rank < 2 ) { <span class="comment">// rank 1</span> <a name="l00118"></a>00118 <span class="keywordtype">int</span> size = <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">num_util::size</a>( my_array ); <a name="l00119"></a>00119 col.clear(); <a name="l00120"></a>00120 col.reserve(size); <a name="l00121"></a>00121 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < size; i++) { <a name="l00122"></a>00122 boost::python::object result = my_array[i]; <a name="l00123"></a>00123 col.push_back( boost::python::extract<double>(result) ); <a name="l00124"></a>00124 } <a name="l00125"></a>00125 } <a name="l00126"></a>00126 <span class="keywordflow">else</span> { <span class="comment">// rank > 1</span> <a name="l00127"></a>00127 boost::python::object tarray = array.getflat(); <a name="l00128"></a>00128 <span class="keywordtype">int</span> size = <a class="code" href="namespacenum__util.html#a137f48a49d12a7dae8ba7c86db2a0c01">num_util::size</a> ( array ); <a name="l00129"></a>00129 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < size; i++ ) { <a name="l00130"></a>00130 boost::python::object result = tarray[i]; <a name="l00131"></a>00131 col.push_back ( boost::python::extract < double > ( result ) ); <a name="l00132"></a>00132 } <a name="l00133"></a>00133 } <a name="l00134"></a>00134 } <a name="l00135"></a>00135 <a name="l00136"></a>00136 } <a name="l00137"></a>00137 } <span class="comment">// namespace</span> <a name="l00138"></a>00138 <span class="preprocessor">#endif</span> <a name="l00139"></a>00139 <span class="preprocessor"></span> <a name="l00140"></a>00140 <span class="keyword">namespace </span>hippodraw { <a name="l00141"></a>00141 <span class="keyword">namespace </span>Python { <a name="l00142"></a>00142 <a name="l00143"></a><a class="code" href="namespacehippodraw_1_1Python.html#ad6af5afe2772f63ffed1e889d166b875">00143</a> <span class="keywordtype">void</span> <a class="code" href="namespacehippodraw_1_1Python.html#ad6af5afe2772f63ffed1e889d166b875">PyDataSourceExceptionTranslator</a>( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html">PyDataSource::StopIteration</a> & e ) { <a name="l00144"></a>00144 PyErr_SetString ( PyExc_StopIteration, e.<a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a586eee248fedb7de1b50219e14b99c7b">what</a>() ); <a name="l00145"></a>00145 } <a name="l00146"></a>00146 <a name="l00147"></a>00147 <span class="keywordtype">void</span> <a name="l00148"></a><a class="code" href="namespacehippodraw_1_1Python.html#aa31e5f35ca3a37a9e5d0fa2536cd35da">00148</a> <a class="code" href="namespacehippodraw_1_1Python.html#aa31e5f35ca3a37a9e5d0fa2536cd35da" title="Export PyDataSourceWrapper.">export_DataArray</a>() <a name="l00149"></a>00149 { <a name="l00150"></a>00150 class_ < PyDataSource > <a name="l00151"></a>00151 ( <span class="stringliteral">"DataArray"</span>, <a name="l00152"></a>00152 <span class="stringliteral">"A DataArray wraps a DataSource object so that numerical Python\n"</span> <a name="l00153"></a>00153 <span class="stringliteral">"arrays can be used as both input and output. The numerical array\n"</span> <a name="l00154"></a>00154 <span class="stringliteral">"can be either a numarray.array or Numeric.array depending on\n"</span> <a name="l00155"></a>00155 <span class="stringliteral">"how the hippo module was configured.\n"</span> <a name="l00156"></a>00156 <span class="stringliteral">"\n"</span> <a name="l00157"></a>00157 <span class="stringliteral">"Access to the array is done like a Python list or dictionary.\n"</span> <a name="l00158"></a>00158 <span class="stringliteral">"\tarray = my_data_array [ index ] # list form\n"</span> <a name="l00159"></a>00159 <span class="stringliteral">"\tarray = my_data_array [ 'my_label' ] # dict form\n"</span> <a name="l00160"></a>00160 <span class="stringliteral">"\n"</span> <a name="l00161"></a>00161 <span class="stringliteral">"Storage to the array is also done like a Python list or dictionary.\n"</span> <a name="l00162"></a>00162 <span class="stringliteral">"\tmy_data_array [ index ] = ... # list form\n"</span> <a name="l00163"></a>00163 <span class="stringliteral">"\tmy_data_array [ 'my_label' ] = ... # dict form\n"</span> ) <a name="l00164"></a>00164 <a name="l00165"></a>00165 .def ( init < const std::string & > ( <a name="l00166"></a>00166 <span class="stringliteral">"DataArray ( string ) -> DataArray\n"</span> <a name="l00167"></a>00167 <span class="stringliteral">"\n"</span> <a name="l00168"></a>00168 <span class="stringliteral">"Creates a DataArray. The string can be one of\n"</span> <a name="l00169"></a>00169 <span class="stringliteral">"\tListTuple\n"</span> <a name="l00170"></a>00170 <span class="stringliteral">"\tNTuple\n"</span> <a name="l00171"></a>00171 <span class="stringliteral">"\tNumArrayTuple"</span> ) ) <a name="l00172"></a>00172 <a name="l00173"></a>00173 .add_property ( <span class="stringliteral">"columns"</span>, <a name="l00174"></a>00174 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a903d6ffef3ddea0d904a5336e231b643">PyDataSource::columns</a> ) <a name="l00175"></a>00175 <a name="l00176"></a>00176 .add_property ( <span class="stringliteral">"rows"</span>, <a name="l00177"></a>00177 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a2b76a8f13ad489df9fa8cc9452c9012b">PyDataSource::rows</a> ) <a name="l00178"></a>00178 <a name="l00179"></a>00179 .def ( <span class="stringliteral">"getCurrent"</span>, <a name="l00180"></a>00180 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a3457559d05aeab1cc59b98f0ed18a127" title="Returns a new PyDataSource that wraps the current DataSource in the DataSourceController...">PyDataSource::getCurrentDataSource</a>, <a name="l00181"></a>00181 return_value_policy < reference_existing_object > (), <a name="l00182"></a>00182 <span class="stringliteral">"getCurrent () -> DataArray\n"</span> <a name="l00183"></a>00183 <span class="stringliteral">"\n"</span> <a name="l00184"></a>00184 <span class="stringliteral">"Returns a DataArray that wraps the current DataSource."</span> ) <a name="l00185"></a>00185 <a name="l00186"></a>00186 .staticmethod ( <span class="stringliteral">"getCurrent"</span> ) <a name="l00187"></a>00187 <a name="l00188"></a>00188 .def ( <span class="stringliteral">"dataSource"</span>, <a name="l00189"></a>00189 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a5e1620dad6d32635469440fb2c902499" title="Return a reference to the underlying DataSource.">PyDataSource::dataSource</a>, <a name="l00190"></a>00190 return_value_policy < reference_existing_object > (), <a name="l00191"></a>00191 <span class="stringliteral">"dataSource () -> DataSource\n"</span> <a name="l00192"></a>00192 <span class="stringliteral">"\n"</span> <a name="l00193"></a>00193 <span class="stringliteral">"Returns reference to underlying DataSource"</span> ) <a name="l00194"></a>00194 <a name="l00195"></a>00195 .def ( <span class="stringliteral">"getTitle"</span>, <a name="l00196"></a>00196 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a98de8e590ee20cbb6aa9c564d79c71ee" title="The title of the DataSource.">PyDataSource::getTitle</a>, <a name="l00197"></a>00197 return_value_policy < copy_const_reference > (), <a name="l00198"></a>00198 <span class="stringliteral">"getTitle () -> string\n"</span> <a name="l00199"></a>00199 <span class="stringliteral">"\n"</span> <a name="l00200"></a>00200 <span class="stringliteral">"Returns title of the DataSource."</span> ) <a name="l00201"></a>00201 <a name="l00202"></a>00202 .def ( <span class="stringliteral">"setName"</span>, <a name="l00203"></a>00203 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a9d3a2685df23b5e7cbf59c19c4a1f9b5" title="Set the name of the DataSource.">PyDataSource::setName</a>, <a name="l00204"></a>00204 <span class="stringliteral">"setName ( string ) -> None\n"</span> <a name="l00205"></a>00205 <span class="stringliteral">"\n"</span> <a name="l00206"></a>00206 <span class="stringliteral">"Sets the name of the DataSource. The name should be unique\n"</span> <a name="l00207"></a>00207 <span class="stringliteral">"with one application and may appear in the Inspector panel."</span> ) <a name="l00208"></a>00208 <a name="l00209"></a>00209 .def ( <span class="stringliteral">"setTitle"</span>, <a name="l00210"></a>00210 &<a class="code" href="classhippodraw_1_1PyDataSource.html#abc79cf0667bbb5c93fca3f01b52c7b57">PyDataSource::setTitle</a>, <a name="l00211"></a>00211 <span class="stringliteral">"setTitle ( string ) -> None\n"</span> <a name="l00212"></a>00212 <span class="stringliteral">"\n"</span> <a name="l00213"></a>00213 <span class="stringliteral">"Sets the title of the DataSource. The title is what appears,\n"</span> <a name="l00214"></a>00214 <span class="stringliteral">"by default, at the top of a Display."</span> ) <a name="l00215"></a>00215 <a name="l00216"></a>00216 .def ( <span class="stringliteral">"getLabels"</span>, <a name="l00217"></a>00217 &<a class="code" href="classhippodraw_1_1PyDataSource.html#aa369dc17424da2fe359d1ce9dd2c8b81" title="Get the column names.">PyDataSource::getLabels</a>, <a name="l00218"></a>00218 return_value_policy < copy_const_reference > (), <a name="l00219"></a>00219 <span class="stringliteral">"getLabels () -> list\n"</span> <a name="l00220"></a>00220 <span class="stringliteral">"\n"</span> <a name="l00221"></a>00221 <span class="stringliteral">"Returns the list of string objects of column labels."</span> ) <a name="l00222"></a>00222 <a name="l00223"></a>00223 .def ( <span class="stringliteral">"addColumn"</span>, <a name="l00224"></a>00224 ( <span class="keywordtype">int</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <a name="l00225"></a>00225 (<span class="keyword">const</span> std::string &, <span class="keyword">const</span> std::vector<double> &) ) <a name="l00226"></a>00226 &<a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">PyDataSource::addColumn</a>, <a name="l00227"></a>00227 <span class="stringliteral">"addColumn ( string, list ) -> value\n"</span> <a name="l00228"></a>00228 <span class="stringliteral">"addColumn ( string, array ) -> value\n"</span> <a name="l00229"></a>00229 <span class="stringliteral">"\n"</span> <a name="l00230"></a>00230 <span class="stringliteral">"Adds a column. The string will be the label of the column.\n"</span> <a name="l00231"></a>00231 <span class="stringliteral">"A copy of the list or array values will be the contents.\n"</span> <a name="l00232"></a>00232 <span class="stringliteral">"The second form is only available if HippoDraw was configured\n"</span> <a name="l00233"></a>00233 <span class="stringliteral">"with numerical Python support. Returns the new column's index."</span> ) <a name="l00234"></a>00234 <a name="l00235"></a>00235 <span class="preprocessor">#ifdef HAVE_NUMARRAY </span> <a name="l00236"></a>00236 <span class="preprocessor"></span> .def ( <span class="stringliteral">"addColumn"</span>, <a name="l00237"></a>00237 ( <span class="keywordtype">int</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <a name="l00238"></a>00238 (<span class="keyword">const</span> std::string &, boost::python::numeric::array) ) <a name="l00239"></a>00239 &PyDataSource::addColumn ) <a name="l00240"></a>00240 <span class="preprocessor">#endif</span> <a name="l00241"></a>00241 <span class="preprocessor"></span> <a name="l00242"></a>00242 .def ( <span class="stringliteral">"getColumn"</span>, <a name="l00243"></a>00243 ( <span class="keyword">const</span> std::vector < double > & (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <span class="comment">// fptr</span> <a name="l00244"></a>00244 ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ) <span class="keyword">const</span>) <span class="comment">// function signature</span> <a name="l00245"></a>00245 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a92a8754d2dfae66f8e8a56066ecd7314" title="Get a column as a tuple of floats by column name.">PyDataSource::getColumn</a>, <a name="l00246"></a>00246 return_value_policy < copy_const_reference> (), <a name="l00247"></a>00247 <span class="stringliteral">"getColumn ( value ) -> list\n"</span> <a name="l00248"></a>00248 <span class="stringliteral">"\n"</span> <a name="l00249"></a>00249 <span class="stringliteral">"Returns a column as list of floats. 'value' maybe either\n"</span> <a name="l00250"></a>00250 <span class="stringliteral">"the column label or its index."</span> ) <a name="l00251"></a>00251 <a name="l00252"></a>00252 .def ( <span class="stringliteral">"getColumn"</span>, <a name="l00253"></a>00253 ( <span class="keyword">const</span> std::vector < double > & (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <span class="comment">// fptr</span> <a name="l00254"></a>00254 ( <span class="keyword">const</span> std::string & ) <span class="keyword">const</span>) <span class="comment">// function signature</span> <a name="l00255"></a>00255 &PyDataSource::getColumn, <a name="l00256"></a>00256 return_value_policy < copy_const_reference> () ) <a name="l00257"></a>00257 <a name="l00258"></a>00258 .def ( <span class="stringliteral">"replaceColumn"</span>, <a name="l00259"></a>00259 ( <span class="keywordtype">void</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <a name="l00260"></a>00260 ( <span class="keyword">const</span> std::string &, <span class="keyword">const</span> std::vector<double> & ) ) <a name="l00261"></a>00261 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">PyDataSource::replaceColumn</a>, <a name="l00262"></a>00262 <span class="stringliteral">"replaceColumn ( value, list ) -> None\n"</span> <a name="l00263"></a>00263 <span class="stringliteral">"replaceColumn ( value, array ) -> None\n"</span> <a name="l00264"></a>00264 <span class="stringliteral">"\n"</span> <a name="l00265"></a>00265 <span class="stringliteral">"Replace column by its label or index. The second form is \n"</span> <a name="l00266"></a>00266 <span class="stringliteral">"only available if HippoDraw was configure with numerical\n"</span> <a name="l00267"></a>00267 <span class="stringliteral">"arrays."</span> ) <a name="l00268"></a>00268 <a name="l00269"></a>00269 .def ( <span class="stringliteral">"replaceColumn"</span>, <a name="l00270"></a>00270 ( <span class="keywordtype">void</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <span class="comment">// fptr</span> <a name="l00271"></a>00271 ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index, <span class="keyword">const</span> std::vector<double> & ) ) <a name="l00272"></a>00272 &PyDataSource::replaceColumn ) <a name="l00273"></a>00273 <a name="l00274"></a>00274 <span class="preprocessor">#ifdef HAVE_NUMARRAY </span> <a name="l00275"></a>00275 <span class="preprocessor"></span> .def ( <span class="stringliteral">"replaceColumn"</span>, <a name="l00276"></a>00276 ( <span class="keywordtype">void</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <span class="comment">// fptr</span> <a name="l00277"></a>00277 ( <span class="keyword">const</span> std::string &, numeric::array ) ) <span class="comment">// function signature</span> <a name="l00278"></a>00278 &PyDataSource::replaceColumn ) <a name="l00279"></a>00279 <a name="l00280"></a>00280 .def ( <span class="stringliteral">"replaceColumn"</span>, <a name="l00281"></a>00281 ( <span class="keywordtype">void</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <span class="comment">// fptr</span> <a name="l00282"></a>00282 ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index, numeric::array ) ) <span class="comment">// function signature</span> <a name="l00283"></a>00283 &PyDataSource::replaceColumn ) <a name="l00284"></a>00284 <span class="preprocessor">#endif</span> <a name="l00285"></a>00285 <span class="preprocessor"></span> <a name="l00286"></a>00286 <span class="comment">// comment out until implemented for ListTuple and NumArrayTuple</span> <a name="l00287"></a>00287 <span class="comment">// .def ( "clear",</span> <a name="l00288"></a>00288 <span class="comment">// &PyDataSource::clear,</span> <a name="l00289"></a>00289 <span class="comment">// "Clears the data elements of the DataSource" )</span> <a name="l00290"></a>00290 <a name="l00291"></a>00291 .def (<span class="stringliteral">"has_key"</span>, <a name="l00292"></a>00292 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">PyDataSource::hasColumn</a>, <a name="l00293"></a>00293 <span class="stringliteral">"has_key ( string ) -> Boolean\n"</span> <a name="l00294"></a>00294 <span class="stringliteral">"\n"</span> <a name="l00295"></a>00295 <span class="stringliteral">"Returns True if column with label exists."</span>) <a name="l00296"></a>00296 <a name="l00297"></a>00297 .def ( <span class="stringliteral">"keys"</span>, <a name="l00298"></a>00298 &<a class="code" href="classhippodraw_1_1PyDataSource.html#aa369dc17424da2fe359d1ce9dd2c8b81" title="Get the column names.">PyDataSource::getLabels</a>, <a name="l00299"></a>00299 return_value_policy < copy_const_reference > (), <a name="l00300"></a>00300 <span class="stringliteral">"keys () -> list\n"</span> <a name="l00301"></a>00301 <span class="stringliteral">"\n"</span> <a name="l00302"></a>00302 <span class="stringliteral">"Returns the list of column labels."</span> ) <a name="l00303"></a>00303 <a name="l00304"></a>00304 .def ( <span class="stringliteral">"register"</span>, <a name="l00305"></a>00305 ( <span class="keywordtype">void</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) ( <span class="keyword">const</span> std::string & ) ) <a name="l00306"></a>00306 &<a class="code" href="classhippodraw_1_1PyDataSource.html#af45f2d9804b33387f930fa8207520544" title="Register this DataSource, returning a unique name.">PyDataSource::registerNTuple</a>, <a name="l00307"></a>00307 <span class="stringliteral">"register ( string ) -> None\n"</span> <a name="l00308"></a>00308 <span class="stringliteral">"register ( ) -> string\n"</span> <a name="l00309"></a>00309 <span class="stringliteral">"\n"</span> <a name="l00310"></a>00310 <span class="stringliteral">"Register the underlying DataSource with the\n"</span> <a name="l00311"></a>00311 <span class="stringliteral">"DataSourceController. The first form registers it with the\n"</span> <a name="l00312"></a>00312 <span class="stringliteral">"given name, while the second from returns a unique name\n"</span> <a name="l00313"></a>00313 <span class="stringliteral">"generated by the controller."</span> ) <a name="l00314"></a>00314 <a name="l00315"></a>00315 .def ( <span class="stringliteral">"register"</span>, <a name="l00316"></a>00316 ( std::string (<a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) () ) <a name="l00317"></a>00317 &PyDataSource::registerNTuple ) <a name="l00318"></a>00318 <a name="l00319"></a>00319 <a name="l00320"></a>00320 <span class="comment">// The following must come before the other __setitem__ so that</span> <a name="l00321"></a>00321 <span class="comment">// it is seen last, otherwise a numarray gets converted to</span> <a name="l00322"></a>00322 <span class="comment">// vector.</span> <a name="l00323"></a>00323 .def ( <span class="stringliteral">"__setitem__"</span>, <a name="l00324"></a>00324 &<a class="code" href="classhippodraw_1_1PyDataSource.html#acd1855a4454aa6fc11ddbd432d133011" title="Replace or add a column from vector.">PyDataSource::saveColumnFrom</a>, <a name="l00325"></a>00325 <span class="stringliteral">"__setitem__ ( label, sequence ) -> None\n"</span> <a name="l00326"></a>00326 <span class="stringliteral">"\n"</span> <a name="l00327"></a>00327 <span class="stringliteral">"Copies the contensts of the sequence. If column with label\n"</span> <a name="l00328"></a>00328 <span class="stringliteral">"already exists, replaces it, otherwise add a new column."</span> ) <a name="l00329"></a>00329 <a name="l00330"></a>00330 .def ( <span class="stringliteral">"addRow"</span>, <a name="l00331"></a>00331 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a37d713fece0af9b698e3fd17568f5c57" title="Adds a row to the DataSource.">PyDataSource::addRow</a>, <a name="l00332"></a>00332 <span class="stringliteral">"addRow ( sequence ) -> None\n"</span> <a name="l00333"></a>00333 <span class="stringliteral">"\n"</span> <a name="l00334"></a>00334 <span class="stringliteral">"Adds a row to the held DataSource object if supported, otherwise"</span> <a name="l00335"></a>00335 <span class="stringliteral">" throws Runtime exception."</span> ) <a name="l00336"></a>00336 <a name="l00337"></a>00337 .def ( <span class="stringliteral">"append"</span>, <a name="l00338"></a>00338 ( <span class="keywordtype">void</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <span class="comment">// function pointer</span> <a name="l00339"></a>00339 ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * ) ) <span class="comment">// signature</span> <a name="l00340"></a>00340 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5" title="Adds all the rows of source to the DataArray.">PyDataSource::append</a>, <a name="l00341"></a>00341 <span class="stringliteral">"append ( DataArray ) -> None\n"</span> <a name="l00342"></a>00342 <span class="stringliteral">"append ( DataSource ) -> None\n"</span> <a name="l00343"></a>00343 <span class="stringliteral">"\n"</span> <a name="l00344"></a>00344 <span class="stringliteral">"Appends contents of DataSource or DataArray to the DataArray."</span> ) <a name="l00345"></a>00345 <a name="l00346"></a>00346 .def ( <span class="stringliteral">"append"</span>, <a name="l00347"></a>00347 ( <span class="keywordtype">void</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <span class="comment">// function pointer</span> <a name="l00348"></a>00348 ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a> * ) ) <span class="comment">// signature</span> <a name="l00349"></a>00349 &PyDataSource::append ) <a name="l00350"></a>00350 <a name="l00351"></a>00351 <a name="l00352"></a>00352 .def ( <span class="stringliteral">"__getitem__"</span>, <a name="l00353"></a>00353 ( numeric::array ( <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <a name="l00354"></a>00354 ( <span class="keyword">const</span> std::string & ) <span class="keyword">const</span> ) <a name="l00355"></a>00355 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a19ea45b2f8e2570d61a73a5d4c208a4d" title="Return a column from the DataSource as a numarray object, indexing by column label...">PyDataSource::columnAsNumArray</a>, <a name="l00356"></a>00356 return_value_policy < return_by_value > (), <a name="l00357"></a>00357 <span class="stringliteral">"__getitem__ ( value ) -> array\n"</span> <a name="l00358"></a>00358 <span class="stringliteral">"\n"</span> <a name="l00359"></a>00359 <span class="stringliteral">"Returns a copy of the column as numerical array. 'value' can\n"</span> <a name="l00360"></a>00360 <span class="stringliteral">"be either the column label or its index."</span> ) <a name="l00361"></a>00361 <a name="l00362"></a>00362 .def ( <span class="stringliteral">"__getitem__"</span>, <a name="l00363"></a>00363 ( numeric::array ( <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <a name="l00364"></a>00364 ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> ) <span class="keyword">const</span> ) <a name="l00365"></a>00365 &PyDataSource::columnAsNumArray, <a name="l00366"></a>00366 return_value_policy < return_by_value > () ) <a name="l00367"></a>00367 <a name="l00368"></a>00368 .def ( <span class="stringliteral">"__setitem__"</span>, <a name="l00369"></a>00369 ( <span class="keywordtype">void</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <a name="l00370"></a>00370 ( <span class="keyword">const</span> std::string &, <a name="l00371"></a>00371 numeric::array ) ) <a name="l00372"></a>00372 &<a class="code" href="classhippodraw_1_1PyDataSource.html#a6df19d2008a22273c0a4cbf2546706be" title="Replace or add a column from a numarray object, indexing by column label.">PyDataSource::saveColumnFromNumArray</a>, <a name="l00373"></a>00373 return_value_policy < return_by_value > (), <a name="l00374"></a>00374 <span class="stringliteral">"__setitem__ ( value, array ) -> None\n"</span> <a name="l00375"></a>00375 <span class="stringliteral">"\n"</span> <a name="l00376"></a>00376 <span class="stringliteral">"Copies the contents of array. If `'value' is an index, then\n"</span> <a name="l00377"></a>00377 <span class="stringliteral">"replaces the contents of the existing column. If 'value' is\n"</span> <a name="l00378"></a>00378 <span class="stringliteral">"a label then either replaces existing column with that label\n"</span> <a name="l00379"></a>00379 <span class="stringliteral">"or adds a new column."</span> ) <a name="l00380"></a>00380 <a name="l00381"></a>00381 .def ( <span class="stringliteral">"__setitem__"</span>, <a name="l00382"></a>00382 ( <span class="keywordtype">void</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a>:: * ) <a name="l00383"></a>00383 ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>, <a name="l00384"></a>00384 numeric::array ) ) <a name="l00385"></a>00385 &PyDataSource::saveColumnFromNumArray, <a name="l00386"></a>00386 return_value_policy < return_by_value > () ) <a name="l00387"></a>00387 <a name="l00388"></a>00388 ; <a name="l00389"></a>00389 register_exception_translator<PyDataSource::StopIteration> <a name="l00390"></a>00390 (&<a class="code" href="namespacehippodraw_1_1Python.html#ad6af5afe2772f63ffed1e889d166b875">PyDataSourceExceptionTranslator</a>); <a name="l00391"></a>00391 } <a name="l00392"></a>00392 <a name="l00393"></a>00393 } <span class="comment">// namespace Python</span> <a name="l00394"></a>00394 } <span class="comment">// namespace hippodraw</span> <a name="l00395"></a>00395 <a name="l00396"></a>00396 <span class="keyword">using namespace </span>hippodraw; <a name="l00397"></a>00397 <a name="l00398"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6">00398</a> PyDataSource::PyDataSource() { <a name="l00399"></a>00399 <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> = <span class="stringliteral">"NTuple"</span>; <a name="l00400"></a>00400 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a>(); <a name="l00401"></a>00401 } <a name="l00402"></a>00402 <a name="l00403"></a>00403 <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource::</a> <a name="l00404"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a7dd234a650aeb1c6c3fef7c312f51100">00404</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a> ( <span class="keyword">const</span> std::string & name, <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * source ) <a name="l00405"></a>00405 : m_type ( name ), <a name="l00406"></a>00406 m_dataSource ( source ) <a name="l00407"></a>00407 { <a name="l00408"></a>00408 } <a name="l00409"></a>00409 <a name="l00413"></a>00413 <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource::</a> <a name="l00414"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a0b402632a0a3ea4d210484ee79ded703">00414</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a>(<span class="keyword">const</span> std::string & dataSource) <a name="l00415"></a>00415 : m_type(dataSource) { <a name="l00416"></a>00416 <span class="keywordflow">if</span> (dataSource == <span class="stringliteral">"ListTuple"</span>) { <a name="l00417"></a>00417 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a>(); <a name="l00418"></a>00418 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dataSource == <span class="stringliteral">"NTuple"</span>) { <a name="l00419"></a>00419 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a>(); <a name="l00420"></a>00420 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00421"></a>00421 <span class="preprocessor"></span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dataSource == <span class="stringliteral">"NumArrayTuple"</span>) { <a name="l00422"></a>00422 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a>(); <a name="l00423"></a>00423 <span class="preprocessor">#else</span> <a name="l00424"></a>00424 <span class="preprocessor"></span> } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (dataSource == <span class="stringliteral">"NumArrayTuple"</span>) { <a name="l00425"></a>00425 <span class="keywordflow">throw</span> std::runtime_error (<span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00426"></a>00426 <span class="stringliteral">"numeric Python soupport"</span> ); <a name="l00427"></a>00427 <span class="preprocessor">#endif</span> <a name="l00428"></a>00428 <span class="preprocessor"></span> } <span class="keywordflow">else</span> { <a name="l00429"></a>00429 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Invalid DataSource: "</span> + dataSource); <a name="l00430"></a>00430 } <a name="l00431"></a>00431 } <a name="l00432"></a>00432 <a name="l00433"></a>00433 <a class="code" href="classhippodraw_1_1PyDataSource.html#a082a7a6e31ce796a088a720bf58f9587">PyDataSource::</a> <a name="l00434"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a082a7a6e31ce796a088a720bf58f9587">00434</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a082a7a6e31ce796a088a720bf58f9587">~PyDataSource</a>() <a name="l00435"></a>00435 { <a name="l00436"></a>00436 <span class="keyword">delete</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>; <a name="l00437"></a>00437 } <a name="l00438"></a>00438 <a name="l00439"></a>00439 <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a> * <a name="l00440"></a>00440 <a class="code" href="classhippodraw_1_1PyDataSource.html#a3457559d05aeab1cc59b98f0ed18a127" title="Returns a new PyDataSource that wraps the current DataSource in the DataSourceController...">PyDataSource::</a> <a name="l00441"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a3457559d05aeab1cc59b98f0ed18a127">00441</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a3457559d05aeab1cc59b98f0ed18a127" title="Returns a new PyDataSource that wraps the current DataSource in the DataSourceController...">getCurrentDataSource</a> () <a name="l00442"></a>00442 { <a name="l00443"></a>00443 <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a> * array = 0; <a name="l00444"></a>00444 <a name="l00445"></a>00445 <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * controller = <a class="code" href="classhippodraw_1_1DataSourceController.html#a4d152e42bfc604fb12ca5656a68017a9" title="Returns the pointer to the singleton instance.">DataSourceController::instance</a> (); <a name="l00446"></a>00446 <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * source = controller -> getCurrent (); <a name="l00447"></a>00447 <a name="l00448"></a>00448 <span class="keywordflow">if</span> ( source != 0 ) { <a name="l00449"></a>00449 <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> * ntuple = dynamic_cast < <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> * > ( source ); <a name="l00450"></a>00450 <span class="keywordflow">if</span> ( ntuple != 0 ) { <a name="l00451"></a>00451 array = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a> ( <span class="stringliteral">"NTuple"</span>, source ); <a name="l00452"></a>00452 } <a name="l00453"></a>00453 <a name="l00454"></a>00454 <a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> * ltuple = dynamic_cast < <a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> * > ( source ); <a name="l00455"></a>00455 <span class="keywordflow">if</span> ( ltuple != 0 ) { <a name="l00456"></a>00456 array = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a> ( <span class="stringliteral">"ListTuple"</span>, source ); <a name="l00457"></a>00457 } <a name="l00458"></a>00458 <a name="l00459"></a>00459 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00460"></a>00460 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> * natuple = dynamic_cast < <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> * > ( source ); <a name="l00461"></a>00461 <span class="keywordflow">if</span> ( natuple != 0 ) { <a name="l00462"></a>00462 array = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a> ( <span class="stringliteral">"NumArrayTuple"</span>, source ); <a name="l00463"></a>00463 } <a name="l00464"></a>00464 <span class="preprocessor">#endif</span> <a name="l00465"></a>00465 <span class="preprocessor"></span> <a name="l00466"></a>00466 <span class="preprocessor">#ifdef HAVE_CFITSIO</span> <a name="l00467"></a>00467 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &lt; DataColumn * &gt; objects.">FitsNTuple</a> * fntuple = dynamic_cast < <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &lt; DataColumn * &gt; objects.">FitsNTuple</a> * > ( source ); <a name="l00468"></a>00468 <span class="keywordflow">if</span> ( fntuple != 0 ) { <a name="l00469"></a>00469 array = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a> ( <span class="stringliteral">"FitsNTuple"</span>, source ); <a name="l00470"></a>00470 } <a name="l00471"></a>00471 <span class="preprocessor">#endif</span> <a name="l00472"></a>00472 <span class="preprocessor"></span> <a name="l00473"></a>00473 <span class="preprocessor">#ifdef HAVE_ROOT</span> <a name="l00474"></a>00474 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1RootNTuple.html" title="A DataSource class implemented with a ROOT TBranch objects from a ROOT TTree to store...">RootNTuple</a> * rntuple = dynamic_cast < <a class="code" href="classhippodraw_1_1RootNTuple.html" title="A DataSource class implemented with a ROOT TBranch objects from a ROOT TTree to store...">RootNTuple</a> * > ( source ); <a name="l00475"></a>00475 <span class="keywordflow">if</span> ( rntuple != 0 ) { <a name="l00476"></a>00476 array = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a> ( <span class="stringliteral">"RootNTuple"</span>, source ); <a name="l00477"></a>00477 } <a name="l00478"></a>00478 <span class="preprocessor">#endif</span> <a name="l00479"></a>00479 <span class="preprocessor"></span> } <a name="l00480"></a>00480 <a name="l00481"></a>00481 <a name="l00482"></a>00482 <span class="keywordflow">return</span> array; <a name="l00483"></a>00483 } <a name="l00484"></a>00484 <a name="l00485"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a903d6ffef3ddea0d904a5336e231b643">00485</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a903d6ffef3ddea0d904a5336e231b643">PyDataSource::columns</a>()<span class="keyword"> const </span>{ <a name="l00486"></a>00486 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a903d6ffef3ddea0d904a5336e231b643" title="Returns the number of columns or data arrays available from this DataSource.">columns</a>(); <a name="l00487"></a>00487 } <a name="l00488"></a>00488 <a name="l00489"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a2b76a8f13ad489df9fa8cc9452c9012b">00489</a> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a2b76a8f13ad489df9fa8cc9452c9012b">PyDataSource::rows</a>()<span class="keyword"> const </span>{ <a name="l00490"></a>00490 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a1d2abe9c739bf78a94515f803cf926e7" title="Returns the number of rows.">rows</a>(); <a name="l00491"></a>00491 } <a name="l00492"></a>00492 <a name="l00493"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a98de8e590ee20cbb6aa9c564d79c71ee">00493</a> <span class="keyword">const</span> std::string & <a class="code" href="classhippodraw_1_1PyDataSource.html#a98de8e590ee20cbb6aa9c564d79c71ee" title="The title of the DataSource.">PyDataSource::getTitle</a>()<span class="keyword"> const </span>{ <a name="l00494"></a>00494 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#afea7e0d9518a202a10d7a14222d7ca13" title="Returns a const reference to the title of the data source.">title</a>(); <a name="l00495"></a>00495 } <a name="l00496"></a>00496 <a name="l00497"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#abc79cf0667bbb5c93fca3f01b52c7b57">00497</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#abc79cf0667bbb5c93fca3f01b52c7b57">PyDataSource::setTitle</a>(<span class="keyword">const</span> std::string & title) { <a name="l00498"></a>00498 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#abc79cf0667bbb5c93fca3f01b52c7b57" title="Sets the title of the data source to title.">setTitle</a>(title); <a name="l00499"></a>00499 } <a name="l00500"></a>00500 <a name="l00501"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a9d3a2685df23b5e7cbf59c19c4a1f9b5">00501</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a9d3a2685df23b5e7cbf59c19c4a1f9b5" title="Set the name of the DataSource.">PyDataSource::setName</a>(<span class="keyword">const</span> std::string & name) { <a name="l00502"></a>00502 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a9d3a2685df23b5e7cbf59c19c4a1f9b5" title="Sets the name of the data source.">setName</a>(name); <a name="l00503"></a>00503 } <a name="l00504"></a>00504 <a name="l00505"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#aa369dc17424da2fe359d1ce9dd2c8b81">00505</a> <span class="keyword">const</span> std::vector<std::string> & <a class="code" href="classhippodraw_1_1PyDataSource.html#aa369dc17424da2fe359d1ce9dd2c8b81" title="Get the column names.">PyDataSource::getLabels</a>()<span class="keyword"> const </span>{ <a name="l00506"></a>00506 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a5f883b623617dd5f66e2fa57216c9397" title="Returns the list of available labels.">getLabels</a>(); <a name="l00507"></a>00507 } <a name="l00508"></a>00508 <a name="l00509"></a>00509 <span class="keyword">const</span> std::vector<double> & <a name="l00510"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a92a8754d2dfae66f8e8a56066ecd7314">00510</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a92a8754d2dfae66f8e8a56066ecd7314" title="Get a column as a tuple of floats by column name.">PyDataSource::getColumn</a>(<span class="keyword">const</span> std::string & name)<span class="keyword"> const </span>{ <a name="l00511"></a>00511 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a0504a66c08cf544452f613aa8ea2390d" title="Returns the data in the column with label name.">getColumn</a>(name); <a name="l00512"></a>00512 } <a name="l00513"></a>00513 <a name="l00514"></a>00514 <span class="keyword">const</span> std::vector<double> & <a name="l00515"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#ac80adb4b1c202ef5f5e5ae84b91cab25">00515</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a92a8754d2dfae66f8e8a56066ecd7314" title="Get a column as a tuple of floats by column name.">PyDataSource::getColumn</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index)<span class="keyword"> const </span>{ <a name="l00516"></a>00516 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a0504a66c08cf544452f613aa8ea2390d" title="Returns the data in the column with label name.">getColumn</a>(index); <a name="l00517"></a>00517 } <a name="l00518"></a>00518 <a name="l00519"></a>00519 <span class="keywordtype">void</span> <a name="l00520"></a>00520 <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">PyDataSource::</a> <a name="l00521"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2">00521</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> (<span class="keyword">const</span> std::string & label, <a name="l00522"></a>00522 <span class="keyword">const</span> std::vector < double > & col ) <a name="l00523"></a>00523 { <a name="l00524"></a>00524 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NTuple"</span> || <a name="l00525"></a>00525 <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"FitsNTuple"</span> || <a name="l00526"></a>00526 <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"RootNTuple"</span> ) { <a name="l00527"></a>00527 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( label, col ); <a name="l00528"></a>00528 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"ListTuple"</span>) { <a name="l00529"></a>00529 <a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00530"></a>00530 <a class="code" href="classboost_1_1python_1_1list.html" title="A wrapper class for Python list objects.">boost::python::list</a> seq(col); <a name="l00531"></a>00531 nt-><a class="code" href="classhippodraw_1_1ListTuple.html#a19ff5a6871a105b2e45b38fa0ff243e2" title="Replaces the column indexed by index with the array.">replaceColumn</a>(label, seq); <a name="l00532"></a>00532 } <span class="keywordflow">else</span> { <a name="l00533"></a>00533 std::string what(<span class="stringliteral">"Cannot replace a column of this type in a "</span> + <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>); <a name="l00534"></a>00534 <span class="keywordflow">throw</span> std::runtime_error(what); <a name="l00535"></a>00535 } <a name="l00536"></a>00536 } <a name="l00537"></a>00537 <a name="l00538"></a>00538 <span class="keywordtype">void</span> <a name="l00539"></a>00539 <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">PyDataSource::</a> <a name="l00540"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#acd6c87247a56525f515f9caa5227a116">00540</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index, <a name="l00541"></a>00541 <span class="keyword">const</span> std::vector < double > & col) <a name="l00542"></a>00542 { <a name="l00543"></a>00543 <span class="keyword">const</span> std::vector<std::string> & names = <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a5f883b623617dd5f66e2fa57216c9397" title="Returns the list of available labels.">getLabels</a>(); <a name="l00544"></a>00544 <span class="keywordflow">if</span> ( index < names.size() ) { <a name="l00545"></a>00545 <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a>(names[index], col); <a name="l00546"></a>00546 } <span class="keywordflow">else</span> { <a name="l00547"></a>00547 std::string what ( <span class="stringliteral">"Invalid column index: "</span> ); <a name="l00548"></a>00548 what += <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">hippodraw::String::convert</a> ( index ); <a name="l00549"></a>00549 <span class="keywordflow">throw</span> std::runtime_error ( what ); <a name="l00550"></a>00550 } <a name="l00551"></a>00551 } <a name="l00552"></a>00552 <a name="l00553"></a>00553 <span class="keywordtype">void</span> <a name="l00554"></a>00554 <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">PyDataSource::</a> <a name="l00555"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a5f314cba2cdd26a743d0af497495575b">00555</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( <span class="keyword">const</span> std::string & label, <a name="l00556"></a>00556 boost::python::numeric::array array) <a name="l00557"></a>00557 { <a name="l00558"></a>00558 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00559"></a>00559 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00560"></a>00560 <span class="keywordflow">if</span> (!nt) { <a name="l00561"></a>00561 std::string what(<span class="stringliteral">"Cannot replace a column of this type in a "</span> + <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>); <a name="l00562"></a>00562 <span class="keywordflow">throw</span> std::runtime_error(what); <a name="l00563"></a>00563 } <a name="l00564"></a>00564 nt-><a class="code" href="classhippodraw_1_1NumArrayTuple.html#a635bb26070528124f48d9d670dfb87bd" title="Replaces the column indexed by index with the array.">replaceColumn</a>(label, array); <a name="l00565"></a>00565 <span class="preprocessor">#else</span> <a name="l00566"></a>00566 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error ( <span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00567"></a>00567 <span class="stringliteral">"numeric Python suppport"</span> ); <a name="l00568"></a>00568 <span class="preprocessor">#endif</span> <a name="l00569"></a>00569 <span class="preprocessor"></span>} <a name="l00570"></a>00570 <a name="l00571"></a>00571 <span class="keywordtype">void</span> <a name="l00572"></a>00572 <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">PyDataSource::</a> <a name="l00573"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a635bb26070528124f48d9d670dfb87bd">00573</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index, <a name="l00574"></a>00574 boost::python::numeric::array array ) <a name="l00575"></a>00575 { <a name="l00576"></a>00576 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00577"></a>00577 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00578"></a>00578 <span class="keywordflow">if</span> (!nt) { <a name="l00579"></a>00579 std::string what(<span class="stringliteral">"Cannot replace a column of this type in a "</span> + <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>); <a name="l00580"></a>00580 <span class="keywordflow">throw</span> std::runtime_error(what); <a name="l00581"></a>00581 } <a name="l00582"></a>00582 nt-><a class="code" href="classhippodraw_1_1NumArrayTuple.html#a635bb26070528124f48d9d670dfb87bd" title="Replaces the column indexed by index with the array.">replaceColumn</a>(index, array); <a name="l00583"></a>00583 <span class="preprocessor">#else</span> <a name="l00584"></a>00584 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error ( <span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00585"></a>00585 <span class="stringliteral">"numeric Python suppport"</span> ); <a name="l00586"></a>00586 <span class="preprocessor">#endif</span> <a name="l00587"></a>00587 <span class="preprocessor"></span>} <a name="l00588"></a>00588 <a name="l00589"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47">00589</a> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">PyDataSource::addColumn</a>( <span class="keyword">const</span> std::string & label, <a name="l00590"></a>00590 <span class="keyword">const</span> std::vector<double> & col ) { <a name="l00591"></a>00591 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NTuple"</span>) { <a name="l00592"></a>00592 <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00593"></a>00593 <span class="keywordflow">return</span> nt-><a class="code" href="classhippodraw_1_1NTuple.html#a904fc609e925ee9d7a4f49a4125b33ab" title="Adds a column to the end of the ntuple and returns the index to the added column...">addColumn</a>(label, col); <a name="l00594"></a>00594 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"ListTuple"</span>) { <a name="l00595"></a>00595 <a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00596"></a>00596 <a class="code" href="classboost_1_1python_1_1list.html" title="A wrapper class for Python list objects.">boost::python::list</a> seq(col); <a name="l00597"></a>00597 <span class="keywordflow">return</span> nt-><a class="code" href="classhippodraw_1_1ListTuple.html#a7f2913d71b204828f7d3b0ae1b6d384c" title="Adds a column to the end of the ListTuple.">addColumn</a>(label, seq); <a name="l00598"></a>00598 } <span class="keywordflow">else</span> { <a name="l00599"></a>00599 std::string what(<span class="stringliteral">"Cannot add a column of this type to a "</span> + <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>); <a name="l00600"></a>00600 <span class="keywordflow">throw</span> std::runtime_error(what); <a name="l00601"></a>00601 } <a name="l00602"></a>00602 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a903d6ffef3ddea0d904a5336e231b643" title="Returns the number of columns or data arrays available from this DataSource.">columns</a>(); <a name="l00603"></a>00603 } <a name="l00604"></a>00604 <a name="l00605"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a3819df12544a637523c37c05b7b24f76">00605</a> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">PyDataSource::addColumn</a>( <span class="keyword">const</span> std::string & label, <a name="l00606"></a>00606 boost::python::numeric::array array ) { <a name="l00607"></a>00607 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00608"></a>00608 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00609"></a>00609 <span class="keywordflow">if</span> (!nt) { <a name="l00610"></a>00610 std::string what(<span class="stringliteral">"Cannot add a column of this type to a "</span> + <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>); <a name="l00611"></a>00611 <span class="keywordflow">throw</span> std::runtime_error(what); <a name="l00612"></a>00612 } <a name="l00613"></a>00613 <span class="keywordflow">return</span> nt-><a class="code" href="classhippodraw_1_1NumArrayTuple.html#a3819df12544a637523c37c05b7b24f76" title="Adds a column to the end of the NumArrayTuple.">addColumn</a>(label, array); <a name="l00614"></a>00614 <span class="preprocessor">#else</span> <a name="l00615"></a>00615 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error ( <span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00616"></a>00616 <span class="stringliteral">"numeric Python support"</span> ); <a name="l00617"></a>00617 <span class="preprocessor">#endif</span> <a name="l00618"></a>00618 <span class="preprocessor"></span>} <a name="l00619"></a>00619 <a name="l00620"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#ac8bb3912a3ce86b15842e79d0b421204">00620</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac8bb3912a3ce86b15842e79d0b421204" title="Clear the data elements of the DataSource.">PyDataSource::clear</a>() { <a name="l00621"></a>00621 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a5eeb94d22b8366d1b68d0614384802fe" title="Clears the data source.">clear</a>(); <a name="l00622"></a>00622 } <a name="l00623"></a>00623 <a name="l00624"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310">00624</a> <span class="keywordtype">bool</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">PyDataSource::hasColumn</a>(<span class="keyword">const</span> std::string & colname)<span class="keyword"> const </span>{ <a name="l00625"></a>00625 <span class="keyword">const</span> std::vector<std::string> & names = <a class="code" href="classhippodraw_1_1PyDataSource.html#aa369dc17424da2fe359d1ce9dd2c8b81" title="Get the column names.">getLabels</a>(); <a name="l00626"></a>00626 <span class="keywordflow">return</span> std::find(names.begin(), names.end(), colname) != names.end(); <a name="l00627"></a>00627 } <a name="l00628"></a>00628 <a name="l00629"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a7d8e265fd7e84a7d8dba60325d5924ac">00629</a> <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#af45f2d9804b33387f930fa8207520544" title="Register this DataSource, returning a unique name.">PyDataSource::registerNTuple</a>( <span class="keyword">const</span> std::string & name ) { <a name="l00630"></a>00630 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a9d3a2685df23b5e7cbf59c19c4a1f9b5" title="Sets the name of the data source.">setName</a>(name); <a name="l00631"></a>00631 <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * controller = <a class="code" href="classhippodraw_1_1DataSourceController.html#a4d152e42bfc604fb12ca5656a68017a9" title="Returns the pointer to the singleton instance.">DataSourceController::instance</a>(); <a name="l00632"></a>00632 controller-><a class="code" href="classhippodraw_1_1DataSourceController.html#a36f566288e01236f92e4430a26c91283" title="Register a DataSource.">registerNTuple</a>(name, <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00633"></a>00633 } <a name="l00634"></a>00634 <a name="l00635"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#af45f2d9804b33387f930fa8207520544">00635</a> std::string <a class="code" href="classhippodraw_1_1PyDataSource.html#af45f2d9804b33387f930fa8207520544" title="Register this DataSource, returning a unique name.">PyDataSource::registerNTuple</a>() { <a name="l00636"></a>00636 <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * controller = <a class="code" href="classhippodraw_1_1DataSourceController.html#a4d152e42bfc604fb12ca5656a68017a9" title="Returns the pointer to the singleton instance.">DataSourceController::instance</a>(); <a name="l00637"></a>00637 <span class="keywordflow">return</span> controller-><a class="code" href="classhippodraw_1_1DataSourceController.html#a36f566288e01236f92e4430a26c91283" title="Register a DataSource.">registerNTuple</a>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00638"></a>00638 } <a name="l00639"></a>00639 <a name="l00640"></a>00640 boost::python::numeric::array <a name="l00641"></a>00641 <a class="code" href="classhippodraw_1_1PyDataSource.html#a19ea45b2f8e2570d61a73a5d4c208a4d" title="Return a column from the DataSource as a numarray object, indexing by column label...">PyDataSource::</a> <a name="l00642"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a19ea45b2f8e2570d61a73a5d4c208a4d">00642</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a19ea45b2f8e2570d61a73a5d4c208a4d" title="Return a column from the DataSource as a numarray object, indexing by column label...">columnAsNumArray</a>( <span class="keyword">const</span> std::string & colname )<span class="keyword"> const</span> <a name="l00643"></a>00643 <span class="keyword"></span>{ <a name="l00644"></a>00644 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00645"></a>00645 <span class="preprocessor"></span> <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NumArrayTuple"</span>) { <a name="l00646"></a>00646 <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00647"></a>00647 boost::python::numeric::array a = nt-><a class="code" href="classhippodraw_1_1NumArrayTuple.html#a576b62321c3ec3f3726c13741135178a" title="Return the reference to the desired numarray by column label.">getNumArray</a>(colname); <a name="l00648"></a>00648 <span class="keywordflow">return</span> a; <a name="l00649"></a>00649 } <a name="l00650"></a>00650 <a name="l00651"></a>00651 <span class="preprocessor">#ifdef HAVE_ROOT</span> <a name="l00652"></a>00652 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"RootNTuple"</span> ) { <a name="l00653"></a>00653 <a class="code" href="classhippodraw_1_1QtRootNTuple.html" title="A wrapper for RootNTuple, so that when RootNTuple is used in Qt based application...">QtRootNTuple</a> * <a class="code" href="classboost_1_1python_1_1tuple.html" title="A wrapper class for Python tuple objects.">tuple</a> = dynamic_cast < <a class="code" href="classhippodraw_1_1QtRootNTuple.html" title="A wrapper for RootNTuple, so that when RootNTuple is used in Qt based application...">QtRootNTuple</a> *> ( <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> ); <a name="l00654"></a>00654 boost::python::numeric::array a = tuple -> getColumnAsArray ( colname ); <a name="l00655"></a>00655 <span class="keywordflow">return</span> a; <a name="l00656"></a>00656 } <a name="l00657"></a>00657 <span class="preprocessor">#endif</span> <a name="l00658"></a>00658 <span class="preprocessor"></span> <a name="l00659"></a>00659 <span class="keyword">typedef</span> std::vector<double> <a class="codeRef" doxygen="Minuit.tag:http://seal.web.cern.ch/seal/MathLibs/Minuit/html/" href="http://seal.web.cern.ch/seal/MathLibs/Minuit/html/classvec.html">vec</a>; <a name="l00660"></a>00660 <span class="keyword">const</span> vec & array = <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a0504a66c08cf544452f613aa8ea2390d" title="Returns the data in the column with label name.">getColumn</a>(colname); <a name="l00661"></a>00661 std::vector < int > <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a>; <a name="l00662"></a>00662 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> fillShape ( shape, colname ); <a name="l00663"></a>00663 numeric::array na <a name="l00664"></a>00664 = <a class="code" href="namespacenum__util.html#a60c82c3b5ac76cd97b322ad93b443f82">num_util::makeNum</a> ( &const_cast<vec &>( array )[0], shape ); <a name="l00665"></a>00665 <span class="keywordflow">return</span> na; <a name="l00666"></a>00666 <span class="preprocessor">#else</span> <a name="l00667"></a>00667 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error (<span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00668"></a>00668 <span class="stringliteral">"numeric Python support"</span> ); <a name="l00669"></a>00669 <span class="preprocessor">#endif // HAVE_NUMARRAY</span> <a name="l00670"></a>00670 <span class="preprocessor"></span>} <a name="l00671"></a>00671 <a name="l00672"></a>00672 boost::python::numeric::array <a name="l00673"></a>00673 <a class="code" href="classhippodraw_1_1PyDataSource.html#a19ea45b2f8e2570d61a73a5d4c208a4d" title="Return a column from the DataSource as a numarray object, indexing by column label...">PyDataSource::</a> <a name="l00674"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#ac33537b91ca131a3b55864c54c1ab414">00674</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a19ea45b2f8e2570d61a73a5d4c208a4d" title="Return a column from the DataSource as a numarray object, indexing by column label...">columnAsNumArray</a> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index )<span class="keyword"> const </span>{ <a name="l00675"></a>00675 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00676"></a>00676 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( index < <a class="code" href="classhippodraw_1_1PyDataSource.html#a903d6ffef3ddea0d904a5336e231b643">columns</a>() ) { <a name="l00677"></a>00677 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NumArrayTuple"</span>) { <a name="l00678"></a>00678 <a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NumArrayTuple.html" title="A DataSource class implemented with a Python numarray array to store the column data...">NumArrayTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00679"></a>00679 <span class="keywordflow">return</span> nt-><a class="code" href="classhippodraw_1_1NumArrayTuple.html#a576b62321c3ec3f3726c13741135178a" title="Return the reference to the desired numarray by column label.">getNumArray</a>(index); <a name="l00680"></a>00680 } <a name="l00681"></a>00681 <span class="keyword">typedef</span> std::vector<double> <a class="codeRef" doxygen="Minuit.tag:http://seal.web.cern.ch/seal/MathLibs/Minuit/html/" href="http://seal.web.cern.ch/seal/MathLibs/Minuit/html/classvec.html">vec</a>; <a name="l00682"></a>00682 <span class="keyword">const</span> vec & array = <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>-><a class="code" href="classhippodraw_1_1DataSource.html#a0504a66c08cf544452f613aa8ea2390d" title="Returns the data in the column with label name.">getColumn</a>(index); <a name="l00683"></a>00683 std::vector < int > <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a>; <a name="l00684"></a>00684 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> fillShape ( shape, index ); <a name="l00685"></a>00685 numeric::array na = <a name="l00686"></a>00686 <a class="code" href="namespacenum__util.html#a60c82c3b5ac76cd97b322ad93b443f82">num_util::makeNum</a> ( &const_cast <vec &> ( array )[0], shape ); <a name="l00687"></a>00687 <span class="keywordflow">return</span> na; <a name="l00688"></a>00688 } <span class="keywordflow">else</span> { <a name="l00689"></a>00689 <span class="keywordflow">throw</span> <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html">StopIteration</a>(<span class="stringliteral">"index out-of-range"</span>); <a name="l00690"></a>00690 } <a name="l00691"></a>00691 <span class="preprocessor">#else</span> <a name="l00692"></a>00692 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error ( <span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00693"></a>00693 <span class="stringliteral">"numeric Python support"</span> ); <a name="l00694"></a>00694 <span class="preprocessor">#endif</span> <a name="l00695"></a>00695 <span class="preprocessor"></span>} <a name="l00696"></a>00696 <a name="l00697"></a>00697 <span class="keywordtype">void</span> <a name="l00698"></a>00698 <a class="code" href="classhippodraw_1_1PyDataSource.html#aa80efa698dafce26e6b5bbccd7f9cccc" title="Checks the rank of the array.">PyDataSource::</a> <a name="l00699"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#aa80efa698dafce26e6b5bbccd7f9cccc">00699</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#aa80efa698dafce26e6b5bbccd7f9cccc" title="Checks the rank of the array.">checkRank</a> ( boost::python::numeric::array array ) <a name="l00700"></a>00700 { <a name="l00701"></a>00701 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00702"></a>00702 <span class="preprocessor"></span> <span class="keywordtype">int</span> rank = <a class="code" href="namespacenum__util.html#a59851d76f9624ac3de899f818f9e0a6b">num_util::rank</a> ( array ); <a name="l00703"></a>00703 <span class="keywordflow">if</span> ( rank > 1 ) { <a name="l00704"></a>00704 std::string what ( <span class="stringliteral">"DataArray: Can not add "</span> ); <a name="l00705"></a>00705 what += <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">hippodraw::String::convert</a> ( rank ); <a name="l00706"></a>00706 what += <span class="stringliteral">" dimensional array\n to "</span>; <a name="l00707"></a>00707 what += <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>; <a name="l00708"></a>00708 <span class="keywordflow">throw</span> std::runtime_error ( what ); <a name="l00709"></a>00709 } <a name="l00710"></a>00710 <span class="preprocessor">#endif</span> <a name="l00711"></a>00711 <span class="preprocessor"></span>} <a name="l00712"></a>00712 <a name="l00713"></a>00713 <span class="keywordtype">void</span> <a name="l00714"></a>00714 <a class="code" href="classhippodraw_1_1PyDataSource.html#a76e160bcea311b6220182ef0e52e0f20" title="Replaces or add column vector.">PyDataSource::</a> <a name="l00715"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a76e160bcea311b6220182ef0e52e0f20">00715</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a76e160bcea311b6220182ef0e52e0f20" title="Replaces or add column vector.">saveColumn</a> ( <span class="keyword">const</span> std::string & label, <a name="l00716"></a>00716 <span class="keyword">const</span> std::vector < double > & v, <a name="l00717"></a>00717 <span class="keyword">const</span> std::vector < intptr_t > & <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a> ) <a name="l00718"></a>00718 { <a name="l00719"></a>00719 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">hasColumn</a> ( label ) ) { <a name="l00720"></a>00720 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( label, v, shape ); <a name="l00721"></a>00721 } <span class="keywordflow">else</span> { <a name="l00722"></a>00722 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">addColumn</a> ( label, v, shape ); <a name="l00723"></a>00723 } <a name="l00724"></a>00724 } <a name="l00725"></a>00725 <a name="l00726"></a>00726 <span class="keywordtype">void</span> <a name="l00727"></a>00727 <a class="code" href="classhippodraw_1_1PyDataSource.html#a6df19d2008a22273c0a4cbf2546706be" title="Replace or add a column from a numarray object, indexing by column label.">PyDataSource::</a> <a name="l00728"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a6df19d2008a22273c0a4cbf2546706be">00728</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a6df19d2008a22273c0a4cbf2546706be" title="Replace or add a column from a numarray object, indexing by column label.">saveColumnFromNumArray</a> ( <span class="keyword">const</span> std::string & label, <a name="l00729"></a>00729 boost::python::numeric::array array ) <a name="l00730"></a>00730 { <a name="l00731"></a>00731 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00732"></a>00732 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1PyApp.html#aa81aed607133209dade63a226818224d" title="Obtains a lock on the application&#39;s mutex.">PyApp::lock</a> (); <a name="l00733"></a>00733 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NumArrayTuple"</span>) { <a name="l00734"></a>00734 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">hasColumn</a>(label)) { <a name="l00735"></a>00735 <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a>(label, array); <a name="l00736"></a>00736 } <span class="keywordflow">else</span> { <a name="l00737"></a>00737 <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">addColumn</a>(label, array); <a name="l00738"></a>00738 } <a name="l00739"></a>00739 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a>(); <a name="l00740"></a>00740 <span class="keywordflow">return</span>; <a name="l00741"></a>00741 } <a name="l00742"></a>00742 <a name="l00743"></a>00743 <span class="preprocessor">#ifdef HAVE_CFITSIO</span> <a name="l00744"></a>00744 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &lt; DataColumn * &gt; objects.">FitsNTuple</a> * fnt = dynamic_cast < <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &lt; DataColumn * &gt; objects.">FitsNTuple</a> * > ( <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> ); <a name="l00745"></a>00745 <span class="keywordflow">if</span> ( fnt != 0 ) { <a name="l00746"></a>00746 std::vector < double > <a class="codeRef" doxygen="Minuit.tag:http://seal.web.cern.ch/seal/MathLibs/Minuit/html/" href="http://seal.web.cern.ch/seal/MathLibs/Minuit/html/classvec.html">vec</a>; <a name="l00747"></a>00747 ::extractVector ( array, vec ); <a name="l00748"></a>00748 <a name="l00749"></a>00749 <span class="keyword">const</span> std::vector < intptr_t > <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a> = <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">num_util::shape</a> ( array ); <a name="l00750"></a>00750 <a class="code" href="classhippodraw_1_1PyDataSource.html#a76e160bcea311b6220182ef0e52e0f20" title="Replaces or add column vector.">saveColumn</a> ( label, vec, shape ); <a name="l00751"></a>00751 <a name="l00752"></a>00752 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a>(); <a name="l00753"></a>00753 <span class="keywordflow">return</span>; <a name="l00754"></a>00754 } <a name="l00755"></a>00755 <span class="preprocessor">#endif // cfitsio</span> <a name="l00756"></a>00756 <span class="preprocessor"></span> <a name="l00757"></a>00757 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"ListTuple"</span>) { <a name="l00758"></a>00758 <a class="code" href="classboost_1_1python_1_1list.html" title="A wrapper class for Python list objects.">boost::python::list</a> seq(array); <a name="l00759"></a>00759 <a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00760"></a>00760 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">hasColumn</a>(label)) { <a name="l00761"></a>00761 nt-><a class="code" href="classhippodraw_1_1ListTuple.html#a19ff5a6871a105b2e45b38fa0ff243e2" title="Replaces the column indexed by index with the array.">replaceColumn</a>(label, seq); <a name="l00762"></a>00762 } <span class="keywordflow">else</span> { <a name="l00763"></a>00763 nt-><a class="code" href="classhippodraw_1_1ListTuple.html#a7f2913d71b204828f7d3b0ae1b6d384c" title="Adds a column to the end of the ListTuple.">addColumn</a>(label, seq); <a name="l00764"></a>00764 } <a name="l00765"></a>00765 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a>(); <a name="l00766"></a>00766 <span class="keywordflow">return</span>; <a name="l00767"></a>00767 } <a name="l00768"></a>00768 <a name="l00769"></a>00769 <a class="code" href="classhippodraw_1_1PyDataSource.html#aa80efa698dafce26e6b5bbccd7f9cccc" title="Checks the rank of the array.">checkRank</a> ( array ); <a name="l00770"></a>00770 std::vector<double> col; <a name="l00771"></a>00771 ::extractVector(array, col); <a name="l00772"></a>00772 <a name="l00773"></a>00773 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NTuple"</span>) { <a name="l00774"></a>00774 <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00775"></a>00775 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">hasColumn</a>(label)) { <a name="l00776"></a>00776 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -><a class="code" href="classhippodraw_1_1DataSource.html#ae712d89bfbd862629a0ae10b8b78bfd1" title="Replaces data in column label with contents of array.">replaceColumn</a> ( label, col ); <a name="l00777"></a>00777 } <span class="keywordflow">else</span> { <a name="l00778"></a>00778 nt-><a class="code" href="classhippodraw_1_1NTuple.html#a904fc609e925ee9d7a4f49a4125b33ab" title="Adds a column to the end of the ntuple and returns the index to the added column...">addColumn</a>(label, col); <a name="l00779"></a>00779 } <a name="l00780"></a>00780 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a>(); <a name="l00781"></a>00781 <span class="keywordflow">return</span>; <a name="l00782"></a>00782 } <a name="l00783"></a>00783 <a name="l00784"></a>00784 <a name="l00785"></a>00785 <span class="preprocessor">#ifdef HAVE_ROOT</span> <a name="l00786"></a>00786 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1RootNTuple.html" title="A DataSource class implemented with a ROOT TBranch objects from a ROOT TTree to store...">RootNTuple</a> * rnt = dynamic_cast < <a class="code" href="classhippodraw_1_1RootNTuple.html" title="A DataSource class implemented with a ROOT TBranch objects from a ROOT TTree to store...">RootNTuple</a> * > ( <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> ); <a name="l00787"></a>00787 <span class="keywordflow">if</span> ( rnt != 0 ) { <a name="l00788"></a>00788 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">hasColumn</a> ( label ) ) { <a name="l00789"></a>00789 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( label, col ); <a name="l00790"></a>00790 } <span class="keywordflow">else</span> { <a name="l00791"></a>00791 rnt -> <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">addColumn</a> ( label, col ); <a name="l00792"></a>00792 } <a name="l00793"></a>00793 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a>(); <a name="l00794"></a>00794 <span class="keywordflow">return</span>; <a name="l00795"></a>00795 } <a name="l00796"></a>00796 <span class="preprocessor">#endif // root</span> <a name="l00797"></a>00797 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a>(); <a name="l00798"></a>00798 <a name="l00799"></a>00799 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"__setitem__ not supported for "</span> + <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>); <a name="l00800"></a>00800 <span class="preprocessor">#else</span> <a name="l00801"></a>00801 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error (<span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00802"></a>00802 <span class="stringliteral">"numeric Python support"</span> ); <a name="l00803"></a>00803 <span class="preprocessor">#endif</span> <a name="l00804"></a>00804 <span class="preprocessor"></span>} <a name="l00805"></a>00805 <a name="l00808"></a>00808 <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a6df19d2008a22273c0a4cbf2546706be" title="Replace or add a column from a numarray object, indexing by column label.">PyDataSource::</a> <a name="l00809"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a15d7bea9a76c5a41ad76627e827fd06e">00809</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a6df19d2008a22273c0a4cbf2546706be" title="Replace or add a column from a numarray object, indexing by column label.">saveColumnFromNumArray</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index, <a name="l00810"></a>00810 boost::python::numeric::array array ) <a name="l00811"></a>00811 { <a name="l00812"></a>00812 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00813"></a>00813 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( index < <a class="code" href="classhippodraw_1_1PyDataSource.html#a903d6ffef3ddea0d904a5336e231b643">columns</a>()) { <a name="l00814"></a>00814 <a name="l00815"></a>00815 <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NumArrayTuple"</span>) { <a name="l00816"></a>00816 <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a>(index, array); <a name="l00817"></a>00817 <span class="keywordflow">return</span>; <a name="l00818"></a>00818 <a name="l00819"></a>00819 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"NTuple"</span>) { <a name="l00820"></a>00820 <a class="code" href="classhippodraw_1_1PyDataSource.html#aa80efa698dafce26e6b5bbccd7f9cccc" title="Checks the rank of the array.">checkRank</a> ( array ); <a name="l00821"></a>00821 std::vector<double> col; <a name="l00822"></a>00822 ::extractVector(array, col); <a name="l00823"></a>00823 <a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1NTuple.html" title="A DataSource class implemented with std::vector&lt;double&gt; to store the column...">NTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00824"></a>00824 nt-><a class="code" href="classhippodraw_1_1NTuple.html#a724450b5a011ae06a5cdcb43ce599754" title="Replaces the data in column col.">replaceColumn</a>(index, col); <a name="l00825"></a>00825 <span class="keywordflow">return</span>; <a name="l00826"></a>00826 <a name="l00827"></a>00827 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a> == <span class="stringliteral">"ListTuple"</span>) { <a name="l00828"></a>00828 <a class="code" href="classboost_1_1python_1_1list.html" title="A wrapper class for Python list objects.">boost::python::list</a> seq(array); <a name="l00829"></a>00829 <a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> * nt = <span class="keyword">dynamic_cast<</span><a class="code" href="classhippodraw_1_1ListTuple.html" title="A DataSource class implemented with a Python list to store the column data.">ListTuple</a> *<span class="keyword">></span>(<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>); <a name="l00830"></a>00830 nt-><a class="code" href="classhippodraw_1_1ListTuple.html#a19ff5a6871a105b2e45b38fa0ff243e2" title="Replaces the column indexed by index with the array.">replaceColumn</a>(index, seq); <a name="l00831"></a>00831 <span class="keywordflow">return</span>; <a name="l00832"></a>00832 } <a name="l00833"></a>00833 <span class="preprocessor">#ifdef HAVE_CFITSIO</span> <a name="l00834"></a>00834 <span class="preprocessor"></span> <span class="keywordflow">else</span> { <a name="l00835"></a>00835 <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &lt; DataColumn * &gt; objects.">FitsNTuple</a> * fnt = dynamic_cast < <a class="code" href="classhippodraw_1_1FitsNTuple.html" title="A DataSource class implemented with a vector &lt; DataColumn * &gt; objects.">FitsNTuple</a> * > ( <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> ); <a name="l00836"></a>00836 <span class="keywordflow">if</span> ( fnt != 0 ) { <a name="l00837"></a>00837 std::vector<double> col; <a name="l00838"></a>00838 ::extractVector ( array, col ); <a name="l00839"></a>00839 <span class="keyword">const</span> std::vector < intptr_t > <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a> = <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">num_util::shape</a> ( array ); <a name="l00840"></a>00840 fnt -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( index, col, shape ); <a name="l00841"></a>00841 <span class="keywordflow">return</span>; <a name="l00842"></a>00842 } <a name="l00843"></a>00843 } <a name="l00844"></a>00844 <span class="preprocessor">#endif</span> <a name="l00845"></a>00845 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error <a name="l00846"></a>00846 (<span class="stringliteral">"__setitem__ by index is not supported for "</span> + <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>); <a name="l00847"></a>00847 } <span class="keywordflow">else</span> { <a name="l00848"></a>00848 std::string what ( <span class="stringliteral">"DataArray:: Attempt to save column "</span> ); <a name="l00849"></a>00849 what += <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">hippodraw::String::convert</a> ( index ); <a name="l00850"></a>00850 what += <span class="stringliteral">" with "</span>; <a name="l00851"></a>00851 what += <a class="code" href="namespacehippodraw_1_1Axes.html#ae2337bddf33bc8b17dd5c08e665422cd" title="Converts from string representation ot Axes::Type representation.">hippodraw::String::convert</a> ( <a class="code" href="classhippodraw_1_1PyDataSource.html#a903d6ffef3ddea0d904a5336e231b643">columns</a> () ); <a name="l00852"></a>00852 what += <span class="stringliteral">" columns in data source"</span>; <a name="l00853"></a>00853 <span class="keywordflow">throw</span> std::runtime_error ( what ); <a name="l00854"></a>00854 } <a name="l00855"></a>00855 <span class="preprocessor">#else</span> <a name="l00856"></a>00856 <span class="preprocessor"></span> <span class="keywordflow">throw</span> std::runtime_error ( <span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00857"></a>00857 <span class="stringliteral">"numeric Python support"</span> ); <a name="l00858"></a>00858 <span class="preprocessor">#endif</span> <a name="l00859"></a>00859 <span class="preprocessor"></span>} <a name="l00860"></a>00860 <a name="l00861"></a>00861 <a name="l00862"></a>00862 <span class="keywordtype">void</span> <a name="l00863"></a>00863 <a class="code" href="classhippodraw_1_1PyDataSource.html#acd1855a4454aa6fc11ddbd432d133011" title="Replace or add a column from vector.">PyDataSource::</a> <a name="l00864"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#acd1855a4454aa6fc11ddbd432d133011">00864</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#acd1855a4454aa6fc11ddbd432d133011" title="Replace or add a column from vector.">saveColumnFrom</a> ( <span class="keyword">const</span> std::string & label, <a name="l00865"></a>00865 <span class="keyword">const</span> std::vector < double > & array ) <a name="l00866"></a>00866 { <a name="l00867"></a>00867 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1PyDataSource.html#a39e3b7738fc6dd9fab374dd90ee5b310" title="Return true if column with label name exists in DataSource.">hasColumn</a> ( label ) ) { <a name="l00868"></a>00868 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a1a1e80f9259f8e456db7ea6a367f17e2" title="Replace a column by its label.">replaceColumn</a> ( label, array ); <a name="l00869"></a>00869 } <a name="l00870"></a>00870 <span class="keywordflow">else</span> { <a name="l00871"></a>00871 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">addColumn</a> ( label, array ); <a name="l00872"></a>00872 } <a name="l00873"></a>00873 } <a name="l00874"></a>00874 <a name="l00875"></a>00875 <span class="keywordtype">void</span> <a name="l00876"></a>00876 <a class="code" href="classhippodraw_1_1PyDataSource.html#a37d713fece0af9b698e3fd17568f5c57" title="Adds a row to the DataSource.">PyDataSource::</a> <a name="l00877"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a37d713fece0af9b698e3fd17568f5c57">00877</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a37d713fece0af9b698e3fd17568f5c57" title="Adds a row to the DataSource.">addRow</a> ( <span class="keyword">const</span> std::vector < double > & row ) <a name="l00878"></a>00878 { <a name="l00879"></a>00879 <a class="code" href="classhippodraw_1_1PyApp.html#aa81aed607133209dade63a226818224d" title="Obtains a lock on the application&#39;s mutex.">PyApp::lock</a> (); <a name="l00880"></a>00880 <span class="keywordflow">try</span> { <a name="l00881"></a>00881 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a37d713fece0af9b698e3fd17568f5c57" title="Adds a row to the DataSource.">addRow</a> ( row ); <a name="l00882"></a>00882 } <a name="l00883"></a>00883 <span class="keywordflow">catch</span> ( <span class="keyword">const</span> std::runtime_error & e ) { <a name="l00884"></a>00884 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a> (); <a name="l00885"></a>00885 <span class="keywordflow">throw</span> e; <a name="l00886"></a>00886 } <a name="l00887"></a>00887 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a> (); <a name="l00888"></a>00888 } <a name="l00889"></a>00889 <a name="l00890"></a>00890 <span class="keywordtype">void</span> <a name="l00891"></a>00891 <a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5" title="Adds all the rows of source to the DataArray.">PyDataSource::</a> <a name="l00892"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5">00892</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5" title="Adds all the rows of source to the DataArray.">append</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * source ) <a name="l00893"></a>00893 { <a name="l00894"></a>00894 <a class="code" href="classhippodraw_1_1PyApp.html#aa81aed607133209dade63a226818224d" title="Obtains a lock on the application&#39;s mutex.">PyApp::lock</a> (); <a name="l00895"></a>00895 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5" title="Adds all the rows of source to the DataArray.">append</a> ( source ); <a name="l00896"></a>00896 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a> (); <a name="l00897"></a>00897 } <a name="l00898"></a>00898 <span class="keywordtype">void</span> <a name="l00899"></a>00899 <a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5" title="Adds all the rows of source to the DataArray.">PyDataSource::</a> <a name="l00900"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a6eab46b6d63662310c2154fe05a3a219">00900</a> <a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5" title="Adds all the rows of source to the DataArray.">append</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1PyDataSource.html" title="This class is the public interface to a DataSource object that the user sees as the...">PyDataSource</a> * source ) <a name="l00901"></a>00901 { <a name="l00902"></a>00902 <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a> -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a8429a83ef387eaa49c68ca4d89c49ca5" title="Adds all the rows of source to the DataArray.">append</a> ( & source -> <a class="code" href="classhippodraw_1_1PyDataSource.html#a5e1620dad6d32635469440fb2c902499" title="Return a reference to the underlying DataSource.">dataSource</a>() ); <a name="l00903"></a>00903 } </pre></div></div> <hr size="1"><address style="align: right;"><small> Generated for HippoDraw Class Library by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border=0> </a> </small></address> </body> </html>