Sophie

Sophie

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

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: pythonutils.h Source File</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><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_18992602582d7248789456d5a25e14d1.html">include</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_d7b4472e78ce4d9f89572afca2a9177a.html">frepple</a>
  </div>
</div>
<div class="contents">
<h1>pythonutils.h</h1><a href="a00234.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/***************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment">  file : $URL: https://frepple.svn.sourceforge.net/svnroot/frepple/trunk/include/frepple/pythonutils.h $</span>
<a name="l00003"></a>00003 <span class="comment">  version : $LastChangedRevision: 1044 $  $LastChangedBy: jdetaeye $</span>
<a name="l00004"></a>00004 <span class="comment">  date : $LastChangedDate: 2009-08-26 17:05:03 +0200 (Wed, 26 Aug 2009) $</span>
<a name="l00005"></a>00005 <span class="comment"> ***************************************************************************/</span>
<a name="l00006"></a>00006 
<a name="l00007"></a>00007 <span class="comment">/***************************************************************************</span>
<a name="l00008"></a>00008 <span class="comment"> *                                                                         *</span>
<a name="l00009"></a>00009 <span class="comment"> * Copyright (C) 2007 by Johan De Taeye                                    *</span>
<a name="l00010"></a>00010 <span class="comment"> *                                                                         *</span>
<a name="l00011"></a>00011 <span class="comment"> * This library is free software; you can redistribute it and/or modify it *</span>
<a name="l00012"></a>00012 <span class="comment"> * under the terms of the GNU Lesser General Public License as published   *</span>
<a name="l00013"></a>00013 <span class="comment"> * by the Free Software Foundation; either version 2.1 of the License, or  *</span>
<a name="l00014"></a>00014 <span class="comment"> * (at your option) any later version.                                     *</span>
<a name="l00015"></a>00015 <span class="comment"> *                                                                         *</span>
<a name="l00016"></a>00016 <span class="comment"> * This library is distributed in the hope that it will be useful,         *</span>
<a name="l00017"></a>00017 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of          *</span>
<a name="l00018"></a>00018 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *</span>
<a name="l00019"></a>00019 <span class="comment"> * General Public License for more details.                                *</span>
<a name="l00020"></a>00020 <span class="comment"> *                                                                         *</span>
<a name="l00021"></a>00021 <span class="comment"> * You should have received a copy of the GNU Lesser General Public        *</span>
<a name="l00022"></a>00022 <span class="comment"> * License along with this library; if not, write to the Free Software     *</span>
<a name="l00023"></a>00023 <span class="comment"> * Foundation Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 *</span>
<a name="l00024"></a>00024 <span class="comment"> * USA                                                                     *</span>
<a name="l00025"></a>00025 <span class="comment"> *                                                                         *</span>
<a name="l00026"></a>00026 <span class="comment"> ***************************************************************************/</span>
<a name="l00027"></a>00027 <span class="comment"></span>
<a name="l00028"></a>00028 <span class="comment">/** @file pythonutils.h</span>
<a name="l00029"></a>00029 <span class="comment">  * @brief Reusable functions for python functionality.</span>
<a name="l00030"></a>00030 <span class="comment">  *</span>
<a name="l00031"></a>00031 <span class="comment">  * Utility classes for interfacing with the Python language.</span>
<a name="l00032"></a>00032 <span class="comment">  */</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="preprocessor">#include &quot;<a class="code" href="a00252.html" title="Header file for auxilary classes.">frepple/utils.h</a>&quot;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="keyword">namespace </span>frepple
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038 <span class="keyword">namespace </span>utils
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040 <span class="comment"></span>
<a name="l00041"></a>00041 <span class="comment">/** @brief A template class to expose category classes which use a string</span>
<a name="l00042"></a>00042 <span class="comment">  * as the key to Python . */</span>
<a name="l00043"></a>00043 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00044"></a><a class="code" href="a00076.html">00044</a> <span class="keyword">class </span><a class="code" href="a00076.html" title="A template class to expose category classes which use a string as the key to Python...">FreppleCategory</a> : <span class="keyword">public</span> <a class="code" href="a00150.html" title="Template class to define Python extensions.">PythonExtension</a>&lt; FreppleCategory&lt;T&gt; &gt;
<a name="l00045"></a>00045 {
<a name="l00046"></a>00046   <span class="keyword">public</span>:<span class="comment"></span>
<a name="l00047"></a>00047 <span class="comment">    /** Initialization method. */</span>
<a name="l00048"></a><a class="code" href="a00076.html#ae7f17f929cdc6585636dfb7a9c845cab">00048</a>     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00076.html#ae7f17f929cdc6585636dfb7a9c845cab">initialize</a>()
<a name="l00049"></a>00049     {
<a name="l00050"></a>00050       <span class="comment">// Initialize the type</span>
<a name="l00051"></a>00051       <a class="code" href="a00155.html" title="This class is a thin wrapper around the type information in Python.">PythonType</a>&amp; x = <a class="code" href="a00150.html" title="Template class to define Python extensions.">PythonExtension&lt; FreppleCategory&lt;T&gt;</a> &gt;<a class="code" href="a00150.html#aec65c2cd811051918027ae6dc00fcfaf">::getType</a>();
<a name="l00052"></a>00052       x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(T::metadata-&gt;type);
<a name="l00053"></a>00053       x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">&quot;frePPLe &quot;</span> + T::metadata-&gt;type);
<a name="l00054"></a>00054       x.<a class="code" href="a00155.html#a8d3f24e0357f41ac3bc0be78bd2ab268">supportgetattro</a>();
<a name="l00055"></a>00055       x.<a class="code" href="a00155.html#a83866bef191c69cf8506426fe38b8d19">supportsetattro</a>();
<a name="l00056"></a>00056       x.<a class="code" href="a00155.html#a23a670ed39c26ab20ec400cbe3618e6c">supportstr</a>();
<a name="l00057"></a>00057       x.<a class="code" href="a00155.html#ae96d28a03dbcf0e2b51100d8d2e6d621">supportcompare</a>();
<a name="l00058"></a>00058       x.<a class="code" href="a00155.html#a001dc53b2dd832c001aee4d21bc7bf09">supportcreate</a>(Object::create&lt;T&gt;);
<a name="l00059"></a>00059       <span class="keyword">const_cast&lt;</span><a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>*<span class="keyword">&gt;</span>(T::metadata)-&gt;pythonClass = x.<a class="code" href="a00155.html#aed0915f1cc32c0c1e12e209abfedf615">type_object</a>();
<a name="l00060"></a>00060       <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>();
<a name="l00061"></a>00061     }
<a name="l00062"></a>00062 };
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 <span class="comment"></span>
<a name="l00065"></a>00065 <span class="comment">/** @brief A template class to expose classes to Python. */</span>
<a name="l00066"></a>00066 <span class="keyword">template</span> &lt;<span class="keyword">class</span> ME, <span class="keyword">class</span> BASE&gt;
<a name="l00067"></a><a class="code" href="a00077.html">00067</a> <span class="keyword">class </span><a class="code" href="a00077.html" title="A template class to expose classes to Python.">FreppleClass</a>  : <span class="keyword">public</span> <a class="code" href="a00150.html" title="Template class to define Python extensions.">PythonExtension</a>&lt; FreppleClass&lt;ME,BASE&gt; &gt;
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069   <span class="keyword">public</span>:
<a name="l00070"></a><a class="code" href="a00077.html#a72fb7e5ca15ba579964e85fcd2ce6c0a">00070</a>     <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="a00077.html#a72fb7e5ca15ba579964e85fcd2ce6c0a">initialize</a>()
<a name="l00071"></a>00071     {
<a name="l00072"></a>00072       <span class="comment">// Initialize the type</span>
<a name="l00073"></a>00073       <a class="code" href="a00155.html" title="This class is a thin wrapper around the type information in Python.">PythonType</a>&amp; x = <a class="code" href="a00150.html" title="Template class to define Python extensions.">PythonExtension&lt; FreppleClass&lt;ME,BASE&gt;</a> &gt;<a class="code" href="a00150.html#aec65c2cd811051918027ae6dc00fcfaf">::getType</a>();
<a name="l00074"></a>00074       x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(ME::metadata-&gt;type);
<a name="l00075"></a>00075       x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">&quot;frePPLe &quot;</span> + ME::metadata-&gt;type);
<a name="l00076"></a>00076       x.<a class="code" href="a00155.html#a8d3f24e0357f41ac3bc0be78bd2ab268">supportgetattro</a>();
<a name="l00077"></a>00077       x.<a class="code" href="a00155.html#a83866bef191c69cf8506426fe38b8d19">supportsetattro</a>();
<a name="l00078"></a>00078       x.<a class="code" href="a00155.html#a23a670ed39c26ab20ec400cbe3618e6c">supportstr</a>();
<a name="l00079"></a>00079       x.<a class="code" href="a00155.html#ae96d28a03dbcf0e2b51100d8d2e6d621">supportcompare</a>();
<a name="l00080"></a>00080       x.<a class="code" href="a00155.html#a001dc53b2dd832c001aee4d21bc7bf09">supportcreate</a>(Object::create&lt;ME&gt;);
<a name="l00081"></a>00081       x.<a class="code" href="a00155.html#a583846cf8dc2a5c91f5ebb9941039ae5">setBase</a>(BASE::metadata-&gt;pythonClass);
<a name="l00082"></a>00082       x.<a class="code" href="a00155.html#ab5950f891179f3ae7d31f4977580cb1d">addMethod</a>(<span class="stringliteral">&quot;toXML&quot;</span>, ME::toXML, METH_VARARGS, <span class="stringliteral">&quot;return a XML representation&quot;</span>);
<a name="l00083"></a>00083       <span class="keyword">const_cast&lt;</span><a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>*<span class="keyword">&gt;</span>(ME::metadata)-&gt;pythonClass = x.<a class="code" href="a00155.html#aed0915f1cc32c0c1e12e209abfedf615">type_object</a>();
<a name="l00084"></a>00084       <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>();
<a name="l00085"></a>00085     }
<a name="l00086"></a>00086 };
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 } <span class="comment">// end namespace</span>
<a name="l00089"></a>00089 } <span class="comment">// end namespace</span>
</pre></div></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>