Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 54cac1c2268db633d66eeff1b4faa585 > files > 429

frepple-doc-0.8.1-3.fc15.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>C++ API frePPLe: frepple::utils::PythonInterpreter Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="../styles.css" rel="stylesheet"  type="text/css">
</head>
<body>
<div id="container">

<div id="menubar"> 
<div id="logo" align="center">
<br/><img src='../frepple.bmp' alt="frepple" /><br/>
<a href='http://www.frepple.com/'>
<strong>a Free<br/>Production Planning<br/>Library</strong>
</a>
</div>
<div id="menu">
<br/>
<h3><a href='../Main/HomePage.html'>Main</a></h3>
<h3><a href='../UI/Main.html'>User Manual</a></h3>
<h3><a href='../Tutorial/Main.html'>Tutorial</a></h3>
<h3><a href='../Frepple/Main.html'>Reference Manual</a></h3>
<h3><a href='../Main/FAQ.html'>FAQ</a></h3>
<h3><a href='index.html'>C++ API</a></h3>
<br/>
</div>  
</div>

<div id="content">
<br/>
<!-- Generated by Doxygen 1.6.1 -->
<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 class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><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="annotated.html"><span>Class&nbsp;List</span></a></li>
      <li><a href="classes.html"><span>Class&nbsp;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&nbsp;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="a00256.html">frepple</a>::<a class="el" href="a00257.html">utils</a>::<a class="el" href="a00153.html">PythonInterpreter</a>
  </div>
</div>
<div class="contents">
<h1>frepple::utils::PythonInterpreter Class Reference</h1><!-- doxytag: class="frepple::utils::PythonInterpreter" -->
<p>This class is used to maintain the Python interpreter.  
<a href="#_details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00252_source.html">utils.h</a>&gt;</code></p>

<p><a href="a00620.html">List of all members.</a></p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2"><h2>Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a6b12865d7cdada51f05ef201b908910a">addThread</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a89888308625faa01991c6c89ba6706dc">deleteThread</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a949cf0e3a7215f64d7e491402aa1a62d">execute</a> (const char *)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static PyObject *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a861434d2219b3240ac16b1007eedcc56">getModule</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static const char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a37a78f854dccfadaab2dc0c7eebd517d">getPythonEncoding</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a25198fb09ba3dd405f99de38cf5b912a">initialize</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a834f86afd4a72a3bf5401894c92bddb4">registerGlobalMethod</a> (const char *, PyCFunctionWithKeywords, int, const char *)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00153.html#a3d9447646d6d4b6e9ab323425e731712">registerGlobalMethod</a> (const char *, PyCFunction, int, const char *, bool=true)</td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<p>This class is used to maintain the Python interpreter. </p>
<p>A single interpreter is used throughout the lifetime of the application.<br/>
 The implementation is implemented in a thread-safe way (within the limitations of the Python threading model, of course).</p>
<p>During the initialization the code checks for a file 'init.py' in its search path and, if it does exist, the statements in the file will be executed. In this way a library of globally available functions can easily be initialized.</p>
<p>The stderr and stdout streams of Python are redirected by default to the frePPLe log stream.</p>
<p>The following frePPLe functions are available from within Python.<br/>
 All of these are in the module called frePPLe.</p>
<ul>
<li>The following <b>classes</b> and their attributes are accessible for reading and writing.<br/>
 Each object has a toXML() method that returns its XML representation as a string, or writes it to a file is a file is passed as argument.<ul>
