Sophie

Sophie

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

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: setupmatrix.cpp 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_88117dff2735251a69c8eb9084477714.html">src</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_25032d30b6d615a661c02e2ac1394b01.html">model</a>
  </div>
</div>
<div class="contents">
<h1>setupmatrix.cpp</h1><a href="a00237.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/src/model/setupmatrix.cpp $</span>
<a name="l00003"></a>00003 <span class="comment">  version : $LastChangedRevision: 1171 $  $LastChangedBy: jdetaeye $</span>
<a name="l00004"></a>00004 <span class="comment">  date : $LastChangedDate: 2010-01-31 22:52:44 +0100 (Sun, 31 Jan 2010) $</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) 2009 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 
<a name="l00028"></a><a class="code" href="a00237.html#a342983a479ae7a921be5face83fdb029">00028</a> <span class="preprocessor">#define FREPPLE_CORE</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="a00218.html">frepple/model.h</a>&quot;</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="keyword">namespace </span>frepple
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="keyword">template</span>&lt;<span class="keyword">class</span> SetupMatrix&gt; <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00181.html" title="This class implements a binary tree data structure. It is used as a container for...">Tree</a> utils::HasName&lt;SetupMatrix&gt;::st;
<a name="l00035"></a>00035 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> <a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>* <a class="code" href="a00165.html#a1d872c221ddb757bd195c43c85ee160b">SetupMatrix::metadata</a>;
<a name="l00036"></a>00036 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>* <a class="code" href="a00166.html#a3e3c250bf0f45f79996e63553e3d806e">SetupMatrixDefault::metadata</a>;
<a name="l00037"></a>00037 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> <a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>* <a class="code" href="a00160.html#ae470441d15b30b149d7179596c96498e">SetupMatrix::Rule::metadata</a>;
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 
<a name="l00040"></a><a class="code" href="a00165.html#a4914a2c19f5a89b61ed75039de1ea7ea">00040</a> <span class="keywordtype">int</span> <a class="code" href="a00165.html#a4914a2c19f5a89b61ed75039de1ea7ea">SetupMatrix::initialize</a>()
<a name="l00041"></a>00041 {
<a name="l00042"></a>00042   <span class="comment">// Initialize the metadata</span>
<a name="l00043"></a>00043   <a class="code" href="a00165.html#a1d872c221ddb757bd195c43c85ee160b">metadata</a> = <span class="keyword">new</span> <a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>(<span class="stringliteral">&quot;setupmatrix&quot;</span>, <span class="stringliteral">&quot;setupmatrices&quot;</span>, <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">reader</a>, <a class="code" href="a00085.html#a1071369052edea444a06baa35d7e991e">writer</a>);
<a name="l00044"></a>00044 
<a name="l00045"></a>00045   <span class="comment">// Initialize the Python class</span>
<a name="l00046"></a>00046   <a class="code" href="a00165.html#a49b6a21717b4a60ef7de3a8380286240">FreppleCategory&lt;SetupMatrix&gt;::getType</a>().addMethod(<span class="stringliteral">&quot;addRule&quot;</span>, <a class="code" href="a00165.html#a11ff98a0b634aa2a7127d054b3655bc3">addPythonRule</a>, METH_KEYWORDS, <span class="stringliteral">&quot;add a new setup rule&quot;</span>);
<a name="l00047"></a>00047   <span class="keywordflow">return</span> <a class="code" href="a00165.html#a4914a2c19f5a89b61ed75039de1ea7ea">FreppleCategory&lt;SetupMatrix&gt;::initialize</a>()
<a name="l00048"></a>00048     + <a class="code" href="a00160.html#a66c9698df6098ec77684eaca40a1d746">Rule::initialize</a>()
<a name="l00049"></a>00049     + <a class="code" href="a00165.html#a4914a2c19f5a89b61ed75039de1ea7ea">SetupMatrixRuleIterator::initialize</a>();
<a name="l00050"></a>00050 }
<a name="l00051"></a>00051 
<a name="l00052"></a>00052 
<a name="l00053"></a><a class="code" href="a00160.html#a66c9698df6098ec77684eaca40a1d746">00053</a> <span class="keywordtype">int</span> <a class="code" href="a00160.html#a66c9698df6098ec77684eaca40a1d746">SetupMatrix::Rule::initialize</a>()
<a name="l00054"></a>00054 {
<a name="l00055"></a>00055   <span class="comment">// Initialize the metadata</span>
<a name="l00056"></a>00056   <a class="code" href="a00160.html#ae470441d15b30b149d7179596c96498e">metadata</a> = <span class="keyword">new</span> <a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>(<span class="stringliteral">&quot;setupmatrixrule&quot;</span>, <span class="stringliteral">&quot;setupmatrixrules&quot;</span>);
<a name="l00057"></a>00057 
<a name="l00058"></a>00058   <span class="comment">// Initialize the Python class</span>
<a name="l00059"></a>00059   <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="a00160.html#aeeda9c9e26302325a381179961552050">PythonExtension&lt;SetupMatrix::Rule&gt;::getType</a>();
<a name="l00060"></a>00060   x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(<span class="stringliteral">&quot;setupmatrixrule&quot;</span>);
<a name="l00061"></a>00061   x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">&quot;frePPLe setupmatrixrule&quot;</span>);
<a name="l00062"></a>00062   x.<a class="code" href="a00155.html#a8d3f24e0357f41ac3bc0be78bd2ab268">supportgetattro</a>();
<a name="l00063"></a>00063   x.<a class="code" href="a00155.html#a83866bef191c69cf8506426fe38b8d19">supportsetattro</a>();
<a name="l00064"></a>00064   <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>(<a class="code" href="a00160.html#ae470441d15b30b149d7179596c96498e">metadata</a>)-&gt;pythonClass = x.<a class="code" href="a00155.html#aed0915f1cc32c0c1e12e209abfedf615">type_object</a>();
<a name="l00065"></a>00065   <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>();
<a name="l00066"></a>00066 }
<a name="l00067"></a>00067 
<a name="l00068"></a>00068 
<a name="l00069"></a><a class="code" href="a00166.html#a77a0fb03843ecff3c5a8454b73cc1556">00069</a> <span class="keywordtype">int</span> <a class="code" href="a00165.html#a4914a2c19f5a89b61ed75039de1ea7ea">SetupMatrixDefault::initialize</a>()
<a name="l00070"></a>00070 {
<a name="l00071"></a>00071   <span class="comment">// Initialize the metadata</span>
<a name="l00072"></a>00072   <a class="code" href="a00166.html#a3e3c250bf0f45f79996e63553e3d806e">SetupMatrixDefault::metadata</a> = <span class="keyword">new</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>(
<a name="l00073"></a>00073     <span class="stringliteral">&quot;setupmatrix&quot;</span>,
<a name="l00074"></a>00074     <span class="stringliteral">&quot;setupmatrix_default&quot;</span>,
<a name="l00075"></a>00075     Object::createString&lt;SetupMatrixDefault&gt;, <span class="keyword">true</span>);
<a name="l00076"></a>00076 
<a name="l00077"></a>00077   <span class="comment">// Initialize the Python class</span>
<a name="l00078"></a>00078   <span class="keywordflow">return</span> <a class="code" href="a00166.html#a77a0fb03843ecff3c5a8454b73cc1556">FreppleClass&lt;SetupMatrixDefault,SetupMatrix&gt;::initialize</a>();
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080 
<a name="l00081"></a>00081 
<a name="l00082"></a><a class="code" href="a00165.html#ade0fa81597c2350dd9edd907caa68e97">00082</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00165.html#ade0fa81597c2350dd9edd907caa68e97">SetupMatrix::~SetupMatrix</a>()
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084   <span class="comment">// Destroy the rules.</span>
<a name="l00085"></a>00085   <span class="comment">// Note that the rule destructor updates the firstRule field.</span>
<a name="l00086"></a>00086   <span class="keywordflow">while</span> (firstRule) <span class="keyword">delete</span> firstRule;
<a name="l00087"></a>00087 
<a name="l00088"></a>00088   <span class="comment">// Remove all references to this setup matrix from resources</span>
<a name="l00089"></a>00089   <span class="keywordflow">for</span> (Resource::iterator m = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Resource::begin</a>(); m != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Resource::end</a>(); ++m)
<a name="l00090"></a>00090     <span class="keywordflow">if</span> (m-&gt;getSetupMatrix() == <span class="keyword">this</span>) m-&gt;setSetupMatrix(NULL);
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 
<a name="l00094"></a><a class="code" href="a00165.html#a4a43de4b7ac0d8b4b9d8705227dd0a49">00094</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00165.html#a4a43de4b7ac0d8b4b9d8705227dd0a49">SetupMatrix::writeElement</a>(<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&amp; tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m)<span class="keyword"> const</span>
<a name="l00095"></a>00095 <span class="keyword"></span>{
<a name="l00096"></a>00096   <span class="comment">// Writing a reference</span>
<a name="l00097"></a>00097   <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>)
<a name="l00098"></a>00098   {
<a name="l00099"></a>00099     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>
<a name="l00100"></a>00100       (tag, <a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>(), <a class="code" href="a00177.html#a6745112e0237e378e2b0cbe41aa5926a">Tags::tag_type</a>, <a class="code" href="a00165.html#a49b6a21717b4a60ef7de3a8380286240">getType</a>().<a class="code" href="a00165.html" title="This class is used to represent a matrix defining the changeover times between setups...">type</a>);
<a name="l00101"></a>00101     <span class="keywordflow">return</span>;
<a name="l00102"></a>00102   }
<a name="l00103"></a>00103 
<a name="l00104"></a>00104   <span class="comment">// Write the complete object</span>
<a name="l00105"></a>00105   <span class="keywordflow">if</span> (m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>
<a name="l00106"></a>00106     (tag, <a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>(), <a class="code" href="a00177.html#a6745112e0237e378e2b0cbe41aa5926a">Tags::tag_type</a>, <a class="code" href="a00165.html#a49b6a21717b4a60ef7de3a8380286240">getType</a>().<a class="code" href="a00165.html" title="This class is used to represent a matrix defining the changeover times between setups...">type</a>);
<a name="l00107"></a>00107 
<a name="l00108"></a>00108   <span class="comment">// Write all rules</span>
<a name="l00109"></a>00109   o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a> (<a class="code" href="a00177.html#adf9ce4a1cd0abc31cd2dc644056aa21e">Tags::tag_rules</a>);
<a name="l00110"></a>00110   <span class="keywordflow">for</span> (<a class="code" href="a00161.html" title="An iterator class to go through all rules of a setup matrix.">RuleIterator</a> i = <a class="code" href="a00165.html#ae66b557c666acf915c10bb3c093b7430">beginRules</a>(); i != <a class="code" href="a00165.html#a7aaf1d728ef211fcfb4193cfa547dcfa">endRules</a>(); ++i)
<a name="l00111"></a>00111     <span class="comment">// We use the FULL mode, to force the rules being written regardless</span>
<a name="l00112"></a>00112     <span class="comment">// of the depth in the XML tree.</span>
<a name="l00113"></a>00113     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a53c64631ad387226a9fee934e53b22ff">Tags::tag_rule</a>, *i, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398ae6f8960699e19b8d77b093b7e2c48619">FULL</a>);
<a name="l00114"></a>00114   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(<a class="code" href="a00177.html#adf9ce4a1cd0abc31cd2dc644056aa21e">Tags::tag_rules</a>);
<a name="l00115"></a>00115 
<a name="l00116"></a>00116   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag);
<a name="l00117"></a>00117 }
<a name="l00118"></a>00118 
<a name="l00119"></a>00119 
<a name="l00120"></a><a class="code" href="a00165.html#a268684607c920d46b82c2a00e2009aba">00120</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00165.html#a268684607c920d46b82c2a00e2009aba">SetupMatrix::beginElement</a>(<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr)
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a53c64631ad387226a9fee934e53b22ff">Tags::tag_rule</a>)
<a name="l00123"></a>00123       &amp;&amp; pIn.<a class="code" href="a00186.html#a407522e9d0dde7f7eebfafe182d050cf">getParentElement</a>().first.isA(<a class="code" href="a00177.html#adf9ce4a1cd0abc31cd2dc644056aa21e">Tags::tag_rules</a>))
<a name="l00124"></a>00124     <span class="comment">// A new rule</span>
<a name="l00125"></a>00125     pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>(<a class="code" href="a00165.html#a28def329cc231c3916fae7dce002bd61">createRule</a>(pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()));
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 
<a name="l00128"></a>00128 
<a name="l00129"></a><a class="code" href="a00165.html#a28def329cc231c3916fae7dce002bd61">00129</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">SetupMatrix::Rule</a>* <a class="code" href="a00165.html#a28def329cc231c3916fae7dce002bd61">SetupMatrix::createRule</a>(<span class="keyword">const</span> <a class="code" href="a00003.html" title="This class represents a dictionary of keyword + value pairs.">AttributeList</a>&amp; atts)
<a name="l00130"></a>00130 {
<a name="l00131"></a>00131   <span class="comment">// Pick up the start, end and name attributes</span>
<a name="l00132"></a>00132   <span class="keywordtype">int</span> priority = atts.<a class="code" href="a00003.html#afc79347bc21694cedfe218f8d023235f">get</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>)-&gt;<a class="code" href="a00047.html#a0d8c973cc584400f5ea5d8acfd82ace2">getInt</a>();
<a name="l00133"></a>00133 
<a name="l00134"></a>00134   <span class="comment">// Check for existence of a rule with the same priority</span>
<a name="l00135"></a>00135   <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>* result = firstRule;
<a name="l00136"></a>00136   <span class="keywordflow">while</span> (result &amp;&amp; priority &gt; result-&gt;priority)
<a name="l00137"></a>00137     result = result-&gt;nextRule;
<a name="l00138"></a>00138   <span class="keywordflow">if</span> (result &amp;&amp; result-&gt;priority != priority) result = NULL;
<a name="l00139"></a>00139 
<a name="l00140"></a>00140   <span class="comment">// Pick up the action attribute and update the rule accordingly</span>
<a name="l00141"></a>00141   <span class="keywordflow">switch</span> (MetaClass::decodeAction(atts))
<a name="l00142"></a>00142   {
<a name="l00143"></a>00143     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a8f6183fcf54ca6985ff2b5ef80673a25">ADD</a>:
<a name="l00144"></a>00144       <span class="comment">// Only additions are allowed</span>
<a name="l00145"></a>00145       <span class="keywordflow">if</span> (result)
<a name="l00146"></a>00146       {
<a name="l00147"></a>00147         ostringstream o;
<a name="l00148"></a>00148         o &lt;&lt; <span class="stringliteral">&quot;Rule with priority &quot;</span>  &lt;&lt; priority
<a name="l00149"></a>00149           &lt;&lt; <span class="stringliteral">&quot; already exists in setup matrix &apos;&quot;</span> &lt;&lt; <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() &lt;&lt; <span class="stringliteral">&quot;&apos;&quot;</span>;
<a name="l00150"></a>00150         <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(o.str());
<a name="l00151"></a>00151       }
<a name="l00152"></a>00152       result = <span class="keyword">new</span> <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>(<span class="keyword">this</span>, priority);
<a name="l00153"></a>00153       <span class="keywordflow">return</span> result;
<a name="l00154"></a>00154     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a1b9888c025bb8f78e322471fd5e14423">CHANGE</a>:
<a name="l00155"></a>00155       <span class="comment">// Only changes are allowed</span>
<a name="l00156"></a>00156       <span class="keywordflow">if</span> (!result)
<a name="l00157"></a>00157       {
<a name="l00158"></a>00158         ostringstream o;
<a name="l00159"></a>00159         o &lt;&lt; <span class="stringliteral">&quot;No rule with priority &quot;</span> &lt;&lt; priority
<a name="l00160"></a>00160           &lt;&lt; <span class="stringliteral">&quot; exists in setup matrix &apos;&quot;</span> &lt;&lt; <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() &lt;&lt; <span class="stringliteral">&quot;&apos;&quot;</span>;
<a name="l00161"></a>00161         <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(o.str());
<a name="l00162"></a>00162       }
<a name="l00163"></a>00163       <span class="keywordflow">return</span> result;
<a name="l00164"></a>00164     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a6b9fb19e9a6595385dec31b63e0054e1">REMOVE</a>:
<a name="l00165"></a>00165       <span class="comment">// Delete the entity</span>
<a name="l00166"></a>00166       <span class="keywordflow">if</span> (!result)
<a name="l00167"></a>00167       {
<a name="l00168"></a>00168         ostringstream o;
<a name="l00169"></a>00169         o &lt;&lt; <span class="stringliteral">&quot;No rule with priority &quot;</span> &lt;&lt; priority
<a name="l00170"></a>00170           &lt;&lt; <span class="stringliteral">&quot; exists in setup matrix &apos;&quot;</span> &lt;&lt; <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() &lt;&lt; <span class="stringliteral">&quot;&apos;&quot;</span>;
<a name="l00171"></a>00171         <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(o.str());
<a name="l00172"></a>00172       }
<a name="l00173"></a>00173       <span class="keywordflow">else</span>
<a name="l00174"></a>00174       {
<a name="l00175"></a>00175         <span class="comment">// Delete it</span>
<a name="l00176"></a>00176         <span class="keyword">delete</span> result;
<a name="l00177"></a>00177         <span class="keywordflow">return</span> NULL;
<a name="l00178"></a>00178       }
<a name="l00179"></a>00179     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a75b4aab762127e8083e16661b4021a00">ADD_CHANGE</a>:
<a name="l00180"></a>00180       <span class="keywordflow">if</span> (!result)
<a name="l00181"></a>00181         <span class="comment">// Adding a new rule</span>
<a name="l00182"></a>00182         result = <span class="keyword">new</span> <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>(<span class="keyword">this</span>, priority);
<a name="l00183"></a>00183       <span class="keywordflow">return</span> result;
<a name="l00184"></a>00184   }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186   <span class="comment">// This part of the code isn&apos;t expected not be reached</span>
<a name="l00187"></a>00187   <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Unreachable code reached&quot;</span>);
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 
<a name="l00190"></a>00190 
<a name="l00191"></a><a class="code" href="a00165.html#a8fd8e1aa2ff563c3d26a6306b4ea495c">00191</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00165.html#a8fd8e1aa2ff563c3d26a6306b4ea495c">SetupMatrix::endElement</a>(<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>&amp; pElement)
<a name="l00192"></a>00192 {
<a name="l00193"></a>00193   <a class="code" href="a00165.html#a8fd8e1aa2ff563c3d26a6306b4ea495c">HasName&lt;SetupMatrix&gt;::endElement</a>(pIn, pAttr, pElement);
<a name="l00194"></a>00194 }
<a name="l00195"></a>00195 
<a name="l00196"></a>00196 
<a name="l00197"></a><a class="code" href="a00165.html#a95cfcffab5777c42c5594f52f54e24cf">00197</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00165.html#a95cfcffab5777c42c5594f52f54e24cf">SetupMatrix::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr)
<a name="l00198"></a>00198 {
<a name="l00199"></a>00199   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>))
<a name="l00200"></a>00200     <span class="keywordflow">return</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>());
<a name="l00201"></a>00201   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#adf9ce4a1cd0abc31cd2dc644056aa21e">Tags::tag_rules</a>))
<a name="l00202"></a>00202     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="a00168.html">SetupMatrixRuleIterator</a>(<span class="keyword">this</span>);
<a name="l00203"></a>00203   <span class="keywordflow">return</span> NULL;
<a name="l00204"></a>00204 }
<a name="l00205"></a>00205 
<a name="l00206"></a>00206 
<a name="l00207"></a><a class="code" href="a00165.html#adf66d9dae820a2b0f1e7b1ae3b544232">00207</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00165.html#adf66d9dae820a2b0f1e7b1ae3b544232">SetupMatrix::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>&amp; field)
<a name="l00208"></a>00208 {
<a name="l00209"></a>00209   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>))
<a name="l00210"></a>00210     <a class="code" href="a00085.html#a97d855d8c9bc9774da9cd8905e242dde">setName</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l00211"></a>00211   <span class="keywordflow">return</span> 0;
<a name="l00212"></a>00212 }
<a name="l00213"></a>00213 
<a name="l00214"></a>00214 
<a name="l00215"></a><a class="code" href="a00165.html#a11ff98a0b634aa2a7127d054b3655bc3">00215</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00165.html#a11ff98a0b634aa2a7127d054b3655bc3">SetupMatrix::addPythonRule</a>(PyObject* <span class="keyword">self</span>, PyObject* args, PyObject* kwdict)
<a name="l00216"></a>00216 {
<a name="l00217"></a>00217   <span class="keywordflow">try</span>
<a name="l00218"></a>00218   {
<a name="l00219"></a>00219     <span class="comment">// Pick up the setup matrix</span>
<a name="l00220"></a>00220     <a class="code" href="a00165.html" title="This class is used to represent a matrix defining the changeover times between setups...">SetupMatrix</a> *matrix = <span class="keyword">static_cast&lt;</span><a class="code" href="a00165.html" title="This class is used to represent a matrix defining the changeover times between setups...">SetupMatrix</a>*<span class="keyword">&gt;</span>(<span class="keyword">self</span>);
<a name="l00221"></a>00221     <span class="keywordflow">if</span> (!matrix) <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Can&apos;t add a rule to a NULL setupmatrix&quot;</span>);
<a name="l00222"></a>00222 
<a name="l00223"></a>00223     <span class="comment">// Parse the arguments</span>
<a name="l00224"></a>00224     <span class="keywordtype">int</span> prio = 0;
<a name="l00225"></a>00225     PyObject *pyfrom = NULL;
<a name="l00226"></a>00226     PyObject *pyto = NULL;
<a name="l00227"></a>00227     <span class="keywordtype">long</span> duration = 0;
<a name="l00228"></a>00228     <span class="keywordtype">double</span> cost = 0;
<a name="l00229"></a>00229     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *kwlist[] = {<span class="stringliteral">&quot;priority&quot;</span>, <span class="stringliteral">&quot;fromsetup&quot;</span>, <span class="stringliteral">&quot;tosetup&quot;</span>, <span class="stringliteral">&quot;duration&quot;</span>, <span class="stringliteral">&quot;cost&quot;</span>, NULL};
<a name="l00230"></a>00230     <span class="keywordflow">if</span> (!PyArg_ParseTupleAndKeywords(args, kwdict,
<a name="l00231"></a>00231       <span class="stringliteral">&quot;i|ssld:addRule&quot;</span>,
<a name="l00232"></a>00232       const_cast&lt;char**&gt;(kwlist), &amp;prio, &amp;pyfrom, &amp;pyto, &amp;duration, &amp;cost))
<a name="l00233"></a>00233         <span class="keywordflow">return</span> NULL;
<a name="l00234"></a>00234 
<a name="l00235"></a>00235     <span class="comment">// Add the new rule</span>
<a name="l00236"></a>00236     <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a> * r = <span class="keyword">new</span> <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>(matrix, prio);
<a name="l00237"></a>00237     <span class="keywordflow">if</span> (pyfrom) r-&gt;<a class="code" href="a00160.html#afeda6a852fcf4390a0b5abd8a5ead426">setFromSetup</a>(<a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(pyfrom).getString());
<a name="l00238"></a>00238     <span class="keywordflow">if</span> (pyto) r-&gt;<a class="code" href="a00160.html#a2abdf44bfdecb8a6ca539f74d4872af9">setToSetup</a>(<a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(pyfrom).getString());
<a name="l00239"></a>00239     r-&gt;<a class="code" href="a00160.html#a462401ed07d7ed19d50a9302f7662458">setDuration</a>(duration);
<a name="l00240"></a>00240     r-&gt;<a class="code" href="a00160.html#a2d9c5a9e6b0b5f84e1a08f633fff184a">setCost</a>(cost);
<a name="l00241"></a>00241     <span class="keywordflow">return</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(r);
<a name="l00242"></a>00242   }
<a name="l00243"></a>00243   <span class="keywordflow">catch</span>(...)
<a name="l00244"></a>00244   {
<a name="l00245"></a>00245     PythonType::evalException();
<a name="l00246"></a>00246     <span class="keywordflow">return</span> NULL;
<a name="l00247"></a>00247   }
<a name="l00248"></a>00248 }
<a name="l00249"></a>00249 
<a name="l00250"></a>00250 
<a name="l00251"></a><a class="code" href="a00160.html#aab09b14a3ccc5ac8fca5f06c46bb9230">00251</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00160.html#aab09b14a3ccc5ac8fca5f06c46bb9230">SetupMatrix::Rule::Rule</a>(<a class="code" href="a00165.html" title="This class is used to represent a matrix defining the changeover times between setups...">SetupMatrix</a> *s, <span class="keywordtype">int</span> p)
<a name="l00252"></a>00252   : cost(0), priority(p), matrix(s), nextRule(NULL), prevRule(NULL)
<a name="l00253"></a>00253 {
<a name="l00254"></a>00254   <span class="comment">// Validate the arguments</span>
<a name="l00255"></a>00255   <span class="keywordflow">if</span> (!matrix) <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Can&apos;t add a rule to NULL setup matrix&quot;</span>);
<a name="l00256"></a>00256 
<a name="l00257"></a>00257   <span class="comment">// Find the right place in the list</span>
<a name="l00258"></a>00258   <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a> *next = matrix-&gt;firstRule, *prev = NULL;
<a name="l00259"></a>00259   <span class="keywordflow">while</span> (next &amp;&amp; p &gt; next-&gt;priority)
<a name="l00260"></a>00260   {
<a name="l00261"></a>00261     prev = next;
<a name="l00262"></a>00262     next = next-&gt;nextRule;
<a name="l00263"></a>00263   }
<a name="l00264"></a>00264 
<a name="l00265"></a>00265   <span class="comment">// Duplicate priority</span>
<a name="l00266"></a>00266   <span class="keywordflow">if</span> (next &amp;&amp; next-&gt;priority == p)
<a name="l00267"></a>00267     <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Multiple rules with identical priority in setup matrix&quot;</span>);
<a name="l00268"></a>00268 
<a name="l00269"></a>00269   <span class="comment">// Maintain linked list</span>
<a name="l00270"></a>00270   nextRule = next;
<a name="l00271"></a>00271   prevRule = prev;
<a name="l00272"></a>00272   <span class="keywordflow">if</span> (prev) prev-&gt;nextRule = <span class="keyword">this</span>;
<a name="l00273"></a>00273   <span class="keywordflow">else</span> matrix-&gt;firstRule = <span class="keyword">this</span>;
<a name="l00274"></a>00274   <span class="keywordflow">if</span> (next) next-&gt;prevRule = <span class="keyword">this</span>;
<a name="l00275"></a>00275 
<a name="l00276"></a>00276   <span class="comment">// Initialize the Python type</span>
<a name="l00277"></a>00277   <a class="code" href="a00151.html#ae5f2cd7cfa5367e07b3de396fe98fbfd">initType</a>(<a class="code" href="a00160.html#ae470441d15b30b149d7179596c96498e">metadata</a>);
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 
<a name="l00280"></a>00280 
<a name="l00281"></a><a class="code" href="a00160.html#aac1bc5ee4f1cc00daa04c682d33e2205">00281</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00160.html#aac1bc5ee4f1cc00daa04c682d33e2205">SetupMatrix::Rule::~Rule</a>()
<a name="l00282"></a>00282 {
<a name="l00283"></a>00283   <span class="comment">// Maintain linked list</span>
<a name="l00284"></a>00284   <span class="keywordflow">if</span> (nextRule) nextRule-&gt;prevRule = prevRule;
<a name="l00285"></a>00285   <span class="keywordflow">if</span> (prevRule) prevRule-&gt;nextRule = nextRule;
<a name="l00286"></a>00286   <span class="keywordflow">else</span> matrix-&gt;firstRule = nextRule;
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288 
<a name="l00289"></a>00289 
<a name="l00290"></a>00290 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00165.html#a4a43de4b7ac0d8b4b9d8705227dd0a49">SetupMatrix::Rule::writeElement</a>
<a name="l00291"></a><a class="code" href="a00160.html#a85805ac8e48a65353925b1c66db9bef1">00291</a> (<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&amp; tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m) <span class="keyword">const</span>
<a name="l00292"></a>00292 {
<a name="l00293"></a>00293   o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(tag, <a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>, priority);
<a name="l00294"></a>00294   <span class="keywordflow">if</span> (!from.empty()) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ada79c2bd71b7e8082711572a3052ef28">Tags::tag_fromsetup</a>, from);
<a name="l00295"></a>00295   <span class="keywordflow">if</span> (!to.empty()) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a24cd8bd821d8642879238929884a69f2">Tags::tag_tosetup</a>, to);
<a name="l00296"></a>00296   <span class="keywordflow">if</span> (duration) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>, duration);
<a name="l00297"></a>00297   <span class="keywordflow">if</span> (cost) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>, cost);
<a name="l00298"></a>00298   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag);
<a name="l00299"></a>00299 }
<a name="l00300"></a>00300 
<a name="l00301"></a>00301 
<a name="l00302"></a><a class="code" href="a00160.html#aa1a62514cbfce49c2a6fad86f9f2b619">00302</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00165.html#a8fd8e1aa2ff563c3d26a6306b4ea495c">SetupMatrix::Rule::endElement</a> (<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>&amp; pElement)
<a name="l00303"></a>00303 {
<a name="l00304"></a>00304   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>))
<a name="l00305"></a>00305     <a class="code" href="a00160.html#a9b9482727e470f01960eb6fa74686712">setPriority</a>(pElement.<a class="code" href="a00047.html#a0d8c973cc584400f5ea5d8acfd82ace2">getInt</a>());
<a name="l00306"></a>00306   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ada79c2bd71b7e8082711572a3052ef28">Tags::tag_fromsetup</a>))
<a name="l00307"></a>00307     <a class="code" href="a00160.html#afeda6a852fcf4390a0b5abd8a5ead426">setFromSetup</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>());
<a name="l00308"></a>00308   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a24cd8bd821d8642879238929884a69f2">Tags::tag_tosetup</a>))
<a name="l00309"></a>00309     <a class="code" href="a00160.html#a2abdf44bfdecb8a6ca539f74d4872af9">setToSetup</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>());
<a name="l00310"></a>00310   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l00311"></a>00311     <a class="code" href="a00160.html#a462401ed07d7ed19d50a9302f7662458">setDuration</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>());
<a name="l00312"></a>00312   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>))
<a name="l00313"></a>00313     <a class="code" href="a00160.html#a2d9c5a9e6b0b5f84e1a08f633fff184a">setCost</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>());
<a name="l00314"></a>00314 }
<a name="l00315"></a>00315 
<a name="l00316"></a>00316 
<a name="l00317"></a><a class="code" href="a00160.html#ae9aef1dfff28ff034dfeee764a212f6b">00317</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00165.html#a95cfcffab5777c42c5594f52f54e24cf">SetupMatrix::Rule::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr)
<a name="l00318"></a>00318 {
<a name="l00319"></a>00319   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>))
<a name="l00320"></a>00320     <span class="keywordflow">return</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(priority);
<a name="l00321"></a>00321   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ada79c2bd71b7e8082711572a3052ef28">Tags::tag_fromsetup</a>))
<a name="l00322"></a>00322     <span class="keywordflow">return</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(from);
<a name="l00323"></a>00323   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a24cd8bd821d8642879238929884a69f2">Tags::tag_tosetup</a>))
<a name="l00324"></a>00324     <span class="keywordflow">return</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(to);
<a name="l00325"></a>00325   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l00326"></a>00326     <span class="keywordflow">return</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(duration);
<a name="l00327"></a>00327   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>))
<a name="l00328"></a>00328     <span class="keywordflow">return</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(cost);
<a name="l00329"></a>00329   <span class="keywordflow">return</span> NULL;
<a name="l00330"></a>00330 }
<a name="l00331"></a>00331 
<a name="l00332"></a>00332 
<a name="l00333"></a><a class="code" href="a00160.html#ab36d248ccce512ee2687ed0912345a3b">00333</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00165.html#adf66d9dae820a2b0f1e7b1ae3b544232">SetupMatrix::Rule::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>&amp; field)
<a name="l00334"></a>00334 {
<a name="l00335"></a>00335   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>))
<a name="l00336"></a>00336     <a class="code" href="a00160.html#a9b9482727e470f01960eb6fa74686712">setPriority</a>(field.<a class="code" href="a00154.html#a783ec10f02cad37886df55bc3f08ba5e">getInt</a>());
<a name="l00337"></a>00337   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ada79c2bd71b7e8082711572a3052ef28">Tags::tag_fromsetup</a>))
<a name="l00338"></a>00338     <a class="code" href="a00160.html#afeda6a852fcf4390a0b5abd8a5ead426">setFromSetup</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l00339"></a>00339   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a24cd8bd821d8642879238929884a69f2">Tags::tag_tosetup</a>))
<a name="l00340"></a>00340     <a class="code" href="a00160.html#a2abdf44bfdecb8a6ca539f74d4872af9">setToSetup</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l00341"></a>00341   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l00342"></a>00342     <a class="code" href="a00160.html#a462401ed07d7ed19d50a9302f7662458">setDuration</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>());
<a name="l00343"></a>00343   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>))
<a name="l00344"></a>00344     <a class="code" href="a00160.html#a2d9c5a9e6b0b5f84e1a08f633fff184a">setCost</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>());
<a name="l00345"></a>00345   <span class="keywordflow">else</span>
<a name="l00346"></a>00346     <span class="keywordflow">return</span> -1;  <span class="comment">// Error</span>
<a name="l00347"></a>00347   <span class="keywordflow">return</span> 0;  <span class="comment">// OK</span>
<a name="l00348"></a>00348 }
<a name="l00349"></a>00349 
<a name="l00350"></a>00350 
<a name="l00351"></a><a class="code" href="a00160.html#a9b9482727e470f01960eb6fa74686712">00351</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00160.html#a9b9482727e470f01960eb6fa74686712">SetupMatrix::Rule::setPriority</a>(<span class="keyword">const</span> <span class="keywordtype">int</span> n)
<a name="l00352"></a>00352 {
<a name="l00353"></a>00353   <span class="comment">// Update the field</span>
<a name="l00354"></a>00354   priority = n;
<a name="l00355"></a>00355 
<a name="l00356"></a>00356   <span class="comment">// Check ordering on the left</span>
<a name="l00357"></a>00357   <span class="keywordflow">while</span> (prevRule &amp;&amp; priority &lt; prevRule-&gt;priority)
<a name="l00358"></a>00358   {
<a name="l00359"></a>00359     <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>* next = nextRule;
<a name="l00360"></a>00360     <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>* prev = prevRule;
<a name="l00361"></a>00361     <span class="keywordflow">if</span> (prev &amp;&amp; prev-&gt;prevRule) prev-&gt;prevRule-&gt;nextRule = <span class="keyword">this</span>;
<a name="l00362"></a>00362     <span class="keywordflow">else</span> matrix-&gt;firstRule = <span class="keyword">this</span>;
<a name="l00363"></a>00363     <span class="keywordflow">if</span> (prev) prev-&gt;nextRule = nextRule;
<a name="l00364"></a>00364     nextRule = prev;
<a name="l00365"></a>00365     prevRule = prev ? prev-&gt;prevRule : NULL;
<a name="l00366"></a>00366     <span class="keywordflow">if</span> (next &amp;&amp; next-&gt;nextRule) next-&gt;nextRule-&gt;prevRule = prev;
<a name="l00367"></a>00367     <span class="keywordflow">if</span> (next) next-&gt;prevRule = prev;
<a name="l00368"></a>00368     <span class="keywordflow">if</span> (prev) prev-&gt;prevRule = <span class="keyword">this</span>;
<a name="l00369"></a>00369   }
<a name="l00370"></a>00370 
<a name="l00371"></a>00371   <span class="comment">// Check ordering on the right</span>
<a name="l00372"></a>00372   <span class="keywordflow">while</span> (nextRule &amp;&amp; priority &gt; nextRule-&gt;priority)
<a name="l00373"></a>00373   {
<a name="l00374"></a>00374     <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>* next = nextRule;
<a name="l00375"></a>00375     <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a>* prev = prevRule;
<a name="l00376"></a>00376     nextRule = next-&gt;nextRule;
<a name="l00377"></a>00377     <span class="keywordflow">if</span> (next &amp;&amp; next-&gt;nextRule) next-&gt;nextRule-&gt;prevRule = <span class="keyword">this</span>;
<a name="l00378"></a>00378     <span class="keywordflow">if</span> (prev) prev-&gt;nextRule = next;
<a name="l00379"></a>00379     <span class="keywordflow">if</span> (next) next-&gt;nextRule = <span class="keyword">this</span>;
<a name="l00380"></a>00380     <span class="keywordflow">if</span> (next) next-&gt;prevRule = prev;
<a name="l00381"></a>00381     prevRule = next;
<a name="l00382"></a>00382   }
<a name="l00383"></a>00383 
<a name="l00384"></a>00384   <span class="comment">// Check for duplicate priorities</span>
<a name="l00385"></a>00385   <span class="keywordflow">if</span> ((prevRule &amp;&amp; prevRule-&gt;priority == priority)
<a name="l00386"></a>00386     || (nextRule &amp;&amp; nextRule-&gt;priority == priority))
<a name="l00387"></a>00387   {
<a name="l00388"></a>00388     ostringstream o;
<a name="l00389"></a>00389     o &lt;&lt; <span class="stringliteral">&quot;Duplicate priority &quot;</span> &lt;&lt; priority &lt;&lt; <span class="stringliteral">&quot; in setup matrix &apos;&quot;</span>
<a name="l00390"></a>00390       &lt;&lt; matrix-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() &lt;&lt; <span class="stringliteral">&quot;&apos;&quot;</span>;
<a name="l00391"></a>00391     <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(o.str());
<a name="l00392"></a>00392   }
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394 
<a name="l00395"></a>00395 
<a name="l00396"></a><a class="code" href="a00168.html#ac257ca41aa05cbfbe34233bf7e03cb93">00396</a> <span class="keywordtype">int</span> <a class="code" href="a00165.html#a4914a2c19f5a89b61ed75039de1ea7ea">SetupMatrixRuleIterator::initialize</a>()
<a name="l00397"></a>00397 {
<a name="l00398"></a>00398   <span class="comment">// Initialize the type</span>
<a name="l00399"></a>00399   <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#aec65c2cd811051918027ae6dc00fcfaf">PythonExtension&lt;SetupMatrixRuleIterator&gt;::getType</a>();
<a name="l00400"></a>00400   x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(<span class="stringliteral">&quot;setupmatrixRuleIterator&quot;</span>);
<a name="l00401"></a>00401   x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">&quot;frePPLe iterator for setupmatrix rules&quot;</span>);
<a name="l00402"></a>00402   x.<a class="code" href="a00155.html#a5bacf8ad021ab55b1056440880cf8760">supportiter</a>();
<a name="l00403"></a>00403   <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>();
<a name="l00404"></a>00404 }
<a name="l00405"></a>00405 
<a name="l00406"></a>00406 
<a name="l00407"></a>00407 PyObject* SetupMatrixRuleIterator::iternext()
<a name="l00408"></a>00408 {
<a name="l00409"></a>00409   <span class="keywordflow">if</span> (currule == matrix-&gt;<a class="code" href="a00165.html#a7aaf1d728ef211fcfb4193cfa547dcfa">endRules</a>()) <span class="keywordflow">return</span> NULL;
<a name="l00410"></a>00410   PyObject *result = &amp;*(currule++);
<a name="l00411"></a>00411   Py_INCREF(result);
<a name="l00412"></a>00412   <span class="keywordflow">return</span> result;
<a name="l00413"></a>00413 }
<a name="l00414"></a>00414 
<a name="l00415"></a>00415 
<a name="l00416"></a>00416 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> SetupMatrix::Rule* <a class="code" href="a00165.html#a2bde77a78252ad83c4429eeec7ff0348">SetupMatrix::calculateSetup</a>
<a name="l00417"></a><a class="code" href="a00165.html#a2bde77a78252ad83c4429eeec7ff0348">00417</a>   (<span class="keyword">const</span> <span class="keywordtype">string</span> oldsetup, <span class="keyword">const</span> <span class="keywordtype">string</span> newsetup) <span class="keyword">const</span>
<a name="l00418"></a>00418 {
<a name="l00419"></a>00419   <span class="comment">// No need to look</span>
<a name="l00420"></a>00420   <span class="keywordflow">if</span> (oldsetup == newsetup) <span class="keywordflow">return</span> NULL;
<a name="l00421"></a>00421 
<a name="l00422"></a>00422   <span class="comment">// Loop through all rules</span>
<a name="l00423"></a>00423   <span class="keywordflow">for</span> (<a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">Rule</a> *curRule = firstRule; curRule; curRule = curRule-&gt;nextRule)
<a name="l00424"></a>00424   {
<a name="l00425"></a>00425     <span class="comment">// Need a match on the fromsetup</span>
<a name="l00426"></a>00426     <span class="keywordflow">if</span> (!curRule-&gt;getFromSetup().empty()
<a name="l00427"></a>00427       &amp;&amp; !<a class="code" href="a00257.html#a7aa7d128febae46b7ef265606e6d0a2c">matchWildcard</a>(curRule-&gt;getFromSetup().c_str(), oldsetup.c_str()))
<a name="l00428"></a>00428         <span class="keywordflow">continue</span>;
<a name="l00429"></a>00429     <span class="comment">// Need a match on the tosetup</span>
<a name="l00430"></a>00430     <span class="keywordflow">if</span> (!curRule-&gt;getToSetup().empty()
<a name="l00431"></a>00431       &amp;&amp; !<a class="code" href="a00257.html#a7aa7d128febae46b7ef265606e6d0a2c">matchWildcard</a>(curRule-&gt;getToSetup().c_str(), newsetup.c_str()))
<a name="l00432"></a>00432         <span class="keywordflow">continue</span>;
<a name="l00433"></a>00433     <span class="comment">// Found a match</span>
<a name="l00434"></a>00434     <span class="keywordflow">return</span> curRule;
<a name="l00435"></a>00435   }
<a name="l00436"></a>00436 
<a name="l00437"></a>00437   <span class="comment">// No matching rule was found</span>
<a name="l00438"></a>00438   <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Warning: Conversion from &apos;&quot;</span> &lt;&lt; oldsetup &lt;&lt; <span class="stringliteral">&quot;&apos; to &apos;&quot;</span> &lt;&lt; newsetup 
<a name="l00439"></a>00439     &lt;&lt; <span class="stringliteral">&quot;&apos; undefined in setup matrix &apos;&quot;</span> &lt;&lt; getName() &lt;&lt; endl;
<a name="l00440"></a>00440   <span class="keywordflow">return</span> NULL;
<a name="l00441"></a>00441 }
<a name="l00442"></a>00442 
<a name="l00443"></a>00443 } <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>