Sophie

Sophie

distrib > Fedora > 13 > i386 > by-pkgid > eebc325dc36bd6e3b09b9b45133e42f8 > files > 1502

HippoDraw-devel-docs-1.21.1-10.fc13.i686.rpm

<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&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;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&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_bd46360b4c6a7cd846adf95fa79d46e4.html">python</a>
  </div>
</div>
<div class="contents">
<h1>ObserverWrap.cxx</h1><a href="ObserverWrap_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 HAVE_CONFIG_H</span>
<a name="l00013"></a>00013 <span class="preprocessor"></span><span class="comment">// for old python</span>
<a name="l00014"></a>00014 <span class="preprocessor">#include &quot;config.h&quot;</span>
<a name="l00015"></a>00015 <span class="preprocessor">#endif</span>
<a name="l00016"></a>00016 <span class="preprocessor"></span>
<a name="l00017"></a>00017 <span class="comment">// include first to avoid _POSIX_C_SOURCE warning.</span>
<a name="l00018"></a>00018 <span class="preprocessor">#include &lt;boost/python.hpp&gt;</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="preprocessor">#include &quot;<a class="code" href="ObserverWrap_8h.html" title="hippodraw::ObserverWrap class interface.">ObserverWrap.h</a>&quot;</span>
<a name="l00021"></a>00021 
<a name="l00022"></a>00022 <span class="preprocessor">#include &quot;<a class="code" href="Observable_8h.html" title="Observable class interface.">pattern/Observable.h</a>&quot;</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00025"></a>00025 
<a name="l00026"></a>00026 <span class="keyword">using</span> std::string;
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="keyword">using namespace </span>boost::python;
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="keyword">namespace </span>hippodraw {
<a name="l00032"></a>00032   <span class="keyword">namespace </span>Python {
<a name="l00033"></a>00033     <span class="keywordtype">void</span>
<a name="l00034"></a><a class="code" href="namespacehippodraw_1_1Python.html#a90877c48f0adc0869f54f44bfeb7785e">00034</a>     <a class="code" href="namespacehippodraw_1_1Python.html#a90877c48f0adc0869f54f44bfeb7785e" title="Exports the Observer class to Python.">export_Observer</a> ()
<a name="l00035"></a>00035     {
<a name="l00036"></a>00036                 class_ &lt; <a class="code" href="classhippodraw_1_1ObserverWrap.html" title="A wrapper class for Observer to allow its pure virtual function to be implemented...">ObserverWrap</a>,
<a name="l00037"></a>00037                              std::auto_ptr&lt;ObserverWrap&gt;,
<a name="l00038"></a>00038                                  boost::noncopyable             &gt;
<a name="l00039"></a>00039          ( <span class="stringliteral">&quot;Observer&quot;</span>,
<a name="l00040"></a>00040           <span class="stringliteral">&quot;The base class for classes that can be targets of Observable\n&quot;</span>
<a name="l00041"></a>00041           <span class="stringliteral">&quot;update messages.&quot;</span>,
<a name="l00042"></a>00042           no_init )
<a name="l00043"></a>00043         ;
<a name="l00044"></a>00044 
<a name="l00045"></a>00045       class_ &lt; Observable &gt;
<a name="l00046"></a>00046         ( <span class="stringliteral">&quot;Observable&quot;</span>,
<a name="l00047"></a>00047           <span class="stringliteral">&quot;The base class for classes that can be target of an Observer\n&quot;</span>
<a name="l00048"></a>00048           <span class="stringliteral">&quot;object.&quot;</span>,
<a name="l00049"></a>00049           init &lt;&gt; () )
<a name="l00050"></a>00050         ;
<a name="l00051"></a>00051     }
<a name="l00052"></a>00052   } <span class="comment">// namespace Python</span>
<a name="l00053"></a>00053 } <span class="comment">// namespace hippodraw</span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="keyword">using namespace </span>hippodraw;
<a name="l00056"></a>00056 
<a name="l00059"></a>00059 ObserverWrap::
<a name="l00060"></a><a class="code" href="classhippodraw_1_1ObserverWrap.html#a90d446da2e16fc7a7b639d3db6de242c">00060</a> ObserverWrap ( PyObject * <span class="keyword">self</span> )
<a name="l00061"></a>00061   : hippodraw::<a class="code" href="classhippodraw_1_1Observer.html" title="Part of an implementation of the Observable Observer pattern based on the example...">Observer</a> (),
<a name="l00062"></a>00062     m_self ( self )
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065 
<a name="l00066"></a>00066 <a class="code" href="classhippodraw_1_1ObserverWrap.html#a98975d353df86cc5c0cae9c13d3e7c1c">ObserverWrap::</a>
<a name="l00067"></a><a class="code" href="classhippodraw_1_1ObserverWrap.html#a98975d353df86cc5c0cae9c13d3e7c1c">00067</a> <a class="code" href="classhippodraw_1_1ObserverWrap.html#a98975d353df86cc5c0cae9c13d3e7c1c">ObserverWrap</a> ( )
<a name="l00068"></a>00068   : hippodraw::<a class="code" href="classhippodraw_1_1Observer.html" title="Part of an implementation of the Observable Observer pattern based on the example...">Observer</a> (),
<a name="l00069"></a>00069     m_self ( 0 )
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 <a class="code" href="classhippodraw_1_1ObserverWrap.html#a98975d353df86cc5c0cae9c13d3e7c1c">ObserverWrap::</a>
<a name="l00073"></a><a class="code" href="classhippodraw_1_1ObserverWrap.html#a3b10e01e83ba9d53db29327912bb6e40">00073</a> <a class="code" href="classhippodraw_1_1ObserverWrap.html#a98975d353df86cc5c0cae9c13d3e7c1c">ObserverWrap</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Observer.html" title="Part of an implementation of the Observable Observer pattern based on the example...">Observer</a> &amp; ow )
<a name="l00074"></a>00074   : hippodraw::<a class="code" href="classhippodraw_1_1Observer.html" title="Part of an implementation of the Observable Observer pattern based on the example...">Observer</a> ( ow ),
<a name="l00075"></a>00075     m_self ( 0 )
<a name="l00076"></a>00076 {
<a name="l00077"></a>00077 }
<a name="l00078"></a>00078 
<a name="l00079"></a>00079 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00080"></a>00080 <span class="keywordtype">object</span>
<a name="l00081"></a>00081 <a class="code" href="classhippodraw_1_1ObserverWrap.html#a6890ec978e2c0d41a8b9e205a5798195" title="Find the Python object that owns this object.">ObserverWrap::</a>
<a name="l00082"></a><a class="code" href="classhippodraw_1_1ObserverWrap.html#a6890ec978e2c0d41a8b9e205a5798195">00082</a> <a class="code" href="classhippodraw_1_1ObserverWrap.html#a6890ec978e2c0d41a8b9e205a5798195" title="Find the Python object that owns this object.">get_owner</a>(<a class="code" href="namespacehippodraw_1_1Axes.html#a1d1cfd8ffb84e947f82999c682b666a7a21f40778b7db9343a6ca75ec2c41ccce" title="title">T</a>* ) const <span class="comment">// me</span>
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084       <span class="comment">// Use secret interface to get the Python object</span>
<a name="l00085"></a>00085       <span class="comment">// that owns *this.  I guess I will have to make that</span>
<a name="l00086"></a>00086       <span class="comment">// interface public. -- Dave Abrahams</span>
<a name="l00087"></a>00087       <span class="keywordflow">return</span>
<a name="l00088"></a>00088 object ( handle&lt;&gt; ( borrowed ( detail::wrapper_base_::get_owner(*<span class="keyword">this</span>))));
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090 
<a name="l00093"></a>00093 <span class="keywordtype">void</span>
<a name="l00094"></a>00094 <a class="code" href="classhippodraw_1_1ObserverWrap.html#ae6b85d8f95c1889865463b18e33d08a5">ObserverWrap::</a>
<a name="l00095"></a><a class="code" href="classhippodraw_1_1ObserverWrap.html#ae6b85d8f95c1889865463b18e33d08a5">00095</a> <a class="code" href="classhippodraw_1_1ObserverWrap.html#ae6b85d8f95c1889865463b18e33d08a5">update</a> ( <span class="keyword">const</span> <a class="code" href="classhippodraw_1_1Observable.html" title="Part of an implementation of the Observable-Observer pattern based on the example...">Observable</a> * obs )
<a name="l00096"></a>00096 {
<a name="l00097"></a>00097 <span class="preprocessor">#ifndef HAVE_OLD_PYTHON</span>
<a name="l00098"></a>00098 <span class="preprocessor"></span>  PyGILState_STATE state = PyGILState_Ensure ();
<a name="l00099"></a>00099 
<a name="l00100"></a>00100   <span class="keywordflow">try</span> {
<a name="l00101"></a>00101      <span class="keywordtype">object</span> <span class="keyword">self</span> = <a class="code" href="classhippodraw_1_1ObserverWrap.html#a6890ec978e2c0d41a8b9e205a5798195" title="Find the Python object that owns this object.">get_owner</a> ( <span class="keyword">this</span> );
<a name="l00102"></a>00102      call_method &lt; void, const Observable * &gt; ( <span class="keyword">self</span>.ptr(), <span class="stringliteral">&quot;update&quot;</span>, obs );
<a name="l00103"></a>00103   } <span class="keywordflow">catch</span> ( error_already_set &amp; ) {
<a name="l00104"></a>00104      std::cout &lt;&lt; <span class="stringliteral">&quot;ObserverWrap::update: caught error_already_set&quot;</span> 
<a name="l00105"></a>00105                &lt;&lt; std::endl;
<a name="l00106"></a>00106      PyErr_Print();
<a name="l00107"></a>00107      handle_exception();
<a name="l00108"></a>00108   }
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   PyGILState_Release ( state );
<a name="l00111"></a>00111 <span class="preprocessor">#endif</span>
<a name="l00112"></a>00112 <span class="preprocessor"></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>