<li>buffer</li>
<li>buffer_default</li>
<li>buffer_infinite</li>
<li>buffer_procure</li>
<li>calendar</li>
<li>calendarBucket</li>
<li>calendar_boolean</li>
<li>calendar_double</li>
<li>calendar_void</li>
<li>customer</li>
<li>customer_default</li>
<li>demand</li>
<li>demand_default</li>
<li>flow</li>
<li>flowplan</li>
<li>item</li>
<li>item_default</li>
<li>load</li>
<li>loadplan</li>
<li>location</li>
<li>location_default</li>
<li>operation</li>
<li>operation_alternate<ul>
<li>addAlternate(operation=x, priority=y, effective_start=z1, effective_end=z2)</li>
</ul>
</li>
<li>operation_fixed_time</li>
<li>operation_routing<ul>
<li>addStep(tuple of operations)</li>
</ul>
</li>
<li>operation_time_per</li>
<li>operationplan</li>
<li>parameters</li>
<li>problem (read-only)</li>
<li>resource</li>
<li>resource_default</li>
<li>resource_infinite</li>
<li>setup_matrix</li>
<li>setup_matrix_default</li>
<li>solver<ul>
<li>solve()</li>
</ul>
</li>
<li>solver_mrp</li>
</ul>
</li>
<li>The following functions or attributes return <b>iterators</b> over the frePPLe objects:<br/>
<ul>
<li>buffers()</li>
<li>buffer.flows</li>
<li>buffer.flowplans</li>
<li>calendar.buckets</li>
<li>calendars()</li>
<li>customers()</li>
<li>demands()</li>
<li>demand.operationplans</li>
<li>demand.pegging</li>
<li>operation.flows</li>
<li>operation.loads</li>
<li>items()</li>
<li>locations()</li>
<li>operations()</li>
<li>operation.operationplans</li>
<li>problems()</li>
<li>resources()</li>
<li>resource.loads</li>
<li>resource.loadplans</li>
<li>setup_matrices()</li>
<li>solvers()</li>
</ul>
</li>
<li><b>printsize()</b>:<br/>
 Prints information about the memory consumption.</li>
<li><b>loadmodule(string [,parameter=value, ...])</b>:<br/>
 Dynamically load a module in memory.</li>
<li><b>readXMLdata(string [,bool] [,bool])</b>:<br/>
 Processes an XML string passed as argument.</li>
<li><b>log(string)</b>:<br/>
 Prints a string to the frePPLe log file.<br/>
 This is used for redirecting the stdout and stderr of Python.</li>
<li><b>readXMLfile(string [,bool] [,bool])</b>:<br/>
 Read an XML-file.</li>
<li><b>saveXMLfile(string)</b>:<br/>
 Save the model to an XML-file.</li>
<li><b>saveplan(string)</b>:<br/>
 Save the main plan information to a file.</li>
<li><b>erase(boolean)</b>:<br/>
 Erase the model (arg true) or only the plan (arg false, default).</li>
<li><b>version</b>:<br/>
 A string variable with the version number. </li>
</ul>

<p>Definition at line <a class="el" href="a00252_source.html#l00724">724</a> of file <a class="el" href="a00252_source.html">utils.h</a>.</p>
<hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a6b12865d7cdada51f05ef201b908910a"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::addThread" ref="a6b12865d7cdada51f05ef201b908910a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void frepple::utils::PythonInterpreter::addThread </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Create a new Python thread state.<br/>
 Each OS-level thread needs to initialize a Python thread state as well. When a new thread is created in the OS, this method should be called to create a Python thread state as well.<br/>
 See the Python PyGILState_Ensure API. </p>

<p>Definition at line <a class="el" href="a00233_source.html#l00170">170</a> of file <a class="el" href="a00233_source.html">pythonutils.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a89888308625faa01991c6c89ba6706dc"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::deleteThread" ref="a89888308625faa01991c6c89ba6706dc" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void frepple::utils::PythonInterpreter::deleteThread </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Delete a Python thread state.<br/>
 Each OS-level thread has a Python thread state. When an OS thread is deleted, this method should be called to delete the Python thread state as well.<br/>
 See the Python PyGILState_Release API. </p>

