<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.h</h1><a href="PyDataSource_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: c++ -*- */</span> <a name="l00002"></a>00002 <a name="l00014"></a>00014 <span class="preprocessor">#ifndef _PyDataSource_H</span> <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#define _PyDataSource_H</span> <a name="l00016"></a>00016 <span class="preprocessor"></span> <a name="l00017"></a>00017 <span class="preprocessor">#include <exception></span> <a name="l00018"></a>00018 <span class="preprocessor">#include <string></span> <a name="l00019"></a>00019 <span class="preprocessor">#include <vector></span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#ifndef _MSC_VER</span> <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#include <inttypes.h></span> <a name="l00023"></a>00023 <span class="preprocessor">#endif</span> <a name="l00024"></a>00024 <span class="preprocessor"></span> <a name="l00025"></a>00025 <span class="keyword">namespace </span>boost { <a name="l00026"></a>00026 <span class="keyword">namespace </span>python { <a name="l00027"></a>00027 <span class="keyword">namespace </span>numeric { <a name="l00028"></a>00028 <span class="keyword">class </span>array; <a name="l00029"></a>00029 } <a name="l00030"></a>00030 } <a name="l00031"></a>00031 } <a name="l00032"></a>00032 <a name="l00033"></a>00033 <span class="keyword">namespace </span>hippodraw { <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="keyword">class </span>DataSource; <a name="l00036"></a>00036 <a name="l00043"></a><a class="code" href="classhippodraw_1_1PyDataSource.html">00043</a> <span class="keyword">class </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="l00044"></a>00044 { <a name="l00045"></a>00045 <a name="l00046"></a>00046 <span class="keyword">private</span>: <a name="l00047"></a>00047 <a name="l00051"></a>00051 <span class="keywordtype">void</span> <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="l00052"></a>00052 <a name="l00053"></a>00053 <span class="keyword">public</span>: <a name="l00054"></a>00054 <a name="l00056"></a>00056 <a class="code" href="classhippodraw_1_1PyDataSource.html#abed98edd5b063f6daff9a975c39ee5d6" title="Default constructor wraps an ordinary NTuple.">PyDataSource</a>(); <a name="l00057"></a>00057 <a name="l00059"></a>00059 <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 & <a class="code" href="classhippodraw_1_1PyDataSource.html#a5e1620dad6d32635469440fb2c902499" title="Return a reference to the underlying DataSource.">dataSource</a>); <a name="l00060"></a>00060 <a name="l00064"></a>00064 <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="l00065"></a>00065 <a name="l00066"></a>00066 <span class="keyword">virtual</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a082a7a6e31ce796a088a720bf58f9587">~PyDataSource</a>(); <a name="l00067"></a>00067 <a name="l00071"></a>00071 <span class="keyword">static</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 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="l00072"></a>00072 <a name="l00074"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a5e1620dad6d32635469440fb2c902499">00074</a> <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> & <a class="code" href="classhippodraw_1_1PyDataSource.html#a5e1620dad6d32635469440fb2c902499" title="Return a reference to the underlying DataSource.">dataSource</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *<a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>; } <a name="l00075"></a>00075 <a name="l00076"></a>00076 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a903d6ffef3ddea0d904a5336e231b643">columns</a>() <span class="keyword">const</span>; <a name="l00077"></a>00077 <a name="l00078"></a>00078 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a2b76a8f13ad489df9fa8cc9452c9012b">rows</a>() <span class="keyword">const</span>; <a name="l00079"></a>00079 <a name="l00081"></a>00081 <span class="keyword">const</span> std::string & <a class="code" href="classhippodraw_1_1PyDataSource.html#a98de8e590ee20cbb6aa9c564d79c71ee" title="The title of the DataSource.">getTitle</a> () <span class="keyword">const</span>; <a name="l00082"></a>00082 <a name="l00083"></a>00083 <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#abc79cf0667bbb5c93fca3f01b52c7b57">setTitle</a>(<span class="keyword">const</span> std::string & title); <a name="l00084"></a>00084 <a name="l00087"></a>00087 <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#a9d3a2685df23b5e7cbf59c19c4a1f9b5" title="Set the name of the DataSource.">setName</a>(<span class="keyword">const</span> std::string & name); <a name="l00088"></a>00088 <a name="l00090"></a>00090 <span class="keyword">const</span> std::vector<std::string> & <a class="code" href="classhippodraw_1_1PyDataSource.html#aa369dc17424da2fe359d1ce9dd2c8b81" title="Get the column names.">getLabels</a>() <span class="keyword">const</span>; <a name="l00091"></a>00091 <a name="l00093"></a>00093 <span class="keyword">const</span> std::vector<double> & <a class="code" href="classhippodraw_1_1PyDataSource.html#a92a8754d2dfae66f8e8a56066ecd7314" title="Get a column as a tuple of floats by column name.">getColumn</a>(<span class="keyword">const</span> std::string & name) <span class="keyword">const</span>; <a name="l00095"></a>00095 <span class="keyword">const</span> std::vector<double> & <a class="code" href="classhippodraw_1_1PyDataSource.html#a92a8754d2dfae66f8e8a56066ecd7314" title="Get a column as a tuple of floats by column name.">getColumn</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index) <span class="keyword">const</span>; <a name="l00096"></a>00096 <a name="l00098"></a>00098 <span class="keywordtype">void</span> <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 &, <a name="l00099"></a>00099 <span class="keyword">const</span> std::vector<double> & col); <a name="l00100"></a>00100 <a name="l00102"></a>00102 <span class="keywordtype">void</span> <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="l00103"></a>00103 <span class="keyword">const</span> std::vector<double> & col); <a name="l00104"></a>00104 <a name="l00107"></a>00107 <span class="keywordtype">void</span> <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 &, <a name="l00108"></a>00108 boost::python::numeric::array array ); <a name="l00109"></a>00109 <a name="l00112"></a>00112 <span class="keywordtype">void</span> <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="l00113"></a>00113 boost::python::numeric::array array); <a name="l00114"></a>00114 <a name="l00116"></a>00116 <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">addColumn</a>( <span class="keyword">const</span> std::string & label, <a name="l00117"></a>00117 <span class="keyword">const</span> std::vector<double> & col ); <a name="l00118"></a>00118 <a name="l00125"></a>00125 <span class="keywordtype">int</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#aaa0e141ade7a2ab257e2aede33ccff47" title="Add a column to an NTuple or ListTuple.">addColumn</a>( <span class="keyword">const</span> std::string & label, <a name="l00126"></a>00126 boost::python::numeric::array array ); <a name="l00127"></a>00127 <a name="l00129"></a>00129 <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#ac8bb3912a3ce86b15842e79d0b421204" title="Clear the data elements of the DataSource.">clear</a>(); <a name="l00130"></a>00130 <a name="l00133"></a>00133 <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.">hasColumn</a>(<span class="keyword">const</span> std::string & name) <span class="keyword">const</span>; <a name="l00134"></a>00134 <a name="l00137"></a>00137 std::string <a class="code" href="classhippodraw_1_1PyDataSource.html#af45f2d9804b33387f930fa8207520544" title="Register this DataSource, returning a unique name.">registerNTuple</a>(); <a name="l00138"></a>00138 <a name="l00141"></a>00141 <span class="keywordtype">void</span> <a class="code" href="classhippodraw_1_1PyDataSource.html#af45f2d9804b33387f930fa8207520544" title="Register this DataSource, returning a unique name.">registerNTuple</a>( <span class="keyword">const</span> std::string & name ); <a name="l00142"></a>00142 <a name="l00146"></a>00146 boost::python::numeric::array <a name="l00147"></a>00147 <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 & label ) <span class="keyword">const</span>; <a name="l00148"></a>00148 <a name="l00152"></a>00152 boost::python::numeric::array <a name="l00153"></a>00153 <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="l00154"></a>00154 <a name="l00157"></a>00157 <span class="keywordtype">void</span> <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="l00158"></a>00158 <span class="keyword">const</span> std::vector < double > & v, <a name="l00159"></a>00159 <span class="keyword">const</span> std::vector < intptr_t > & <a class="code" href="namespacenum__util.html#a8570d9b34e8e9d714823c1b1986764f7">shape</a> ); <a name="l00160"></a>00160 <a name="l00164"></a>00164 <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.">saveColumnFromNumArray</a>( <span class="keyword">const</span> std::string & label, <a name="l00165"></a>00165 boost::python::numeric::array array ); <a name="l00166"></a>00166 <a name="l00170"></a>00170 <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.">saveColumnFromNumArray</a>( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> index, <a name="l00171"></a>00171 boost::python::numeric::array array ); <a name="l00172"></a>00172 <a name="l00173"></a>00173 <a name="l00176"></a>00176 <span class="keywordtype">void</span> <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="l00177"></a>00177 <span class="keyword">const</span> std::vector < double > & array ); <a name="l00178"></a>00178 <a name="l00181"></a>00181 <span class="keywordtype">void</span> <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 > & array ); <a name="l00182"></a>00182 <a name="l00185"></a>00185 <span class="keywordtype">void</span> <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="l00186"></a>00186 <a name="l00189"></a>00189 <span class="keywordtype">void</span> <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="l00190"></a>00190 <a name="l00191"></a><a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html">00191</a> <span class="keyword">class </span><a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html">StopIteration</a> : <span class="keyword">public</span> std::exception { <a name="l00192"></a>00192 <span class="keyword">public</span>: <a name="l00193"></a><a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#aa8c2388c57db95cccffd25928ed67494">00193</a> <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#aa8c2388c57db95cccffd25928ed67494">StopIteration</a>(<span class="keyword">const</span> std::string & <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a586eee248fedb7de1b50219e14b99c7b">what</a>) : <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a9a8d3e94862c71c2c1ab83a0938c7f20">m_what</a>(what) {} <a name="l00194"></a><a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a127234ca8e87f95c965457a340be178e">00194</a> <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a127234ca8e87f95c965457a340be178e">~StopIteration</a>() throw() {} <a name="l00195"></a><a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a586eee248fedb7de1b50219e14b99c7b">00195</a> <span class="keyword">const</span> <span class="keywordtype">char</span> * <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a586eee248fedb7de1b50219e14b99c7b">what</a>() <span class="keyword">const</span> throw() { <a name="l00196"></a>00196 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a9a8d3e94862c71c2c1ab83a0938c7f20">m_what</a>.c_str(); <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <span class="keyword">private</span>: <a name="l00199"></a><a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a9a8d3e94862c71c2c1ab83a0938c7f20">00199</a> <span class="keyword">const</span> std::string <a class="code" href="classhippodraw_1_1PyDataSource_1_1StopIteration.html#a9a8d3e94862c71c2c1ab83a0938c7f20">m_what</a>; <a name="l00200"></a>00200 }; <a name="l00201"></a>00201 <a name="l00202"></a>00202 <a name="l00203"></a>00203 <span class="keyword">private</span>: <a name="l00204"></a>00204 <a name="l00206"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040">00206</a> std::string <a class="code" href="classhippodraw_1_1PyDataSource.html#a864a6c1ec7b6518cdddda525a697b040" title="The type of data source.">m_type</a>; <a name="l00207"></a>00207 <a name="l00209"></a><a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4">00209</a> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * <a class="code" href="classhippodraw_1_1PyDataSource.html#ac33ef7aa5120117399b2fde0fc4408f4" title="The actual DataSource object.">m_dataSource</a>; <a name="l00210"></a>00210 <a name="l00211"></a>00211 }; <a name="l00212"></a>00212 <a name="l00213"></a>00213 } <span class="comment">// namespace hippodraw</span> <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="preprocessor">#endif // _PyDataSource_H</span> </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>