<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>PyNTupleController.cxx</h1><a href="PyNTupleController_8cxx.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00012"></a>00012 <span class="preprocessor">#ifdef _MSC_VER</span> <a name="l00013"></a>00013 <span class="preprocessor"></span><span class="comment">// nonstandard extension used 'extern' before...</span> <a name="l00014"></a>00014 <span class="preprocessor"># pragma warning(disable:4231) </span> <a name="l00015"></a>00015 <span class="preprocessor"></span> <a name="l00016"></a>00016 <span class="comment">// needs to have dll-interface used by client</span> <a name="l00017"></a>00017 <span class="preprocessor"># pragma warning(disable:4251) </span> <a name="l00018"></a>00018 <span class="preprocessor"></span> <a name="l00019"></a>00019 <span class="comment">// non dll-interface struct</span> <a name="l00020"></a>00020 <span class="preprocessor"># pragma warning(disable:4275) </span> <a name="l00021"></a>00021 <span class="preprocessor"></span> <a name="l00022"></a>00022 <span class="comment">// 'int' : forcing value to bool 'true' or 'false' (performance warning)</span> <a name="l00023"></a>00023 <span class="preprocessor"># pragma warning(disable:4800) </span> <a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00025"></a>00025 <span class="preprocessor"></span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="PyNTupleController_8h.html" title="hippodraw::PyNTupleController class interface.">PyNTupleController.h</a>"</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="PyApp_8h.html" title="hippodraw::PyApp class interface.">PyApp.h</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="PyDataSource_8h.html" title="hippodraw::PyDataSource class interface">PyDataSource.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="PyNTuple_8h.html" title="hippodraw::PyNTuple class interface.">PyNTuple.h</a>"</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="preprocessor">#include "<a class="code" href="DataSourceController_8h.html" title="DataSourceController class interface.">datasrcs/DataSourceController.h</a>"</span> <a name="l00033"></a>00033 <span class="preprocessor">#include "<a class="code" href="NTupleController_8h.html" title="hippodraw::NTupleController class interface">datasrcs/NTupleController.h</a>"</span> <a name="l00034"></a>00034 <a name="l00035"></a>00035 <span class="preprocessor">#include <stdexcept></span> <a name="l00036"></a>00036 <a name="l00037"></a>00037 <span class="keyword">using namespace </span>hippodraw; <a name="l00038"></a>00038 <a name="l00039"></a>00039 <a class="code" href="classhippodraw_1_1NTupleController.html" title="A singleton class that is the interface between GUI and the NTuple objects.">NTupleController</a> * PyNTupleController::m_instance = 0; <a name="l00040"></a>00040 <a class="code" href="classhippodraw_1_1PyNTupleController.html" title="A wrapper for NTupleController for use from Python.">PyNTupleController</a> * PyNTupleController::s_instance = 0; <a name="l00041"></a>00041 <a name="l00042"></a>00042 <a name="l00043"></a>00043 PyNTupleController:: <a name="l00044"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#a2e7a5a2f15bbc6f1ca2efc2f71b59b27">00044</a> PyNTupleController() <a name="l00045"></a>00045 { <a name="l00046"></a>00046 } <a name="l00047"></a>00047 <a name="l00048"></a>00048 <a class="code" href="classhippodraw_1_1PyNTupleController.html" title="A wrapper for NTupleController for use from Python.">PyNTupleController</a> * <a name="l00049"></a>00049 <a class="code" href="classhippodraw_1_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec" title="The singleton instance method.">PyNTupleController::</a> <a name="l00050"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec">00050</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec" title="The singleton instance method.">instance</a> () <a name="l00051"></a>00051 { <a name="l00052"></a>00052 <span class="keywordflow">if</span> ( <a class="code" href="classhippodraw_1_1PyNTupleController.html#a0f8af5e5f604571c49006a15203c62de" title="The singleton PyNTupleController instance.">s_instance</a> == 0 ) { <a name="l00053"></a>00053 <a class="code" href="classhippodraw_1_1PyNTupleController.html#a0f8af5e5f604571c49006a15203c62de" title="The singleton PyNTupleController instance.">s_instance</a> = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a2e7a5a2f15bbc6f1ca2efc2f71b59b27" title="The default constructor, protected from being used.">PyNTupleController</a> (); <a name="l00054"></a>00054 <a class="code" href="classhippodraw_1_1PyNTupleController.html#abf0d99a974d42265b03430a5f9fe382b" title="The singleton NTupleController object.">m_instance</a> = <a class="code" href="classhippodraw_1_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec" title="The singleton instance method.">NTupleController::instance</a> (); <a name="l00055"></a>00055 } <a name="l00056"></a>00056 <a name="l00057"></a>00057 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a0f8af5e5f604571c49006a15203c62de" title="The singleton PyNTupleController instance.">s_instance</a>; <a name="l00058"></a>00058 } <a name="l00059"></a>00059 <a name="l00060"></a>00060 <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="l00061"></a>00061 <a class="code" href="classhippodraw_1_1PyNTupleController.html#acb491d08abb6c7ddc23c3fee5f09094f" title="Creates an empty NTuple object.">PyNTupleController::</a> <a name="l00062"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#acb491d08abb6c7ddc23c3fee5f09094f">00062</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#acb491d08abb6c7ddc23c3fee5f09094f" title="Creates an empty NTuple object.">createNTuple</a> ( ) <a name="l00063"></a>00063 { <a name="l00064"></a>00064 <a class="code" href="classhippodraw_1_1PyNTuple.html" title="A wrapper for NTuple, so that when NTuple is used in Qt based application, the application...">PyNTuple</a> * ntuple = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyNTuple.html" title="A wrapper for NTuple, so that when NTuple is used in Qt based application, the application...">PyNTuple</a> (); <a name="l00065"></a>00065 <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_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec" title="The singleton instance method.">DataSourceController::instance</a> (); <a name="l00066"></a>00066 controller -> <a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4" title="Registers the DataSource object and returns its assigned name.">registerNTuple</a> ( ntuple ); <a name="l00067"></a>00067 <a name="l00068"></a>00068 <span class="keywordflow">return</span> ntuple; <a name="l00069"></a>00069 } <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * <a name="l00072"></a>00072 <a class="code" href="classhippodraw_1_1PyNTupleController.html#acb491d08abb6c7ddc23c3fee5f09094f" title="Creates an empty NTuple object.">PyNTupleController::</a> <a name="l00073"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#a367a0129829b506b44f415cad946db40">00073</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#acb491d08abb6c7ddc23c3fee5f09094f" title="Creates an empty NTuple object.">createNTuple</a> ( <span class="keyword">const</span> std::string & filename ) <a name="l00074"></a>00074 { <a name="l00075"></a>00075 <a class="code" href="classhippodraw_1_1PyApp.html#aa81aed607133209dade63a226818224d" title="Obtains a lock on the application&#39;s mutex.">PyApp::lock</a> (); <a name="l00076"></a>00076 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> columns = 0; <a name="l00077"></a>00077 <a class="code" href="classhippodraw_1_1PyNTuple.html" title="A wrapper for NTuple, so that when NTuple is used in Qt based application, the application...">PyNTuple</a> * ntuple = <span class="keyword">new</span> <a class="code" href="classhippodraw_1_1PyNTuple.html" title="A wrapper for NTuple, so that when NTuple is used in Qt based application, the application...">PyNTuple</a> ( columns ); <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="keywordflow">try</span> { <a name="l00080"></a>00080 <a class="code" href="classhippodraw_1_1PyNTupleController.html#abf0d99a974d42265b03430a5f9fe382b" title="The singleton NTupleController object.">m_instance</a> -> fillFromFile ( filename, ntuple ); <a name="l00081"></a>00081 } <a name="l00082"></a>00082 <span class="keywordflow">catch</span> ( <span class="keyword">const</span> std::runtime_error & e ) { <a name="l00083"></a>00083 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a> (); <a name="l00084"></a>00084 <span class="keyword">delete</span> ntuple; <a name="l00085"></a>00085 <span class="keywordflow">throw</span> e; <a name="l00086"></a>00086 } <a name="l00087"></a>00087 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a> (); <a name="l00088"></a>00088 <a name="l00089"></a>00089 <span class="keywordflow">return</span> ntuple; <a name="l00090"></a>00090 } <a name="l00091"></a>00091 <a name="l00092"></a>00092 <a class="code" href="classhippodraw_1_1CircularBuffer.html" title="CircularBuffer manager.">CircularBuffer</a> * <a name="l00093"></a>00093 <a class="code" href="classhippodraw_1_1PyNTupleController.html#abe5e046b69f62a258ecfc15e45031cdd" title="Creates an empty CircularBuffer object with n columns.">PyNTupleController::</a> <a name="l00094"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#abe5e046b69f62a258ecfc15e45031cdd">00094</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#abe5e046b69f62a258ecfc15e45031cdd" title="Creates an empty CircularBuffer object with n columns.">createCircularBuffer</a> ( <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> columns ) <a name="l00095"></a>00095 { <a name="l00096"></a>00096 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyNTupleController.html#abf0d99a974d42265b03430a5f9fe382b" title="The singleton NTupleController object.">m_instance</a> -> <a class="code" href="classhippodraw_1_1PyNTupleController.html#abe5e046b69f62a258ecfc15e45031cdd" title="Creates an empty CircularBuffer object with n columns.">createCircularBuffer</a> ( columns ); <a name="l00097"></a>00097 } <a name="l00098"></a>00098 <a name="l00099"></a>00099 <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="l00100"></a>00100 <a class="code" href="classhippodraw_1_1PyNTupleController.html#a54ad3ba0cc17e8722e998708f47fd4e9" title="Creates a DataArray Python object from the file filename.">PyNTupleController::</a> <a name="l00101"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#a54ad3ba0cc17e8722e998708f47fd4e9">00101</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a54ad3ba0cc17e8722e998708f47fd4e9" title="Creates a DataArray Python object from the file filename.">createDataArray</a> ( <span class="keyword">const</span> std::string & filename ) <a name="l00102"></a>00102 { <a name="l00103"></a>00103 <span class="preprocessor">#ifdef HAVE_NUMARRAY</span> <a name="l00104"></a>00104 <span class="preprocessor"></span> <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * tuple = <a class="code" href="classhippodraw_1_1PyNTupleController.html#acb491d08abb6c7ddc23c3fee5f09094f" title="Creates an empty NTuple object.">createNTuple</a> ( filename ); <a name="l00105"></a>00105 <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> * ds = <span class="keyword">new</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="stringliteral">"NTuple"</span>, tuple ); <a name="l00106"></a>00106 <a name="l00107"></a>00107 <span class="keywordflow">return</span> ds; <a name="l00108"></a>00108 <span class="preprocessor">#else</span> <a name="l00109"></a>00109 <span class="preprocessor"></span> std::runtime_error e ( <span class="stringliteral">"HippoDraw was not built with "</span> <a name="l00110"></a>00110 <span class="stringliteral">"numeric Python support"</span> ); <a name="l00111"></a>00111 <span class="keywordflow">throw</span> e; <a name="l00112"></a>00112 <span class="preprocessor">#endif</span> <a name="l00113"></a>00113 <span class="preprocessor"></span>} <a name="l00114"></a>00114 <a name="l00115"></a>00115 <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * <a name="l00116"></a>00116 <a class="code" href="classhippodraw_1_1PyNTupleController.html#a12d64d4bd97d8216595ba5a405e4399b" title="Finds the DataSource by name.">PyNTupleController::</a> <a name="l00117"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#a12d64d4bd97d8216595ba5a405e4399b">00117</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a12d64d4bd97d8216595ba5a405e4399b" title="Finds the DataSource by name.">findDataSource</a> ( <span class="keyword">const</span> std::string & name )<span class="keyword"> const</span> <a name="l00118"></a>00118 <span class="keyword"></span>{ <a name="l00119"></a>00119 <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * dsc = <a class="code" href="classhippodraw_1_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec" title="The singleton instance method.">DataSourceController::instance</a> (); <a name="l00120"></a>00120 <a name="l00121"></a>00121 <span class="keywordflow">return</span> dsc -> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a12d64d4bd97d8216595ba5a405e4399b" title="Finds the DataSource by name.">findDataSource</a> ( name ); <a name="l00122"></a>00122 } <a name="l00123"></a>00123 <a name="l00124"></a>00124 std::string <a name="l00125"></a>00125 <a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4" title="Registers the DataSource object and returns its assigned name.">PyNTupleController::</a> <a name="l00126"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4">00126</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4" title="Registers the DataSource object and returns its assigned name.">registerNTuple</a> ( <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * source ) <a name="l00127"></a>00127 { <a name="l00128"></a>00128 <a class="code" href="classhippodraw_1_1PyApp.html#aa81aed607133209dade63a226818224d" title="Obtains a lock on the application&#39;s mutex.">PyApp::lock</a> (); <a name="l00129"></a>00129 <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * dsc = <a class="code" href="classhippodraw_1_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec" title="The singleton instance method.">DataSourceController::instance</a> (); <a name="l00130"></a>00130 <a name="l00131"></a>00131 std::string name = dsc -> <a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4" title="Registers the DataSource object and returns its assigned name.">registerNTuple</a> ( source ); <a name="l00132"></a>00132 <a class="code" href="classhippodraw_1_1PyApp.html#a9278be8203e1c42e2619179882ae4403" title="Releases the lock on the application&#39;s mutex.">PyApp::unlock</a> (); <a name="l00133"></a>00133 <a name="l00134"></a>00134 <span class="keywordflow">return</span> name; <a name="l00135"></a>00135 } <a name="l00136"></a>00136 <a name="l00137"></a>00137 <span class="keywordtype">void</span> <a name="l00138"></a>00138 <a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4" title="Registers the DataSource object and returns its assigned name.">PyNTupleController::</a> <a name="l00139"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#a9292685bda625ec1441b30a2045e5a5c">00139</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4" title="Registers the DataSource object and returns its assigned name.">registerNTuple</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="l00140"></a>00140 { <a name="l00141"></a>00141 <a class="code" href="classhippodraw_1_1DataSourceController.html" title="A singleton class that is the interface between GUI and the DataSource objects.">DataSourceController</a> * dsc = <a class="code" href="classhippodraw_1_1PyNTupleController.html#aa4c2092d0abd15b0a47dba934c61c0ec" title="The singleton instance method.">DataSourceController::instance</a> (); <a name="l00142"></a>00142 <a name="l00143"></a>00143 dsc -> <a class="code" href="classhippodraw_1_1PyNTupleController.html#ad3b01e81b51eacf4fc67bb140f1644e4" title="Registers the DataSource object and returns its assigned name.">registerNTuple</a> ( name, source ); <a name="l00144"></a>00144 } <a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="keywordtype">int</span> <a name="l00147"></a>00147 <a class="code" href="classhippodraw_1_1PyNTupleController.html#a66b12b1d426bb84b3511ebbec62ad6aa" title="Writes the DataSource to the file filename.">PyNTupleController::</a> <a name="l00148"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#a66b12b1d426bb84b3511ebbec62ad6aa">00148</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a66b12b1d426bb84b3511ebbec62ad6aa" title="Writes the DataSource to the file filename.">writeNTupleToFile</a> ( <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * source, <a name="l00149"></a>00149 <span class="keyword">const</span> std::string & filename ) <a name="l00150"></a>00150 { <a name="l00151"></a>00151 <span class="keywordflow">return</span> <a class="code" href="classhippodraw_1_1PyNTupleController.html#abf0d99a974d42265b03430a5f9fe382b" title="The singleton NTupleController object.">m_instance</a> -> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a66b12b1d426bb84b3511ebbec62ad6aa" title="Writes the DataSource to the file filename.">writeNTupleToFile</a> ( source, filename ); <a name="l00152"></a>00152 } <a name="l00153"></a>00153 <a name="l00154"></a>00154 <span class="keywordtype">void</span> <a name="l00155"></a>00155 <a class="code" href="classhippodraw_1_1PyNTupleController.html#a1a82f788ee5bf0a627e95d320f4f31c7" title="Changes the name of the DataSource.">PyNTupleController::</a> <a name="l00156"></a><a class="code" href="classhippodraw_1_1PyNTupleController.html#a1a82f788ee5bf0a627e95d320f4f31c7">00156</a> <a class="code" href="classhippodraw_1_1PyNTupleController.html#a1a82f788ee5bf0a627e95d320f4f31c7" title="Changes the name of the DataSource.">changeName</a> ( <a class="code" href="classhippodraw_1_1DataSource.html" title="Base class for DataSource.">DataSource</a> * source, <span class="keyword">const</span> std::string & new_name ) <a name="l00157"></a>00157 { <a name="l00158"></a>00158 source -> setName ( new_name ); <a name="l00159"></a>00159 } </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>