<p>Definition at line <a class="el" href="a00233_source.html#l00186">186</a> of file <a class="el" href="a00233_source.html">pythonutils.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a949cf0e3a7215f64d7e491402aa1a62d"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::execute" ref="a949cf0e3a7215f64d7e491402aa1a62d" args="(const char *)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void frepple::utils::PythonInterpreter::execute </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>cmd</em></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Execute some python code. </p>

<p>Definition at line <a class="el" href="a00233_source.html#l00199">199</a> of file <a class="el" href="a00233_source.html">pythonutils.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a861434d2219b3240ac16b1007eedcc56"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::getModule" ref="a861434d2219b3240ac16b1007eedcc56" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static PyObject* frepple::utils::PythonInterpreter::getModule </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Return a pointer to the main extension module. </p>

<p>Definition at line <a class="el" href="a00252_source.html#l00750">750</a> of file <a class="el" href="a00252_source.html">utils.h</a>.</p>

</div>
</div>
<a class="anchor" id="a37a78f854dccfadaab2dc0c7eebd517d"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::getPythonEncoding" ref="a37a78f854dccfadaab2dc0c7eebd517d" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">static const char* frepple::utils::PythonInterpreter::getPythonEncoding </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Return the preferred encoding of the Python interpreter. </p>

<p>Definition at line <a class="el" href="a00252_source.html#l00753">753</a> of file <a class="el" href="a00252_source.html">utils.h</a>.</p>

</div>
</div>
<a class="anchor" id="a25198fb09ba3dd405f99de38cf5b912a"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::initialize" ref="a25198fb09ba3dd405f99de38cf5b912a" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void frepple::utils::PythonInterpreter::initialize </td>
          <td>(</td>
          <td class="paramname"></td>
          <td>&nbsp;)&nbsp;</td>
          <td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Initializes the interpreter. </p>

<p>Definition at line <a class="el" href="a00233_source.html#l00100">100</a> of file <a class="el" href="a00233_source.html">pythonutils.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a834f86afd4a72a3bf5401894c92bddb4"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::registerGlobalMethod" ref="a834f86afd4a72a3bf5401894c92bddb4" args="(const char *, PyCFunctionWithKeywords, int, const char *)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void frepple::utils::PythonInterpreter::registerGlobalMethod </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>c</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">PyCFunctionWithKeywords&nbsp;</td>
          <td class="paramname"> <em>f</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>i</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>d</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Register a new method to Python. </p>

<p>Definition at line <a class="el" href="a00233_source.html#l00304">304</a> of file <a class="el" href="a00233_source.html">pythonutils.cpp</a>.</p>

</div>
</div>
<a class="anchor" id="a3d9447646d6d4b6e9ab323425e731712"></a><!-- doxytag: member="frepple::utils::PythonInterpreter::registerGlobalMethod" ref="a3d9447646d6d4b6e9ab323425e731712" args="(const char *, PyCFunction, int, const char *, bool=true)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void frepple::utils::PythonInterpreter::registerGlobalMethod </td>
          <td>(</td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>name</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">PyCFunction&nbsp;</td>
          <td class="paramname"> <em>method</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>flags</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&nbsp;</td>
          <td class="paramname"> <em>doc</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&nbsp;</td>
          <td class="paramname"> <em>lock</em> = <code>true</code></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td><code> [static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<p>Register a new method to Python.<br/>
 Arguments:</p>
<ul>
<li>The name of the built-in function/method</li>
<li>The function that implements it.</li>
<li>Combination of METH_* flags, which mostly describe the args expected by the C func.</li>
<li>The __doc__ attribute, or NULL. </li>
</ul>

<p>Definition at line <a class="el" href="a00233_source.html#l00243">243</a> of file <a class="el" href="a00233_source.html">pythonutils.cpp</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="a00252_source.html">utils.h</a></li>
<li><a class="el" href="a00233_source.html">pythonutils.cpp</a></li>
</ul>
</div>
<hr size="1"/><address style="align: right;"><small>Documentation generated for frePPLe by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"/></a></small></address>
</div>
</div>
</body>
</html>