<!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: buffer.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 Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_88117dff2735251a69c8eb9084477714.html">src</a> » <a class="el" href="dir_25032d30b6d615a661c02e2ac1394b01.html">model</a> </div> </div> <div class="contents"> <h1>buffer.cpp</h1><a href="a00194.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/buffer.cpp $</span> <a name="l00003"></a>00003 <span class="comment"> version : $LastChangedRevision: 1336 $ $LastChangedBy: jdetaeye $</span> <a name="l00004"></a>00004 <span class="comment"> date : $LastChangedDate: 2010-08-16 08:39:23 +0200 (Mon, 16 Aug 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) 2007-2010 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="a00194.html#a342983a479ae7a921be5face83fdb029">00028</a> <span class="preprocessor">#define FREPPLE_CORE</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="a00218.html">frepple/model.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include <math.h></span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">// This is the name used for the dummy operation used to represent the</span> <a name="l00033"></a>00033 <span class="comment">// inventory.</span> <a name="l00034"></a><a class="code" href="a00194.html#afa170ae27e19952a526c676b0ed2a099">00034</a> <span class="preprocessor">#define INVENTORY_OPERATION "Inventory of buffer '" + string(getName()) + "'"</span> <a name="l00035"></a>00035 <span class="preprocessor"></span> <a name="l00036"></a>00036 <span class="comment">// This is the name used for the dummy operation used to represent procurements</span> <a name="l00037"></a><a class="code" href="a00194.html#a4c0ba48382d5c668c848e5aecd397079">00037</a> <span class="preprocessor">#define PROCURE_OPERATION "Procure for buffer '" + string(getName()) + "'"</span> <a name="l00038"></a>00038 <span class="preprocessor"></span> <a name="l00039"></a>00039 <span class="keyword">namespace </span>frepple <a name="l00040"></a>00040 { <a name="l00041"></a>00041 <a name="l00042"></a>00042 <span class="keyword">template</span><<span class="keyword">class</span> Buffer> <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<Buffer>::st; <a name="l00043"></a>00043 <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="a00008.html#ac768b16e2c57bb8a8d028d17b8565543">Buffer::metadata</a>; <a name="l00044"></a>00044 <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="a00009.html#a5368f9afd999b677884f545801cfa754">BufferDefault::metadata</a>, <a name="l00045"></a>00045 *<a class="code" href="a00010.html#a32f9598c4f298d16ee5beb12fee145cc">BufferInfinite::metadata</a>, <a name="l00046"></a>00046 *<a class="code" href="a00012.html#a4f4c8e1d995ffbdf9491f6f6c07e82d0">BufferProcure::metadata</a>; <a name="l00047"></a>00047 <a name="l00048"></a>00048 <a name="l00049"></a><a class="code" href="a00008.html#adf5890327f565bc167993d7d9e497617">00049</a> <span class="keywordtype">int</span> <a class="code" href="a00008.html#adf5890327f565bc167993d7d9e497617">Buffer::initialize</a>() <a name="l00050"></a>00050 { <a name="l00051"></a>00051 <span class="comment">// Initialize the metadata</span> <a name="l00052"></a>00052 <a class="code" href="a00008.html#ac768b16e2c57bb8a8d028d17b8565543">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">"buffer"</span>, <span class="stringliteral">"buffers"</span>, <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">reader</a>, <a class="code" href="a00085.html#a1071369052edea444a06baa35d7e991e">writer</a>); <a name="l00053"></a>00053 <a name="l00054"></a>00054 <span class="comment">// Initialize the Python class</span> <a name="l00055"></a>00055 <span class="keywordflow">return</span> <a class="code" href="a00008.html#adf5890327f565bc167993d7d9e497617">FreppleCategory<Buffer>::initialize</a>(); <a name="l00056"></a>00056 } <a name="l00057"></a>00057 <a name="l00058"></a>00058 <a name="l00059"></a><a class="code" href="a00009.html#a8f21dee81176468fbb35b149c752d0d4">00059</a> <span class="keywordtype">int</span> <a class="code" href="a00009.html#a8f21dee81176468fbb35b149c752d0d4">BufferDefault::initialize</a>() <a name="l00060"></a>00060 { <a name="l00061"></a>00061 <span class="comment">// Initialize the metadata</span> <a name="l00062"></a>00062 <a class="code" href="a00009.html#a5368f9afd999b677884f545801cfa754">BufferDefault::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="l00063"></a>00063 <span class="stringliteral">"buffer"</span>, <a name="l00064"></a>00064 <span class="stringliteral">"buffer_default"</span>, <a name="l00065"></a>00065 Object::createString<BufferDefault>, <span class="keyword">true</span>); <a name="l00066"></a>00066 <a name="l00067"></a>00067 <span class="comment">// Initialize the Python class</span> <a name="l00068"></a>00068 <span class="keywordflow">return</span> <a class="code" href="a00009.html#a8f21dee81176468fbb35b149c752d0d4">FreppleClass<BufferDefault,Buffer>::initialize</a>(); <a name="l00069"></a>00069 } <a name="l00070"></a>00070 <a name="l00071"></a>00071 <a name="l00072"></a><a class="code" href="a00010.html#a1993c1e21efaaeff8d85231f1b2f7a8f">00072</a> <span class="keywordtype">int</span> <a class="code" href="a00010.html#a1993c1e21efaaeff8d85231f1b2f7a8f">BufferInfinite::initialize</a>() <a name="l00073"></a>00073 { <a name="l00074"></a>00074 <span class="comment">// Initialize the metadata</span> <a name="l00075"></a>00075 <a class="code" href="a00010.html#a32f9598c4f298d16ee5beb12fee145cc">BufferInfinite::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="l00076"></a>00076 <span class="stringliteral">"buffer"</span>, <a name="l00077"></a>00077 <span class="stringliteral">"buffer_infinite"</span>, <a name="l00078"></a>00078 Object::createString<BufferInfinite>); <a name="l00079"></a>00079 <a name="l00080"></a>00080 <span class="comment">// Initialize the Python class</span> <a name="l00081"></a>00081 <span class="keywordflow">return</span> <a class="code" href="a00010.html#a1993c1e21efaaeff8d85231f1b2f7a8f">FreppleClass<BufferInfinite,Buffer>::initialize</a>(); <a name="l00082"></a>00082 } <a name="l00083"></a>00083 <a name="l00084"></a>00084 <a name="l00085"></a><a class="code" href="a00012.html#a51e004c371fa0c0d50077248cf1b69e2">00085</a> <span class="keywordtype">int</span> <a class="code" href="a00012.html#a51e004c371fa0c0d50077248cf1b69e2">BufferProcure::initialize</a>() <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <span class="comment">// Initialize the metadata</span> <a name="l00088"></a>00088 <a class="code" href="a00012.html#a4f4c8e1d995ffbdf9491f6f6c07e82d0">BufferProcure::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="l00089"></a>00089 <span class="stringliteral">"buffer"</span>, <a name="l00090"></a>00090 <span class="stringliteral">"buffer_procure"</span>, <a name="l00091"></a>00091 Object::createString<BufferProcure>); <a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="comment">// Initialize the Python class</span> <a name="l00094"></a>00094 <span class="keywordflow">return</span> <a class="code" href="a00012.html#a51e004c371fa0c0d50077248cf1b69e2">FreppleClass<BufferProcure,Buffer>::initialize</a>(); <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a name="l00097"></a>00097 <a name="l00098"></a><a class="code" href="a00008.html#aaceb978ee33141c9599ef9448819a5aa">00098</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#aaceb978ee33141c9599ef9448819a5aa">Buffer::setOnHand</a>(<span class="keywordtype">double</span> f) <a name="l00099"></a>00099 { <a name="l00100"></a>00100 <span class="comment">// The dummy operation to model the inventory may need to be created</span> <a name="l00101"></a>00101 <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a> *o = <a class="code" href="a00085.html#aad19dfc63a16f3fb30f7bda2e00f3cdc">Operation::find</a>(<a class="code" href="a00194.html#afa170ae27e19952a526c676b0ed2a099">INVENTORY_OPERATION</a>); <a name="l00102"></a>00102 <a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a> *fl; <a name="l00103"></a>00103 <span class="keywordflow">if</span> (!o) <a name="l00104"></a>00104 { <a name="l00105"></a>00105 <span class="comment">// Create a fixed time operation with zero leadtime, hidden from the xml</span> <a name="l00106"></a>00106 <span class="comment">// output, hidden for the solver, and without problem detection.</span> <a name="l00107"></a>00107 o = <span class="keyword">new</span> <a class="code" href="a00123.html" title="Models an operation that takes a fixed amount of time, independent of the quantity...">OperationFixedTime</a>(<a class="code" href="a00194.html#afa170ae27e19952a526c676b0ed2a099">INVENTORY_OPERATION</a>); <a name="l00108"></a>00108 <a class="code" href="a00085.html#a63b0e8c75aecc6fde9f4053ece52fde0">Operation::add</a>(o); <span class="comment">// No need to check again for existance</span> <a name="l00109"></a>00109 o-><a class="code" href="a00121.html#a5ad84f4daa4e5f5d018ba46c8896a585">setHidden</a>(<span class="keyword">true</span>); <a name="l00110"></a>00110 o-><a class="code" href="a00133.html#a1bd0cabdb794a96725c03c2a74aa3662">setDetectProblems</a>(<span class="keyword">false</span>); <a name="l00111"></a>00111 fl = <span class="keyword">new</span> <a class="code" href="a00066.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">FlowEnd</a>(o, <span class="keyword">this</span>, 1); <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <span class="keywordflow">else</span> <a name="l00114"></a>00114 <span class="comment">// Find the flow of this operation</span> <a name="l00115"></a>00115 fl = <span class="keyword">const_cast<</span><a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a>*<span class="keyword">></span>(&*(o-><a class="code" href="a00121.html#ac6b2f299c5939e2c61b2724ac58a2326">getFlows</a>().<a class="code" href="a00102.html#aff9c9d538c22eea35428266887b4d83c">begin</a>())); <a name="l00116"></a>00116 <a name="l00117"></a>00117 <span class="comment">// Check valid pointers</span> <a name="l00118"></a>00118 <span class="keywordflow">if</span> (!fl || !o) <a name="l00119"></a>00119 <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">"Failed creating inventory operation for '"</span> <a name="l00120"></a>00120 + <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"'"</span>); <a name="l00121"></a>00121 <a name="l00122"></a>00122 <span class="comment">// Make sure the sign of the flow is correct: +1 or -1.</span> <a name="l00123"></a>00123 fl-><a class="code" href="a00065.html#a96f7a635f0f33ff70455c4eabb7b3c19">setQuantity</a>(f>=0.0 ? 1.0 : -1.0); <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="comment">// Create a dummy operationplan on the inventory operation</span> <a name="l00126"></a>00126 <a class="code" href="a00093.html" title="This class models an STL-like iterator that allows us to iterate over the operationplans...">OperationPlan::iterator</a> i(o); <a name="l00127"></a>00127 <span class="keywordflow">if</span> (i == <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>()) <a name="l00128"></a>00128 { <a name="l00129"></a>00129 <span class="comment">// No operationplan exists yet</span> <a name="l00130"></a>00130 <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a> *opplan = o-><a class="code" href="a00121.html#ad183a2e72b75cdd83f9e71f6bc235424">createOperationPlan</a>( <a name="l00131"></a>00131 fabs(f), Date::infinitePast, Date::infinitePast); <a name="l00132"></a>00132 opplan-><a class="code" href="a00125.html#ad845e28c8e3a41fb08bfd7d47ff81e3a">setLocked</a>(<span class="keyword">true</span>); <a name="l00133"></a>00133 <span class="comment">// Note that we use the max counter for the onhand operationplans.</span> <a name="l00134"></a>00134 opplan-><a class="code" href="a00125.html#a13fe13cfa3f0b8dc229b9f115172c9c5">instantiate</a>(<span class="keyword">false</span>); <a name="l00135"></a>00135 } <a name="l00136"></a>00136 <span class="keywordflow">else</span> <a name="l00137"></a>00137 { <a name="l00138"></a>00138 <span class="comment">// Update the existing operationplan</span> <a name="l00139"></a>00139 i->setLocked(<span class="keyword">false</span>); <a name="l00140"></a>00140 i->setQuantity(fabs(f)); <a name="l00141"></a>00141 i->setLocked(<span class="keyword">true</span>); <a name="l00142"></a>00142 } <a name="l00143"></a>00143 <a class="code" href="a00133.html#a11a86a6e020664a337325a96a64f6d2c">setChanged</a>(); <a name="l00144"></a>00144 } <a name="l00145"></a>00145 <a name="l00146"></a>00146 <a name="l00147"></a><a class="code" href="a00008.html#a7b14e45b2fa323722171eeee20fe68cb">00147</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">double</span> <a class="code" href="a00008.html#a7b14e45b2fa323722171eeee20fe68cb">Buffer::getOnHand</a>(<a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> d)<span class="keyword"> const</span> <a name="l00148"></a>00148 <span class="keyword"></span>{ <a name="l00149"></a>00149 <span class="keywordtype">double</span> tmp(0.0); <a name="l00150"></a>00150 <span class="keywordflow">for</span> (flowplanlist::const_iterator oo=flowplans.<a class="code" href="a00178.html#ad6fe958ddd6a9a63662a40079d777a2f">begin</a>(); <a name="l00151"></a>00151 oo!=flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>(); ++oo) <a name="l00152"></a>00152 { <a name="l00153"></a>00153 <span class="keywordflow">if</span> (oo->getDate() > d) <a name="l00154"></a>00154 <span class="comment">// Found a flowplan with a later date.</span> <a name="l00155"></a>00155 <span class="comment">// Return the onhand after the previous flowplan.</span> <a name="l00156"></a>00156 <span class="keywordflow">return</span> tmp; <a name="l00157"></a>00157 tmp = oo->getOnhand(); <a name="l00158"></a>00158 } <a name="l00159"></a>00159 <span class="comment">// Found no flowplan: either we have specified a date later than the</span> <a name="l00160"></a>00160 <span class="comment">// last flowplan, either there are no flowplans at all.</span> <a name="l00161"></a>00161 <span class="keywordflow">return</span> tmp; <a name="l00162"></a>00162 } <a name="l00163"></a>00163 <a name="l00164"></a>00164 <a name="l00165"></a><a class="code" href="a00008.html#a80c519a7a05577fee5fe63ef6bacf372">00165</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">double</span> <a class="code" href="a00008.html#a7b14e45b2fa323722171eeee20fe68cb">Buffer::getOnHand</a>(<a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> d1, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> d2, <span class="keywordtype">bool</span> min)<span class="keyword"> const</span> <a name="l00166"></a>00166 <span class="keyword"></span>{ <a name="l00167"></a>00167 <span class="comment">// Swap parameters if required</span> <a name="l00168"></a>00168 <span class="keywordflow">if</span> (d2 < d1) <a name="l00169"></a>00169 { <a name="l00170"></a>00170 <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> x(d1); <a name="l00171"></a>00171 d2 = d1; <a name="l00172"></a>00172 d2 = x; <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <a name="l00175"></a>00175 <span class="comment">// Loop through all flowplans</span> <a name="l00176"></a>00176 <span class="keywordtype">double</span> tmp(0.0), record(0.0); <a name="l00177"></a>00177 <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> d, prev_Date; <a name="l00178"></a>00178 <span class="keywordflow">for</span> (flowplanlist::const_iterator oo=flowplans.<a class="code" href="a00178.html#ad6fe958ddd6a9a63662a40079d777a2f">begin</a>(); <span class="keyword">true</span>; ++oo) <a name="l00179"></a>00179 { <a name="l00180"></a>00180 <span class="keywordflow">if</span> (oo==flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>() || oo->getDate() > d) <a name="l00181"></a>00181 { <a name="l00182"></a>00182 <span class="comment">// Date has now changed or we have arrived at the end</span> <a name="l00183"></a>00183 <a name="l00184"></a>00184 <span class="comment">// New max?</span> <a name="l00185"></a>00185 <span class="keywordflow">if</span> (prev_Date < d1) <a name="l00186"></a>00186 <span class="comment">// Not in active Date range: we simply follow the onhand profile</span> <a name="l00187"></a>00187 record = tmp; <a name="l00188"></a>00188 <span class="keywordflow">else</span> <a name="l00189"></a>00189 { <a name="l00190"></a>00190 <span class="comment">// In the active range</span> <a name="l00191"></a>00191 <span class="comment">// New extreme?</span> <a name="l00192"></a>00192 <span class="keywordflow">if</span> (min) {<span class="keywordflow">if</span> (tmp < record) record = tmp;} <a name="l00193"></a>00193 <span class="keywordflow">else</span> {<span class="keywordflow">if</span> (tmp > record) record = tmp;} <a name="l00194"></a>00194 } <a name="l00195"></a>00195 <a name="l00196"></a>00196 <span class="comment">// Are we done now?</span> <a name="l00197"></a>00197 <span class="keywordflow">if</span> (prev_Date > d2 || oo==flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>()) <span class="keywordflow">return</span> record; <a name="l00198"></a>00198 <a name="l00199"></a>00199 <span class="comment">// Set the variable with the new Date</span> <a name="l00200"></a>00200 d = oo->getDate(); <a name="l00201"></a>00201 } <a name="l00202"></a>00202 tmp = oo->getOnhand(); <a name="l00203"></a>00203 prev_Date = oo->getDate(); <a name="l00204"></a>00204 } <a name="l00205"></a>00205 <span class="comment">// The above for-loop controls the exit. This line of code is never reached.</span> <a name="l00206"></a>00206 <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">"Unreachable code reached"</span>); <a name="l00207"></a>00207 } <a name="l00208"></a>00208 <a name="l00209"></a>00209 <a name="l00210"></a><a class="code" href="a00008.html#a8e72becff5b6b068ce2cd9e008902209">00210</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#a8e72becff5b6b068ce2cd9e008902209">Buffer::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> &tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m)<span class="keyword"> const</span> <a name="l00211"></a>00211 <span class="keyword"></span>{ <a name="l00212"></a>00212 <span class="comment">// Writing a reference</span> <a name="l00213"></a>00213 <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>) <a name="l00214"></a>00214 { <a name="l00215"></a>00215 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(tag, <a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>()); <a name="l00216"></a>00216 <span class="keywordflow">return</span>; <a name="l00217"></a>00217 } <a name="l00218"></a>00218 <a name="l00219"></a>00219 <span class="comment">// Write the complete object</span> <a name="l00220"></a>00220 <span class="keywordflow">if</span> (m!= <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-><a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(tag, <a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>()); <a name="l00221"></a>00221 <a name="l00222"></a>00222 <span class="comment">// Write own fields</span> <a name="l00223"></a>00223 <a class="code" href="a00008.html#a8e72becff5b6b068ce2cd9e008902209">HasDescription::writeElement</a>(o, tag); <a name="l00224"></a>00224 <a class="code" href="a00008.html#a8e72becff5b6b068ce2cd9e008902209">HasHierarchy<Buffer>::writeElement</a>(o, tag); <a name="l00225"></a>00225 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a419541bdc90e7a049a3d9bd9a1e6615f">Tags::tag_producing</a>, producing_operation); <a name="l00226"></a>00226 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a9503f5b5b382603919b72bf295c6bb95">Tags::tag_item</a>, it); <a name="l00227"></a>00227 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a3355294c37c4e6cd3a72a17115567071">Tags::tag_location</a>, loc); <a name="l00228"></a>00228 <a class="code" href="a00008.html#a8e72becff5b6b068ce2cd9e008902209">Plannable::writeElement</a>(o, tag); <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="comment">// Onhand</span> <a name="l00231"></a>00231 flowplanlist::const_iterator i = flowplans.<a class="code" href="a00178.html#ad6fe958ddd6a9a63662a40079d777a2f">begin</a>(); <a name="l00232"></a>00232 <span class="comment">// Loop through the flowplans at the start of the horizon</span> <a name="l00233"></a>00233 <span class="keywordflow">for</span> (; i!=flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>() && i->getType()!=1 && !i->getDate(); ++i) ; <a name="l00234"></a>00234 <span class="keywordflow">if</span> (i!=flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>() && i->getType()==1) <a name="l00235"></a>00235 { <a name="l00236"></a>00236 <span class="comment">// A flowplan has been found</span> <a name="l00237"></a>00237 <span class="keyword">const</span> <a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a> *fp = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>*<span class="keyword">></span>(&*i); <a name="l00238"></a>00238 <span class="keywordflow">if</span> (fp <a name="l00239"></a>00239 && fp-><a class="code" href="a00068.html#afad8d8ad9e551d7abb012bf1383b18c8">getFlow</a>()-><a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() == string(<a class="code" href="a00194.html#afa170ae27e19952a526c676b0ed2a099">INVENTORY_OPERATION</a>) <a name="l00240"></a>00240 && fabs(fp-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>()) > <a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a>) <a name="l00241"></a>00241 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a94ff585d707284cf4d69287f4ea4a9ba">Tags::tag_onhand</a>, fp-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>()); <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <a name="l00244"></a>00244 <span class="comment">// Minimum and maximum inventory targets, carrying cost</span> <a name="l00245"></a>00245 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ac361ec1b9a7c26e74fbc4c21acb99049">Tags::tag_minimum</a>, min_cal); <a name="l00246"></a>00246 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a608a97000f23fdec1baec4504d095b24">Tags::tag_maximum</a>, max_cal); <a name="l00247"></a>00247 <span class="keywordflow">if</span> (<a class="code" href="a00008.html#adba7cdfff779fb56225d9601ad664eed">getCarryingCost</a>()!= 0.0) <a name="l00248"></a>00248 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a6709bcf02b8e43b4784877c04c551e07">Tags::tag_carrying_cost</a>, <a class="code" href="a00008.html#adba7cdfff779fb56225d9601ad664eed">getCarryingCost</a>()); <a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="comment">// Write extra plan information</span> <a name="l00251"></a>00251 i = flowplans.<a class="code" href="a00178.html#ad6fe958ddd6a9a63662a40079d777a2f">begin</a>(); <a name="l00252"></a>00252 <span class="keywordflow">if</span> ((o-><a class="code" href="a00189.html#a364e86ed0671915df858bc52adadd29f">getContentType</a>() == XMLOutput::PLAN <a name="l00253"></a>00253 || o-><a class="code" href="a00189.html#a364e86ed0671915df858bc52adadd29f">getContentType</a>() == XMLOutput::PLANDETAIL) && i!=flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>()) <a name="l00254"></a>00254 { <a name="l00255"></a>00255 o-><a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(<a class="code" href="a00177.html#aeaa2557f88702842d0f9fc54fd97fccc">Tags::tag_flowplans</a>); <a name="l00256"></a>00256 <span class="keywordflow">for</span> (; i!=flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>(); ++i) <a name="l00257"></a>00257 <span class="keywordflow">if</span> (i->getType()==1) <a name="l00258"></a>00258 dynamic_cast<const FlowPlan*>(&*i)->writeElement(o, <a class="code" href="a00177.html#acf5f50deeeea86273b84a1f593626514">Tags::tag_flowplan</a>); <a name="l00259"></a>00259 o-><a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(<a class="code" href="a00177.html#aeaa2557f88702842d0f9fc54fd97fccc">Tags::tag_flowplans</a>); <a name="l00260"></a>00260 } <a name="l00261"></a>00261 <a name="l00262"></a>00262 <span class="comment">// Ending tag</span> <a name="l00263"></a>00263 o-><a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag); <a name="l00264"></a>00264 } <a name="l00265"></a>00265 <a name="l00266"></a>00266 <a name="l00267"></a><a class="code" href="a00008.html#a140c1480d858f20fad672408f9e1a452">00267</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#a140c1480d858f20fad672408f9e1a452">Buffer::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>& pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& pAttr) <a name="l00268"></a>00268 { <a name="l00269"></a>00269 <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a2b7f55f8d34c873afe442d0eca79c122">Tags::tag_flow</a>) <a name="l00270"></a>00270 && pIn.<a class="code" href="a00186.html#a407522e9d0dde7f7eebfafe182d050cf">getParentElement</a>().first.isA(<a class="code" href="a00177.html#a945bcc90195696e5059467e3e7e78cce">Tags::tag_flows</a>)) <a name="l00271"></a>00271 { <a name="l00272"></a>00272 <a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a> *f = <a name="l00273"></a>00273 <span class="keyword">dynamic_cast<</span><a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a>*<span class="keyword">></span>(MetaCategory::ControllerDefault(<a class="code" href="a00065.html#a57cd1a48af0ab914b78bb411711c447a">Flow::metadata</a>,pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>())); <a name="l00274"></a>00274 <span class="keywordflow">if</span> (f) f-><a class="code" href="a00065.html#a40617c135538c6efd90cd515d7026032">setBuffer</a>(<span class="keyword">this</span>); <a name="l00275"></a>00275 pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a> (f); <a name="l00276"></a>00276 } <a name="l00277"></a>00277 <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#a419541bdc90e7a049a3d9bd9a1e6615f">Tags::tag_producing</a>)) <a name="l00278"></a>00278 pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>( <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">Operation::reader</a>(<a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>,pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()) ); <a name="l00279"></a>00279 <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#a9503f5b5b382603919b72bf295c6bb95">Tags::tag_item</a>)) <a name="l00280"></a>00280 pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>( <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">Item::reader</a>(<a class="code" href="a00088.html#add18088c74a5522fc93a577922239e0a">Item::metadata</a>,pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()) ); <a name="l00281"></a>00281 <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#ac361ec1b9a7c26e74fbc4c21acb99049">Tags::tag_minimum</a>) || pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a608a97000f23fdec1baec4504d095b24">Tags::tag_maximum</a>)) <a name="l00282"></a>00282 pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>( <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">Calendar::reader</a>(<a class="code" href="a00013.html#a80be0bca89b0fd95ed0dfefa2f965a6f">Calendar::metadata</a>,pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()) ); <a name="l00283"></a>00283 <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#a3355294c37c4e6cd3a72a17115567071">Tags::tag_location</a>)) <a name="l00284"></a>00284 pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>( <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">Location::reader</a>(<a class="code" href="a00108.html#a92b7d2941cf8330f08acd95992dc89ad">Location::metadata</a>,pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()) ); <a name="l00285"></a>00285 <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#aeaa2557f88702842d0f9fc54fd97fccc">Tags::tag_flowplans</a>)) <a name="l00286"></a>00286 pIn.<a class="code" href="a00186.html#af1ffc5c65dd968dcb04a23e05a0da5ba">IgnoreElement</a>(); <a name="l00287"></a>00287 <span class="keywordflow">else</span> <a name="l00288"></a>00288 <a class="code" href="a00008.html#a140c1480d858f20fad672408f9e1a452">HasHierarchy<Buffer>::beginElement</a>(pIn, pAttr); <a name="l00289"></a>00289 } <a name="l00290"></a>00290 <a name="l00291"></a>00291 <a name="l00292"></a><a class="code" href="a00008.html#a561782e0a5a6fb84c62209aba172a241">00292</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#a561782e0a5a6fb84c62209aba172a241">Buffer::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>& pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& 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>& pElement) <a name="l00293"></a>00293 { <a name="l00294"></a>00294 <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a419541bdc90e7a049a3d9bd9a1e6615f">Tags::tag_producing</a>)) <a name="l00295"></a>00295 { <a name="l00296"></a>00296 <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a> *b = <span class="keyword">dynamic_cast<</span><a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00297"></a>00297 <span class="keywordflow">if</span> (b) <a class="code" href="a00008.html#a4b3fe4aa484216fb7eb9941d6ad069c9">setProducingOperation</a>(b); <a name="l00298"></a>00298 <span class="keywordflow">else</span> <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">"Incorrect object type during read operation"</span>); <a name="l00299"></a>00299 } <a name="l00300"></a>00300 <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#a9503f5b5b382603919b72bf295c6bb95">Tags::tag_item</a>)) <a name="l00301"></a>00301 { <a name="l00302"></a>00302 <a class="code" href="a00088.html" title="An item defines the products being planned, sold, stored and/or manufactured. Buffers...">Item</a> *a = <span class="keyword">dynamic_cast<</span><a class="code" href="a00088.html" title="An item defines the products being planned, sold, stored and/or manufactured. Buffers...">Item</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00303"></a>00303 <span class="keywordflow">if</span> (a) <a class="code" href="a00008.html#a32bd53e8441100b2d4a9b45f782114aa">setItem</a>(a); <a name="l00304"></a>00304 <span class="keywordflow">else</span> <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">"Incorrect object type during read operation"</span>); <a name="l00305"></a>00305 } <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#a94ff585d707284cf4d69287f4ea4a9ba">Tags::tag_onhand</a>)) <a name="l00307"></a>00307 <a class="code" href="a00008.html#aaceb978ee33141c9599ef9448819a5aa">setOnHand</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</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#ac361ec1b9a7c26e74fbc4c21acb99049">Tags::tag_minimum</a>)) <a name="l00309"></a>00309 { <a name="l00310"></a>00310 <a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a> *mincal = <a name="l00311"></a>00311 <span class="keyword">dynamic_cast<</span><a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00312"></a>00312 <span class="keywordflow">if</span> (mincal) <a name="l00313"></a>00313 <a class="code" href="a00008.html#a320d4eaa96145dda150d4c2cc4698cdd">setMinimum</a>(mincal); <a name="l00314"></a>00314 <span class="keywordflow">else</span> <a name="l00315"></a>00315 { <a name="l00316"></a>00316 <a class="code" href="a00013.html" title="This is the class used to represent variables that are varying over time.">Calendar</a> *c = <span class="keyword">dynamic_cast<</span><a class="code" href="a00013.html" title="This is the class used to represent variables that are varying over time.">Calendar</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00317"></a>00317 <span class="keywordflow">if</span> (!c) <a name="l00318"></a>00318 <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">"Incorrect object type during read operation"</span>); <a name="l00319"></a>00319 <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">"Calendar '"</span> + c-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <a name="l00320"></a>00320 <span class="stringliteral">"' has invalid type for use as buffer min calendar"</span>); <a name="l00321"></a>00321 } <a name="l00322"></a>00322 } <a name="l00323"></a>00323 <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#a608a97000f23fdec1baec4504d095b24">Tags::tag_maximum</a>)) <a name="l00324"></a>00324 { <a name="l00325"></a>00325 <a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a> *maxcal = <a name="l00326"></a>00326 <span class="keyword">dynamic_cast<</span><a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00327"></a>00327 <span class="keywordflow">if</span> (maxcal) <a name="l00328"></a>00328 <a class="code" href="a00008.html#a917f1bca74a654f228eee0b1e2c8763d">setMaximum</a>(maxcal); <a name="l00329"></a>00329 <span class="keywordflow">else</span> <a name="l00330"></a>00330 { <a name="l00331"></a>00331 <a class="code" href="a00013.html" title="This is the class used to represent variables that are varying over time.">Calendar</a> *c = <span class="keyword">dynamic_cast<</span><a class="code" href="a00013.html" title="This is the class used to represent variables that are varying over time.">Calendar</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00332"></a>00332 <span class="keywordflow">if</span> (!c) <a name="l00333"></a>00333 <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">"Incorrect object type during read operation"</span>); <a name="l00334"></a>00334 <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">"Calendar '"</span> + c-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <a name="l00335"></a>00335 <span class="stringliteral">"' has invalid type for use as buffer max calendar"</span>); <a name="l00336"></a>00336 } <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <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#a3355294c37c4e6cd3a72a17115567071">Tags::tag_location</a>)) <a name="l00339"></a>00339 { <a name="l00340"></a>00340 <a class="code" href="a00108.html" title="This abstract class is used to associate buffers and resources with a physical or...">Location</a> * d = <span class="keyword">dynamic_cast<</span><a class="code" href="a00108.html" title="This abstract class is used to associate buffers and resources with a physical or...">Location</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00341"></a>00341 <span class="keywordflow">if</span> (d) <a class="code" href="a00008.html#a18888ecb9681edd3b16d93ae6c8356cd">setLocation</a>(d); <a name="l00342"></a>00342 <span class="keywordflow">else</span> <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">"Incorrect object type during read operation"</span>); <a name="l00343"></a>00343 } <a name="l00344"></a>00344 <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#a6709bcf02b8e43b4784877c04c551e07">Tags::tag_carrying_cost</a>)) <a name="l00345"></a>00345 <a class="code" href="a00008.html#a7642211a5ba839ec3ad9515cee2dc091">setCarryingCost</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>()); <a name="l00346"></a>00346 <span class="keywordflow">else</span> <a name="l00347"></a>00347 { <a name="l00348"></a>00348 <a class="code" href="a00008.html#a561782e0a5a6fb84c62209aba172a241">Plannable::endElement</a>(pIn, pAttr, pElement); <a name="l00349"></a>00349 <a class="code" href="a00008.html#a561782e0a5a6fb84c62209aba172a241">HasDescription::endElement</a>(pIn, pAttr, pElement); <a name="l00350"></a>00350 <a class="code" href="a00008.html#a561782e0a5a6fb84c62209aba172a241">HasHierarchy<Buffer>::endElement</a>(pIn, pAttr, pElement); <a name="l00351"></a>00351 } <a name="l00352"></a>00352 } <a name="l00353"></a>00353 <a name="l00354"></a>00354 <a name="l00355"></a><a class="code" href="a00008.html#a320d4eaa96145dda150d4c2cc4698cdd">00355</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#a320d4eaa96145dda150d4c2cc4698cdd">Buffer::setMinimum</a>(<a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a> *cal) <a name="l00356"></a>00356 { <a name="l00357"></a>00357 <span class="comment">// Resetting the same calendar</span> <a name="l00358"></a>00358 <span class="keywordflow">if</span> (min_cal == cal) <span class="keywordflow">return</span>; <a name="l00359"></a>00359 <a name="l00360"></a>00360 <span class="comment">// Mark as changed</span> <a name="l00361"></a>00361 <a class="code" href="a00133.html#a11a86a6e020664a337325a96a64f6d2c">setChanged</a>(); <a name="l00362"></a>00362 <a name="l00363"></a>00363 <span class="comment">// Calendar is already set: delete previous events.</span> <a name="l00364"></a>00364 <span class="keywordflow">if</span> (min_cal) <a name="l00365"></a>00365 { <a name="l00366"></a>00366 <span class="keywordflow">for</span> (flowplanlist::iterator oo=flowplans.<a class="code" href="a00178.html#ad6fe958ddd6a9a63662a40079d777a2f">begin</a>(); oo!=flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>(); ) <a name="l00367"></a>00367 <span class="keywordflow">if</span> (oo->getType() == 3) <a name="l00368"></a>00368 { <a name="l00369"></a>00369 flowplans.<a class="code" href="a00178.html#a8b48bf8187fd711ae67dcdd8e35c554f">erase</a>(&(*oo)); <a name="l00370"></a>00370 <span class="keyword">delete</span> &(*(oo++)); <a name="l00371"></a>00371 } <a name="l00372"></a>00372 <span class="keywordflow">else</span> ++oo; <a name="l00373"></a>00373 } <a name="l00374"></a>00374 <a name="l00375"></a>00375 <span class="comment">// Null pointer passed</span> <a name="l00376"></a>00376 <span class="keywordflow">if</span> (!cal) <span class="keywordflow">return</span>; <a name="l00377"></a>00377 <a name="l00378"></a>00378 <span class="comment">// Create timeline structures for every event. A new entry is created only</span> <a name="l00379"></a>00379 <span class="comment">// when the value changes.</span> <a name="l00380"></a>00380 min_cal = <span class="keyword">const_cast<</span> <a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>* <span class="keyword">></span>(cal); <a name="l00381"></a>00381 <span class="keywordtype">double</span> curMin = 0.0; <a name="l00382"></a>00382 <span class="keywordflow">for</span> (<a class="code" href="a00061.html" title="An iterator class to go through all dates where the calendar value changes.">CalendarDouble::EventIterator</a> x(min_cal); x.getDate()<Date::infiniteFuture; ++x) <a name="l00383"></a>00383 <span class="keywordflow">if</span> (curMin != x.getValue()) <a name="l00384"></a>00384 { <a name="l00385"></a>00385 curMin = x.<a class="code" href="a00023.html#a269067e065a9ca2a62be6cbfcf489fa1">getValue</a>(); <a name="l00386"></a>00386 flowplanlist::EventMinQuantity *newBucket = <a name="l00387"></a>00387 <span class="keyword">new</span> flowplanlist::EventMinQuantity(x.getDate(), curMin); <a name="l00388"></a>00388 flowplans.<a class="code" href="a00178.html#a8f2260de9aaf8f821d2ad3d097cf2a34">insert</a>(newBucket); <a name="l00389"></a>00389 } <a name="l00390"></a>00390 } <a name="l00391"></a>00391 <a name="l00392"></a>00392 <a name="l00393"></a><a class="code" href="a00008.html#a917f1bca74a654f228eee0b1e2c8763d">00393</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#a917f1bca74a654f228eee0b1e2c8763d">Buffer::setMaximum</a>(<a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a> *cal) <a name="l00394"></a>00394 { <a name="l00395"></a>00395 <span class="comment">// Resetting the same calendar</span> <a name="l00396"></a>00396 <span class="keywordflow">if</span> (max_cal == cal) <span class="keywordflow">return</span>; <a name="l00397"></a>00397 <a name="l00398"></a>00398 <span class="comment">// Mark as changed</span> <a name="l00399"></a>00399 <a class="code" href="a00133.html#a11a86a6e020664a337325a96a64f6d2c">setChanged</a>(); <a name="l00400"></a>00400 <a name="l00401"></a>00401 <span class="comment">// Calendar is already set: delete previous events.</span> <a name="l00402"></a>00402 <span class="keywordflow">if</span> (max_cal) <a name="l00403"></a>00403 { <a name="l00404"></a>00404 <span class="keywordflow">for</span> (flowplanlist::iterator oo=flowplans.<a class="code" href="a00178.html#ad6fe958ddd6a9a63662a40079d777a2f">begin</a>(); oo!=flowplans.<a class="code" href="a00178.html#a247a6dfded3b61f1aeb838719ac295bc">end</a>(); ) <a name="l00405"></a>00405 <span class="keywordflow">if</span> (oo->getType() == 4) <a name="l00406"></a>00406 { <a name="l00407"></a>00407 flowplans.<a class="code" href="a00178.html#a8b48bf8187fd711ae67dcdd8e35c554f">erase</a>(&(*oo)); <a name="l00408"></a>00408 <span class="keyword">delete</span> &(*(oo++)); <a name="l00409"></a>00409 } <a name="l00410"></a>00410 <span class="keywordflow">else</span> ++oo; <a name="l00411"></a>00411 } <a name="l00412"></a>00412 <a name="l00413"></a>00413 <span class="comment">// Null pointer passed</span> <a name="l00414"></a>00414 <span class="keywordflow">if</span> (!cal) <span class="keywordflow">return</span>; <a name="l00415"></a>00415 <a name="l00416"></a>00416 <span class="comment">// Create timeline structures for every bucket. A new entry is created only</span> <a name="l00417"></a>00417 <span class="comment">// when the value changes.</span> <a name="l00418"></a>00418 max_cal = <span class="keyword">const_cast<</span><a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>*<span class="keyword">></span>(cal); <a name="l00419"></a>00419 <span class="keywordtype">double</span> curMax = 0.0; <a name="l00420"></a>00420 <span class="keywordflow">for</span> (<a class="code" href="a00061.html" title="An iterator class to go through all dates where the calendar value changes.">CalendarDouble::EventIterator</a> x(min_cal); x.getDate()<Date::infiniteFuture; ++x) <a name="l00421"></a>00421 <span class="keywordflow">if</span> (curMax != x.getValue()) <a name="l00422"></a>00422 { <a name="l00423"></a>00423 curMax = x.<a class="code" href="a00023.html#a269067e065a9ca2a62be6cbfcf489fa1">getValue</a>(); <a name="l00424"></a>00424 flowplanlist::EventMaxQuantity *newBucket = <a name="l00425"></a>00425 <span class="keyword">new</span> flowplanlist::EventMaxQuantity(x.getDate(), curMax); <a name="l00426"></a>00426 flowplans.<a class="code" href="a00178.html#a8f2260de9aaf8f821d2ad3d097cf2a34">insert</a>(newBucket); <a name="l00427"></a>00427 } <a name="l00428"></a>00428 } <a name="l00429"></a>00429 <a name="l00430"></a>00430 <a name="l00431"></a><a class="code" href="a00008.html#aaa1d3fd54d065f5d3bb240285bf2eedd">00431</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#aaa1d3fd54d065f5d3bb240285bf2eedd">Buffer::deleteOperationPlans</a>(<span class="keywordtype">bool</span> deleteLocked) <a name="l00432"></a>00432 { <a name="l00433"></a>00433 <span class="comment">// Delete the operationplans</span> <a name="l00434"></a>00434 <span class="keywordflow">for</span> (<a class="code" href="a00092.html" title="An iterator over the associated objects.">flowlist::iterator</a> i=flows.<a class="code" href="a00102.html#aff9c9d538c22eea35428266887b4d83c">begin</a>(); i!=flows.<a class="code" href="a00102.html#a2752a29487a58a9d970ae02e8f21955d">end</a>(); ++i) <a name="l00435"></a>00435 <a class="code" href="a00125.html#aebe0ba79364fcd6952413913a0bc5a92">OperationPlan::deleteOperationPlans</a>(i->getOperation(),deleteLocked); <a name="l00436"></a>00436 <a name="l00437"></a>00437 <span class="comment">// Mark to recompute the problems</span> <a name="l00438"></a>00438 <a class="code" href="a00133.html#a11a86a6e020664a337325a96a64f6d2c">setChanged</a>(); <a name="l00439"></a>00439 } <a name="l00440"></a>00440 <a name="l00441"></a>00441 <a name="l00442"></a><a class="code" href="a00008.html#a6f4e38fcae8f28b5d3664499928e187e">00442</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00008.html#a6f4e38fcae8f28b5d3664499928e187e">Buffer::~Buffer</a>() <a name="l00443"></a>00443 { <a name="l00444"></a>00444 <span class="comment">// Delete all operationplans.</span> <a name="l00445"></a>00445 <span class="comment">// An alternative logic would be to delete only the flowplans for this</span> <a name="l00446"></a>00446 <span class="comment">// buffer and leave the rest of the plan untouched. The currently</span> <a name="l00447"></a>00447 <span class="comment">// implemented method is way more drastic...</span> <a name="l00448"></a>00448 <a class="code" href="a00008.html#aaa1d3fd54d065f5d3bb240285bf2eedd">deleteOperationPlans</a>(<span class="keyword">true</span>); <a name="l00449"></a>00449 <a name="l00450"></a>00450 <span class="comment">// The Flow objects are automatically deleted by the destructor of the</span> <a name="l00451"></a>00451 <span class="comment">// Association list class.</span> <a name="l00452"></a>00452 <a name="l00453"></a>00453 <span class="comment">// Remove the inventory operation</span> <a name="l00454"></a>00454 <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a> *invoper = <a class="code" href="a00085.html#aad19dfc63a16f3fb30f7bda2e00f3cdc">Operation::find</a>(<a class="code" href="a00194.html#afa170ae27e19952a526c676b0ed2a099">INVENTORY_OPERATION</a>); <a name="l00455"></a>00455 <span class="keywordflow">if</span> (invoper) <span class="keyword">delete</span> invoper; <a name="l00456"></a>00456 } <a name="l00457"></a>00457 <a name="l00458"></a>00458 <a name="l00459"></a>00459 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00008.html#ac308afe477503d28feaa3344e519a910">Buffer::followPegging</a> <a name="l00460"></a><a class="code" href="a00008.html#ac308afe477503d28feaa3344e519a910">00460</a> (<a class="code" href="a00131.html" title="This class allows upstream and downstream navigation through the plan.">PeggingIterator</a>& iter, <a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>* curflowplan, <span class="keywordtype">short</span> nextlevel, <span class="keywordtype">double</span> curqty, <span class="keywordtype">double</span> curfactor) <a name="l00461"></a>00461 { <a name="l00462"></a>00462 <a name="l00463"></a>00463 <span class="keywordtype">double</span> peggedQty(0); <a name="l00464"></a>00464 Buffer::flowplanlist::const_iterator f = getFlowPlans().begin(curflowplan); <a name="l00465"></a>00465 <a name="l00466"></a>00466 <span class="keywordflow">if</span> (curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>() < -<a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a> && !iter.<a class="code" href="a00131.html#aac7a5bc00810ea3656d3463ad5aff140">isDownstream</a>()) <a name="l00467"></a>00467 { <a name="l00468"></a>00468 <span class="comment">// CASE 1:</span> <a name="l00469"></a>00469 <span class="comment">// This is a flowplan consuming from a buffer. Navigating upstream means</span> <a name="l00470"></a>00470 <span class="comment">// finding the flowplans producing this consumed material.</span> <a name="l00471"></a>00471 <span class="keywordtype">double</span> endQty = f->getCumulativeConsumed(); <a name="l00472"></a>00472 <span class="keywordtype">double</span> startQty = endQty + f->getQuantity(); <a name="l00473"></a>00473 <span class="keywordflow">if</span> (f->getCumulativeProduced() <= startQty) <a name="l00474"></a>00474 { <a name="l00475"></a>00475 <span class="comment">// CASE 1A: Not produced enough yet: move forward</span> <a name="l00476"></a>00476 <span class="keywordflow">while</span> (f!=getFlowPlans().end() <a name="l00477"></a>00477 && f->getCumulativeProduced() <= startQty) ++f; <a name="l00478"></a>00478 <span class="keywordflow">while</span> (f!=getFlowPlans().end() <a name="l00479"></a>00479 && ( (f->getQuantity()<=0 && f->getCumulativeProduced() < endQty) <a name="l00480"></a>00480 || (f->getQuantity()>0 <a name="l00481"></a>00481 && f->getCumulativeProduced()-f->getQuantity() < endQty)) <a name="l00482"></a>00482 ) <a name="l00483"></a>00483 { <a name="l00484"></a>00484 <span class="keywordflow">if</span> (f->getQuantity() > <a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a>) <a name="l00485"></a>00485 { <a name="l00486"></a>00486 <span class="keywordtype">double</span> newqty = f->getQuantity(); <a name="l00487"></a>00487 <span class="keywordflow">if</span> (f->getCumulativeProduced()-f->getQuantity() < startQty) <a name="l00488"></a>00488 newqty -= startQty - (f->getCumulativeProduced()-f->getQuantity()); <a name="l00489"></a>00489 <span class="keywordflow">if</span> (f->getCumulativeProduced() > endQty) <a name="l00490"></a>00490 newqty -= f->getCumulativeProduced() - endQty; <a name="l00491"></a>00491 peggedQty += newqty; <a name="l00492"></a>00492 <span class="keyword">const</span> <a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a> *x = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>*<span class="keyword">></span>(&(*f)); <a name="l00493"></a>00493 iter.<a class="code" href="a00131.html#ae54c20a1ee7a60ef6448f05207c11990">updateStack</a>(nextlevel, <a name="l00494"></a>00494 -curqty*newqty/curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(), <a name="l00495"></a>00495 curfactor*newqty/f->getQuantity(), <a name="l00496"></a>00496 curflowplan, x); <a name="l00497"></a>00497 } <a name="l00498"></a>00498 ++f; <a name="l00499"></a>00499 } <a name="l00500"></a>00500 } <a name="l00501"></a>00501 <span class="keywordflow">else</span> <a name="l00502"></a>00502 { <a name="l00503"></a>00503 <span class="comment">// CASE 1B: Produced too much already: move backward</span> <a name="l00504"></a>00504 <span class="keywordflow">while</span> ( f!=getFlowPlans().end() <a name="l00505"></a>00505 && ((f->getQuantity()<=0 && f->getCumulativeProduced() > endQty) <a name="l00506"></a>00506 || (f->getQuantity()>0 <a name="l00507"></a>00507 && f->getCumulativeProduced()-f->getQuantity() > endQty))) --f; <a name="l00508"></a>00508 <span class="keywordflow">while</span> (f!=getFlowPlans().end() && f->getCumulativeProduced() > startQty) <a name="l00509"></a>00509 { <a name="l00510"></a>00510 <span class="keywordflow">if</span> (f->getQuantity() > <a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a>) <a name="l00511"></a>00511 { <a name="l00512"></a>00512 <span class="keywordtype">double</span> newqty = f->getQuantity(); <a name="l00513"></a>00513 <span class="keywordflow">if</span> (f->getCumulativeProduced()-f->getQuantity() < startQty) <a name="l00514"></a>00514 newqty -= startQty - (f->getCumulativeProduced()-f->getQuantity()); <a name="l00515"></a>00515 <span class="keywordflow">if</span> (f->getCumulativeProduced() > endQty) <a name="l00516"></a>00516 newqty -= f->getCumulativeProduced() - endQty; <a name="l00517"></a>00517 peggedQty += newqty; <a name="l00518"></a>00518 <span class="keyword">const</span> <a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a> *x = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>*<span class="keyword">></span>(&(*f)); <a name="l00519"></a>00519 iter.<a class="code" href="a00131.html#ae54c20a1ee7a60ef6448f05207c11990">updateStack</a>(nextlevel, <a name="l00520"></a>00520 -curqty*newqty/curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(), <a name="l00521"></a>00521 curfactor*newqty/f->getQuantity(), <a name="l00522"></a>00522 curflowplan, x); <a name="l00523"></a>00523 } <a name="l00524"></a>00524 --f; <a name="l00525"></a>00525 } <a name="l00526"></a>00526 } <a name="l00527"></a>00527 <span class="keywordflow">if</span> (peggedQty < endQty - startQty - <a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a>) <a name="l00528"></a>00528 <span class="comment">// Unproduced material (i.e. material that is consumed but never</span> <a name="l00529"></a>00529 <span class="comment">// produced) is handled with a special entry on the stack.</span> <a name="l00530"></a>00530 iter.<a class="code" href="a00131.html#ae54c20a1ee7a60ef6448f05207c11990">updateStack</a>(nextlevel, <a name="l00531"></a>00531 curqty*(peggedQty - endQty + startQty)/curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(), <a name="l00532"></a>00532 curfactor, <a name="l00533"></a>00533 curflowplan, <a name="l00534"></a>00534 NULL, <a name="l00535"></a>00535 <span class="keyword">false</span>); <a name="l00536"></a>00536 <span class="keywordflow">return</span>; <a name="l00537"></a>00537 } <a name="l00538"></a>00538 <a name="l00539"></a>00539 <span class="keywordflow">if</span> (curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>() > <a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a> && iter.<a class="code" href="a00131.html#aac7a5bc00810ea3656d3463ad5aff140">isDownstream</a>()) <a name="l00540"></a>00540 { <a name="l00541"></a>00541 <span class="comment">// CASE 2:</span> <a name="l00542"></a>00542 <span class="comment">// This is a flowplan producing in a buffer. Navigating downstream means</span> <a name="l00543"></a>00543 <span class="comment">// finding the flowplans consuming this produced material.</span> <a name="l00544"></a>00544 <span class="keywordtype">double</span> endQty = f->getCumulativeProduced(); <a name="l00545"></a>00545 <span class="keywordtype">double</span> startQty = endQty - f->getQuantity(); <a name="l00546"></a>00546 <span class="keywordflow">if</span> (f->getCumulativeConsumed() <= startQty) <a name="l00547"></a>00547 { <a name="l00548"></a>00548 <span class="comment">// CASE 2A: Not consumed enough yet: move forward</span> <a name="l00549"></a>00549 <span class="keywordflow">while</span> (f!=getFlowPlans().end() <a name="l00550"></a>00550 && f->getCumulativeConsumed() <= startQty) ++f; <a name="l00551"></a>00551 <span class="keywordflow">while</span> (f!=getFlowPlans().end() <a name="l00552"></a>00552 && ( (f->getQuantity()<=0 <a name="l00553"></a>00553 && f->getCumulativeConsumed()+f->getQuantity() < endQty) <a name="l00554"></a>00554 || (f->getQuantity()>0 && f->getCumulativeConsumed() < endQty)) <a name="l00555"></a>00555 ) <a name="l00556"></a>00556 { <a name="l00557"></a>00557 <span class="keywordflow">if</span> (f->getQuantity() < -<a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a>) <a name="l00558"></a>00558 { <a name="l00559"></a>00559 <span class="keywordtype">double</span> newqty = - f->getQuantity(); <a name="l00560"></a>00560 <span class="keywordflow">if</span> (f->getCumulativeConsumed()+f->getQuantity() < startQty) <a name="l00561"></a>00561 newqty -= startQty - (f->getCumulativeConsumed()+f->getQuantity()); <a name="l00562"></a>00562 <span class="keywordflow">if</span> (f->getCumulativeConsumed() > endQty) <a name="l00563"></a>00563 newqty -= f->getCumulativeConsumed() - endQty; <a name="l00564"></a>00564 peggedQty += newqty; <a name="l00565"></a>00565 <span class="keyword">const</span> <a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a> *x = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>*<span class="keyword">></span>(&(*f)); <a name="l00566"></a>00566 iter.<a class="code" href="a00131.html#ae54c20a1ee7a60ef6448f05207c11990">updateStack</a>(nextlevel, <a name="l00567"></a>00567 curqty*newqty/curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(), <a name="l00568"></a>00568 -curfactor*newqty/f->getQuantity(), <a name="l00569"></a>00569 x, curflowplan); <a name="l00570"></a>00570 } <a name="l00571"></a>00571 ++f; <a name="l00572"></a>00572 } <a name="l00573"></a>00573 } <a name="l00574"></a>00574 <span class="keywordflow">else</span> <a name="l00575"></a>00575 { <a name="l00576"></a>00576 <span class="comment">// CASE 2B: Consumed too much already: move backward</span> <a name="l00577"></a>00577 <span class="keywordflow">while</span> ( f!=getFlowPlans().end() <a name="l00578"></a>00578 && ((f->getQuantity()<=0 && f->getCumulativeConsumed()+f->getQuantity() < endQty) <a name="l00579"></a>00579 || (f->getQuantity()>0 && f->getCumulativeConsumed() < endQty))) --f; <a name="l00580"></a>00580 <span class="keywordflow">while</span> (f!=getFlowPlans().end() && f->getCumulativeConsumed() > startQty) <a name="l00581"></a>00581 { <a name="l00582"></a>00582 <span class="keywordflow">if</span> (f->getQuantity() < -<a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a>) <a name="l00583"></a>00583 { <a name="l00584"></a>00584 <span class="keywordtype">double</span> newqty = - f->getQuantity(); <a name="l00585"></a>00585 <span class="keywordflow">if</span> (f->getCumulativeConsumed()+f->getQuantity() < startQty) <a name="l00586"></a>00586 newqty -= startQty - (f->getCumulativeConsumed()+f->getQuantity()); <a name="l00587"></a>00587 <span class="keywordflow">if</span> (f->getCumulativeConsumed() > endQty) <a name="l00588"></a>00588 newqty -= f->getCumulativeConsumed() - endQty; <a name="l00589"></a>00589 peggedQty += newqty; <a name="l00590"></a>00590 <span class="keyword">const</span> <a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a> *x = <span class="keyword">dynamic_cast<</span><span class="keyword">const </span><a class="code" href="a00068.html" title="A flowplan represents a planned material flow in or out of a buffer.">FlowPlan</a>*<span class="keyword">></span>(&(*f)); <a name="l00591"></a>00591 iter.<a class="code" href="a00131.html#ae54c20a1ee7a60ef6448f05207c11990">updateStack</a>(nextlevel, <a name="l00592"></a>00592 curqty*newqty/curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(), <a name="l00593"></a>00593 -curfactor*newqty/f->getQuantity(), <a name="l00594"></a>00594 x, curflowplan); <a name="l00595"></a>00595 } <a name="l00596"></a>00596 --f; <a name="l00597"></a>00597 } <a name="l00598"></a>00598 } <a name="l00599"></a>00599 <span class="keywordflow">if</span> (peggedQty < endQty - startQty) <a name="l00600"></a>00600 <span class="comment">// Unpegged material (i.e. material that is produced but never consumed)</span> <a name="l00601"></a>00601 <span class="comment">// is handled with a special entry on the stack.</span> <a name="l00602"></a>00602 iter.<a class="code" href="a00131.html#ae54c20a1ee7a60ef6448f05207c11990">updateStack</a>(nextlevel, <a name="l00603"></a>00603 curqty*(endQty - startQty - peggedQty)/curflowplan-><a class="code" href="a00059.html#a665af7bb916d05a8c9a06f1a8170090f">getQuantity</a>(), <a name="l00604"></a>00604 curfactor, <a name="l00605"></a>00605 NULL, curflowplan, <a name="l00606"></a>00606 <span class="keyword">false</span>); <a name="l00607"></a>00607 <span class="keywordflow">return</span>; <a name="l00608"></a>00608 } <a name="l00609"></a>00609 } <a name="l00610"></a>00610 <a name="l00611"></a>00611 <a name="l00612"></a>00612 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00010.html#a49b7c093cc51337c3f9536eca163416f">BufferInfinite::writeElement</a> <a name="l00613"></a><a class="code" href="a00010.html#a49b7c093cc51337c3f9536eca163416f">00613</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> &tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m) <span class="keyword">const</span> <a name="l00614"></a>00614 { <a name="l00615"></a>00615 <span class="comment">// Writing a reference</span> <a name="l00616"></a>00616 <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>) <a name="l00617"></a>00617 { <a name="l00618"></a>00618 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a> <a name="l00619"></a>00619 (tag, <a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, getName(), <a class="code" href="a00177.html#a6745112e0237e378e2b0cbe41aa5926a">Tags::tag_type</a>, getType().<a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">type</a>); <a name="l00620"></a>00620 <span class="keywordflow">return</span>; <a name="l00621"></a>00621 } <a name="l00622"></a>00622 <a name="l00623"></a>00623 <span class="comment">// Write the complete object</span> <a name="l00624"></a>00624 <span class="keywordflow">if</span> (m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-><a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a> <a name="l00625"></a>00625 (tag, <a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, getName(), <a class="code" href="a00177.html#a6745112e0237e378e2b0cbe41aa5926a">Tags::tag_type</a>, getType().<a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">type</a>); <a name="l00626"></a>00626 <a name="l00627"></a>00627 <span class="comment">// Write the fields and an ending tag</span> <a name="l00628"></a>00628 <a class="code" href="a00008.html#a8e72becff5b6b068ce2cd9e008902209">Buffer::writeElement</a>(o, tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>); <a name="l00629"></a>00629 } <a name="l00630"></a>00630 <a name="l00631"></a>00631 <a name="l00632"></a><a class="code" href="a00012.html#a50c10dee04e69195b5cccf8d91f9a3e9">00632</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00012.html#a50c10dee04e69195b5cccf8d91f9a3e9">BufferProcure::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>& pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& 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>& pElement) <a name="l00633"></a>00633 { <a name="l00634"></a>00634 <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a587d0f9a5d6f1fb11616b7f578d075f8">Tags::tag_leadtime</a>)) <a name="l00635"></a>00635 <a class="code" href="a00012.html#a5535e9a0e34a8de45a7de084de382678">setLeadtime</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>()); <a name="l00636"></a>00636 <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#a15051acfb2b84d9d66739b35b1f25dc2">Tags::tag_fence</a>)) <a name="l00637"></a>00637 <a class="code" href="a00012.html#a544a240f3322d166adeaffabc2f524c6">setFence</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>()); <a name="l00638"></a>00638 <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#a2a61d428da86cb99dc1e14942471e196">Tags::tag_size_maximum</a>)) <a name="l00639"></a>00639 <a class="code" href="a00012.html#a78af19d959dbbca11449c90037cdbddd">setSizeMaximum</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>()); <a name="l00640"></a>00640 <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#ac4efa6667599d8cf4b76d8751ff8cfbe">Tags::tag_size_minimum</a>)) <a name="l00641"></a>00641 <a class="code" href="a00012.html#a4acf38cd5f6fc69ff2fcc079c4ae0ee9">setSizeMinimum</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>()); <a name="l00642"></a>00642 <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#aa65ff231e3095a71120ddd19573fdeb6">Tags::tag_size_multiple</a>)) <a name="l00643"></a>00643 <a class="code" href="a00012.html#ab8da024a595efd03f866131395f14c2d">setSizeMultiple</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>()); <a name="l00644"></a>00644 <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#a8df2b0dd36108f0c7dedbc60f8ffa97d">Tags::tag_mininterval</a>)) <a name="l00645"></a>00645 <a class="code" href="a00012.html#a93ddc7837d7dda3467a2137389b51922">setMinimumInterval</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>()); <a name="l00646"></a>00646 <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#a4f268e9e03b0f064a27662ba838da99d">Tags::tag_maxinterval</a>)) <a name="l00647"></a>00647 <a class="code" href="a00012.html#acb8b8ec59dc5d8e6a83323cc13a60b7d">setMaximumInterval</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>()); <a name="l00648"></a>00648 <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#af591555c3d70008ed7920e769cd9e6c9">Tags::tag_mininventory</a>)) <a name="l00649"></a>00649 <a class="code" href="a00012.html#af2b20b3639c672ba2a5ead0e1c7b7abe">setMinimumInventory</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>()); <a name="l00650"></a>00650 <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#a42b2887f5af01b8c6f1663a5738bcb9d">Tags::tag_maxinventory</a>)) <a name="l00651"></a>00651 <a class="code" href="a00012.html#af34fbf7d13f57144d40a12a55598c4b3">setMaximumInventory</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>()); <a name="l00652"></a>00652 <span class="keywordflow">else</span> <a name="l00653"></a>00653 <a class="code" href="a00012.html#a50c10dee04e69195b5cccf8d91f9a3e9">Buffer::endElement</a>(pIn, pAttr, pElement); <a name="l00654"></a>00654 } <a name="l00655"></a>00655 <a name="l00656"></a>00656 <a name="l00657"></a><a class="code" href="a00012.html#a452abe7405e755e660a5b11a670c4996">00657</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00012.html#a452abe7405e755e660a5b11a670c4996">BufferProcure::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> &tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m)<span class="keyword"> const</span> <a name="l00658"></a>00658 <span class="keyword"></span>{ <a name="l00659"></a>00659 <span class="comment">// Writing a reference</span> <a name="l00660"></a>00660 <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>) <a name="l00661"></a>00661 { <a name="l00662"></a>00662 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a> <a name="l00663"></a>00663 (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="a00012.html#a333bbbf8917572e288bbb0183cafbbc5">getType</a>().<a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">type</a>); <a name="l00664"></a>00664 <span class="keywordflow">return</span>; <a name="l00665"></a>00665 } <a name="l00666"></a>00666 <a name="l00667"></a>00667 <span class="comment">// Write the complete object</span> <a name="l00668"></a>00668 <span class="keywordflow">if</span> (m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-><a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a> <a name="l00669"></a>00669 (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="a00012.html#a333bbbf8917572e288bbb0183cafbbc5">getType</a>().<a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">type</a>); <a name="l00670"></a>00670 <a name="l00671"></a>00671 <span class="comment">// Write the extra fields</span> <a name="l00672"></a>00672 <span class="keywordflow">if</span> (leadtime) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a587d0f9a5d6f1fb11616b7f578d075f8">Tags::tag_leadtime</a>, leadtime); <a name="l00673"></a>00673 <span class="keywordflow">if</span> (fence) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a15051acfb2b84d9d66739b35b1f25dc2">Tags::tag_fence</a>, fence); <a name="l00674"></a>00674 <span class="keywordflow">if</span> (size_maximum != DBL_MAX) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a2a61d428da86cb99dc1e14942471e196">Tags::tag_size_maximum</a>, size_maximum); <a name="l00675"></a>00675 <span class="keywordflow">if</span> (size_minimum) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ac4efa6667599d8cf4b76d8751ff8cfbe">Tags::tag_size_minimum</a>, size_minimum); <a name="l00676"></a>00676 <span class="keywordflow">if</span> (size_multiple) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#aa65ff231e3095a71120ddd19573fdeb6">Tags::tag_size_multiple</a>, size_multiple); <a name="l00677"></a>00677 <span class="keywordflow">if</span> (min_interval) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a8df2b0dd36108f0c7dedbc60f8ffa97d">Tags::tag_mininterval</a>, min_interval); <a name="l00678"></a>00678 <span class="keywordflow">if</span> (max_interval) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a4f268e9e03b0f064a27662ba838da99d">Tags::tag_maxinterval</a>, max_interval); <a name="l00679"></a>00679 <span class="keywordflow">if</span> (<a class="code" href="a00012.html#a37c714b5271449925c30b0f33c48559d">getMinimumInventory</a>()) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#af591555c3d70008ed7920e769cd9e6c9">Tags::tag_mininventory</a>, <a class="code" href="a00012.html#a37c714b5271449925c30b0f33c48559d">getMinimumInventory</a>()); <a name="l00680"></a>00680 <span class="keywordflow">if</span> (<a class="code" href="a00012.html#af6e461c261f6fa1100d3ad25577d3d55">getMaximumInventory</a>()) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a42b2887f5af01b8c6f1663a5738bcb9d">Tags::tag_maxinventory</a>, <a class="code" href="a00012.html#af6e461c261f6fa1100d3ad25577d3d55">getMaximumInventory</a>()); <a name="l00681"></a>00681 <a name="l00682"></a>00682 <span class="comment">// Write the fields and an ending tag</span> <a name="l00683"></a>00683 <a class="code" href="a00012.html#a452abe7405e755e660a5b11a670c4996">Buffer::writeElement</a>(o, tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>); <a name="l00684"></a>00684 } <a name="l00685"></a>00685 <a name="l00686"></a>00686 <a name="l00687"></a><a class="code" href="a00012.html#a403448f5135da4a0199ca43d03e3eb28">00687</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>* <a class="code" href="a00012.html#a403448f5135da4a0199ca43d03e3eb28">BufferProcure::getOperation</a>()<span class="keyword"> const</span> <a name="l00688"></a>00688 <span class="keyword"></span>{ <a name="l00689"></a>00689 <span class="keywordflow">if</span> (!oper) <a name="l00690"></a>00690 { <a name="l00691"></a>00691 <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a> *o = <a class="code" href="a00085.html#aad19dfc63a16f3fb30f7bda2e00f3cdc">Operation::find</a>(<a class="code" href="a00194.html#a4c0ba48382d5c668c848e5aecd397079">PROCURE_OPERATION</a>); <a name="l00692"></a>00692 <span class="keywordflow">if</span> (!o) <a name="l00693"></a>00693 { <a name="l00694"></a>00694 <span class="comment">// Create the operation if it didn't exist yet</span> <a name="l00695"></a>00695 o = <span class="keyword">new</span> <a class="code" href="a00123.html" title="Models an operation that takes a fixed amount of time, independent of the quantity...">OperationFixedTime</a>(<a class="code" href="a00194.html#a4c0ba48382d5c668c848e5aecd397079">PROCURE_OPERATION</a>); <a name="l00696"></a>00696 <span class="keyword">static_cast<</span><a class="code" href="a00123.html" title="Models an operation that takes a fixed amount of time, independent of the quantity...">OperationFixedTime</a>*<span class="keyword">></span>(o)->setDuration(leadtime); <a name="l00697"></a>00697 o-><a class="code" href="a00121.html#a24fa469d1f7e5bce42ab27389a15db92">setFence</a>(<a class="code" href="a00012.html#a2b36a705f88f52b7a7df0c9d55ef11e4">getFence</a>()); <a name="l00698"></a>00698 <span class="comment">// Ideally we would like to hide the procurement operation itself.</span> <a name="l00699"></a>00699 <span class="comment">// But in that case we need a different way to show the procurements</span> <a name="l00700"></a>00700 <span class="comment">// to the outside world.</span> <a name="l00701"></a>00701 <span class="comment">// o->setHidden(true);</span> <a name="l00702"></a>00702 <a class="code" href="a00085.html#a63b0e8c75aecc6fde9f4053ece52fde0">Operation::add</a>(o); <span class="comment">// No need to check again for existence</span> <a name="l00703"></a>00703 <span class="keyword">new</span> <a class="code" href="a00066.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">FlowEnd</a>(o, const_cast<BufferProcure*>(<span class="keyword">this</span>), 1); <a name="l00704"></a>00704 } <a name="l00705"></a>00705 <span class="keyword">const_cast<</span><a class="code" href="a00012.html" title="This class models a buffer that is replenish by an external supplier using a reorder-point...">BufferProcure</a>*<span class="keyword">></span>(<span class="keyword">this</span>)->oper = o; <a name="l00706"></a>00706 } <a name="l00707"></a>00707 <span class="keywordflow">return</span> oper; <a name="l00708"></a>00708 } <a name="l00709"></a>00709 <a name="l00710"></a>00710 <a name="l00711"></a><a class="code" href="a00008.html#ab843613e4155345fc443d514e2a5733c">00711</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00008.html#ab843613e4155345fc443d514e2a5733c">Buffer::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& attr) <a name="l00712"></a>00712 { <a name="l00713"></a>00713 <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="l00714"></a>00714 <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="l00715"></a>00715 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a6ae79e34440e259269ed2f902cd47157">Tags::tag_description</a>)) <a name="l00716"></a>00716 <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="a00082.html#aff438ae1fc6f5899acdc16217bbdd3a8">getDescription</a>()); <a name="l00717"></a>00717 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a712bcf2d196c0ddae4c4971127d4d43b">Tags::tag_category</a>)) <a name="l00718"></a>00718 <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="a00082.html#af0eb12cffb01b34278b77d1af02d2ddd">getCategory</a>()); <a name="l00719"></a>00719 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac932faef2edd6d850d233d2c2de7eb68">Tags::tag_subcategory</a>)) <a name="l00720"></a>00720 <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="a00082.html#a3f197282206d815ab8e8cdb0f4b49cc0">getSubCategory</a>()); <a name="l00721"></a>00721 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#aaa2f978792ac2320979871ceafdc5c16">Tags::tag_owner</a>)) <a name="l00722"></a>00722 <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="a00083.html#a4bda4eb77f34c0528e176446886fcce1">getOwner</a>()); <a name="l00723"></a>00723 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a3355294c37c4e6cd3a72a17115567071">Tags::tag_location</a>)) <a name="l00724"></a>00724 <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="a00008.html#a40c0c5f8038e7b9f4a0079aff1f90424">getLocation</a>()); <a name="l00725"></a>00725 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a419541bdc90e7a049a3d9bd9a1e6615f">Tags::tag_producing</a>)) <a name="l00726"></a>00726 <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="a00008.html#aa694888268875ab6711e5b97fc4c66c2">getProducingOperation</a>()); <a name="l00727"></a>00727 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a9503f5b5b382603919b72bf295c6bb95">Tags::tag_item</a>)) <a name="l00728"></a>00728 <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="a00008.html#ad4c18a30b6a1d8f04cad0435b78bef1c">getItem</a>()); <a name="l00729"></a>00729 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a94ff585d707284cf4d69287f4ea4a9ba">Tags::tag_onhand</a>)) <a name="l00730"></a>00730 <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="a00008.html#a7b14e45b2fa323722171eeee20fe68cb">getOnHand</a>()); <a name="l00731"></a>00731 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#aeaa2557f88702842d0f9fc54fd97fccc">Tags::tag_flowplans</a>)) <a name="l00732"></a>00732 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="a00070.html">FlowPlanIterator</a>(<span class="keyword">this</span>); <a name="l00733"></a>00733 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a608a97000f23fdec1baec4504d095b24">Tags::tag_maximum</a>)) <a name="l00734"></a>00734 <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="a00008.html#adbc1266e3cad49b06119cd9cd2e69bea">getMaximum</a>()); <a name="l00735"></a>00735 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac361ec1b9a7c26e74fbc4c21acb99049">Tags::tag_minimum</a>)) <a name="l00736"></a>00736 <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="a00008.html#abf0343b09fcc0d288c63104fdc1ba75f">getMinimum</a>()); <a name="l00737"></a>00737 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a6709bcf02b8e43b4784877c04c551e07">Tags::tag_carrying_cost</a>)) <a name="l00738"></a>00738 <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="a00008.html#adba7cdfff779fb56225d9601ad664eed">getCarryingCost</a>()); <a name="l00739"></a>00739 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac016b995f75e5fdb50eefc35924c6503">Tags::tag_hidden</a>)) <a name="l00740"></a>00740 <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="a00008.html#aaedd1dc617104d503802c40759969f27">getHidden</a>()); <a name="l00741"></a>00741 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a945bcc90195696e5059467e3e7e78cce">Tags::tag_flows</a>)) <a name="l00742"></a>00742 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="a00067.html">FlowIterator</a>(<span class="keyword">this</span>); <a name="l00743"></a>00743 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ab0b51261656d7b486c09abe3f2cd7025">Tags::tag_level</a>)) <a name="l00744"></a>00744 <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="a00084.html#a44c879fcf3b6ae9193c393630e25fd13">getLevel</a>()); <a name="l00745"></a>00745 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a5853f07e0af5d432d25a87b49e627e92">Tags::tag_cluster</a>)) <a name="l00746"></a>00746 <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="a00084.html#a1bd01594632b07953d6fa9babfa39d58">getCluster</a>()); <a name="l00747"></a>00747 <span class="comment">// @todo support member iteration for buffer, res, dem, item, ...</span> <a name="l00748"></a>00748 <span class="comment">// PythonBufferIterator becomes an abstract class: defines the pytype and an abstract iternext.</span> <a name="l00749"></a>00749 <span class="comment">// 2 subclasses then implement it: an iterator over all buffers, and another one over all members.</span> <a name="l00750"></a>00750 <span class="keywordflow">return</span> NULL; <a name="l00751"></a>00751 } <a name="l00752"></a>00752 <a name="l00753"></a>00753 <a name="l00754"></a><a class="code" href="a00008.html#af128af0e9d1496b37f07f1c514e3772a">00754</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00008.html#af128af0e9d1496b37f07f1c514e3772a">Buffer::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& 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>& field) <a name="l00755"></a>00755 { <a name="l00756"></a>00756 <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="l00757"></a>00757 <a class="code" href="a00085.html#a97d855d8c9bc9774da9cd8905e242dde">setName</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>()); <a name="l00758"></a>00758 <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#a6ae79e34440e259269ed2f902cd47157">Tags::tag_description</a>)) <a name="l00759"></a>00759 <a class="code" href="a00082.html#a86430aaf17c259450986d8ad73aa2fbf">setDescription</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>()); <a name="l00760"></a>00760 <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#a712bcf2d196c0ddae4c4971127d4d43b">Tags::tag_category</a>)) <a name="l00761"></a>00761 <a class="code" href="a00082.html#a765bec78ade5db873ae5d2c1a56238ab">setCategory</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>()); <a name="l00762"></a>00762 <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#ac932faef2edd6d850d233d2c2de7eb68">Tags::tag_subcategory</a>)) <a name="l00763"></a>00763 <a class="code" href="a00082.html#abd65cc21a6a0636f3569e90e89e54e5f">setSubCategory</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>()); <a name="l00764"></a>00764 <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#aaa2f978792ac2320979871ceafdc5c16">Tags::tag_owner</a>)) <a name="l00765"></a>00765 { <a name="l00766"></a>00766 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00008.html#ac768b16e2c57bb8a8d028d17b8565543">Buffer::metadata</a>)) <a name="l00767"></a>00767 { <a name="l00768"></a>00768 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"buffer owner must be of type buffer"</span>); <a name="l00769"></a>00769 <span class="keywordflow">return</span> -1; <a name="l00770"></a>00770 } <a name="l00771"></a>00771 <a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">Buffer</a>* y = <span class="keyword">static_cast<</span><a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">Buffer</a>*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00772"></a>00772 <a class="code" href="a00083.html#a9072d43b9a5670ce1492f55fefdc4b7f">setOwner</a>(y); <a name="l00773"></a>00773 } <a name="l00774"></a>00774 <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#a3355294c37c4e6cd3a72a17115567071">Tags::tag_location</a>)) <a name="l00775"></a>00775 { <a name="l00776"></a>00776 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00108.html#a92b7d2941cf8330f08acd95992dc89ad">Location::metadata</a>)) <a name="l00777"></a>00777 { <a name="l00778"></a>00778 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"buffer location must be of type location"</span>); <a name="l00779"></a>00779 <span class="keywordflow">return</span> -1; <a name="l00780"></a>00780 } <a name="l00781"></a>00781 <a class="code" href="a00108.html" title="This abstract class is used to associate buffers and resources with a physical or...">Location</a>* y = <span class="keyword">static_cast<</span><a class="code" href="a00108.html" title="This abstract class is used to associate buffers and resources with a physical or...">Location</a>*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00782"></a>00782 <a class="code" href="a00008.html#a18888ecb9681edd3b16d93ae6c8356cd">setLocation</a>(y); <a name="l00783"></a>00783 } <a name="l00784"></a>00784 <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#a9503f5b5b382603919b72bf295c6bb95">Tags::tag_item</a>)) <a name="l00785"></a>00785 { <a name="l00786"></a>00786 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00088.html#add18088c74a5522fc93a577922239e0a">Item::metadata</a>)) <a name="l00787"></a>00787 { <a name="l00788"></a>00788 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"buffer item must be of type item"</span>); <a name="l00789"></a>00789 <span class="keywordflow">return</span> -1; <a name="l00790"></a>00790 } <a name="l00791"></a>00791 <a class="code" href="a00088.html" title="An item defines the products being planned, sold, stored and/or manufactured. Buffers...">Item</a>* y = <span class="keyword">static_cast<</span><a class="code" href="a00088.html" title="An item defines the products being planned, sold, stored and/or manufactured. Buffers...">Item</a>*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00792"></a>00792 <a class="code" href="a00008.html#a32bd53e8441100b2d4a9b45f782114aa">setItem</a>(y); <a name="l00793"></a>00793 } <a name="l00794"></a>00794 <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#a608a97000f23fdec1baec4504d095b24">Tags::tag_maximum</a>)) <a name="l00795"></a>00795 { <a name="l00796"></a>00796 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00016.html#a758e254f27a10333b8801eecf7874b15">CalendarDouble::metadata</a>)) <a name="l00797"></a>00797 { <a name="l00798"></a>00798 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"buffer maximum must be of type calendar_double"</span>); <a name="l00799"></a>00799 <span class="keywordflow">return</span> -1; <a name="l00800"></a>00800 } <a name="l00801"></a>00801 <a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>* y = <span class="keyword">static_cast<</span><a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00802"></a>00802 <a class="code" href="a00008.html#a917f1bca74a654f228eee0b1e2c8763d">setMaximum</a>(y); <a name="l00803"></a>00803 } <a name="l00804"></a>00804 <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#ac361ec1b9a7c26e74fbc4c21acb99049">Tags::tag_minimum</a>)) <a name="l00805"></a>00805 { <a name="l00806"></a>00806 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00016.html#a758e254f27a10333b8801eecf7874b15">CalendarDouble::metadata</a>)) <a name="l00807"></a>00807 { <a name="l00808"></a>00808 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"buffer minimum must be of type calendar_double"</span>); <a name="l00809"></a>00809 <span class="keywordflow">return</span> -1; <a name="l00810"></a>00810 } <a name="l00811"></a>00811 <a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>* y = <span class="keyword">static_cast<</span><a class="code" href="a00016.html" title="A calendar storing double values in its buckets.">CalendarDouble</a>*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00812"></a>00812 <a class="code" href="a00008.html#a320d4eaa96145dda150d4c2cc4698cdd">setMinimum</a>(y); <a name="l00813"></a>00813 } <a name="l00814"></a>00814 <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#a94ff585d707284cf4d69287f4ea4a9ba">Tags::tag_onhand</a>)) <a name="l00815"></a>00815 <a class="code" href="a00008.html#aaceb978ee33141c9599ef9448819a5aa">setOnHand</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00816"></a>00816 <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#a6709bcf02b8e43b4784877c04c551e07">Tags::tag_carrying_cost</a>)) <a name="l00817"></a>00817 <a class="code" href="a00008.html#a7642211a5ba839ec3ad9515cee2dc091">setCarryingCost</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00818"></a>00818 <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#a419541bdc90e7a049a3d9bd9a1e6615f">Tags::tag_producing</a>)) <a name="l00819"></a>00819 { <a name="l00820"></a>00820 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>)) <a name="l00821"></a>00821 { <a name="l00822"></a>00822 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"buffer producing must be of type operation"</span>); <a name="l00823"></a>00823 <span class="keywordflow">return</span> -1; <a name="l00824"></a>00824 } <a name="l00825"></a>00825 <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>* y = <span class="keyword">static_cast<</span><a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00826"></a>00826 <a class="code" href="a00008.html#a4b3fe4aa484216fb7eb9941d6ad069c9">setProducingOperation</a>(y); <a name="l00827"></a>00827 } <a name="l00828"></a>00828 <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#ac016b995f75e5fdb50eefc35924c6503">Tags::tag_hidden</a>)) <a name="l00829"></a>00829 <a class="code" href="a00008.html#a1c1cc68f49327a3fb73e0678a745f565">setHidden</a>(field.<a class="code" href="a00154.html#a804b478fb76759d334882ee468fc84f9">getBool</a>()); <a name="l00830"></a>00830 <span class="keywordflow">else</span> <a name="l00831"></a>00831 <span class="keywordflow">return</span> -1; <span class="comment">// Error</span> <a name="l00832"></a>00832 <span class="keywordflow">return</span> 0; <span class="comment">// OK</span> <a name="l00833"></a>00833 } <a name="l00834"></a>00834 <a name="l00835"></a>00835 <a name="l00836"></a><a class="code" href="a00012.html#af131c8bbe4797a65df984c7715ebb07a">00836</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00012.html#af131c8bbe4797a65df984c7715ebb07a">BufferProcure::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& attr) <a name="l00837"></a>00837 { <a name="l00838"></a>00838 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a587d0f9a5d6f1fb11616b7f578d075f8">Tags::tag_leadtime</a>)) <a name="l00839"></a>00839 <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="a00012.html#a6adc5a1e4580c13dfafc9a7f4511a0f9">getLeadtime</a>()); <a name="l00840"></a>00840 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#af591555c3d70008ed7920e769cd9e6c9">Tags::tag_mininventory</a>)) <a name="l00841"></a>00841 <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="a00012.html#a37c714b5271449925c30b0f33c48559d">getMinimumInventory</a>()); <a name="l00842"></a>00842 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a42b2887f5af01b8c6f1663a5738bcb9d">Tags::tag_maxinventory</a>)) <a name="l00843"></a>00843 <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="a00012.html#af6e461c261f6fa1100d3ad25577d3d55">getMaximumInventory</a>()); <a name="l00844"></a>00844 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a8df2b0dd36108f0c7dedbc60f8ffa97d">Tags::tag_mininterval</a>)) <a name="l00845"></a>00845 <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="a00012.html#ab76ddd340f5507854db8a913afb758b6">getMinimumInterval</a>()); <a name="l00846"></a>00846 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a4f268e9e03b0f064a27662ba838da99d">Tags::tag_maxinterval</a>)) <a name="l00847"></a>00847 <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="a00012.html#a8e1343aa1e4e76370356d4a93de47a2b">getMaximumInterval</a>()); <a name="l00848"></a>00848 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a15051acfb2b84d9d66739b35b1f25dc2">Tags::tag_fence</a>)) <a name="l00849"></a>00849 <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="a00012.html#a2b36a705f88f52b7a7df0c9d55ef11e4">getFence</a>()); <a name="l00850"></a>00850 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac4efa6667599d8cf4b76d8751ff8cfbe">Tags::tag_size_minimum</a>)) <a name="l00851"></a>00851 <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="a00012.html#a273d7f036ed4fd6b2197c07e71356ece">getSizeMinimum</a>()); <a name="l00852"></a>00852 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#aa65ff231e3095a71120ddd19573fdeb6">Tags::tag_size_multiple</a>)) <a name="l00853"></a>00853 <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="a00012.html#a118957464c24c66af57cbbae5f7097c6">getSizeMultiple</a>()); <a name="l00854"></a>00854 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a2a61d428da86cb99dc1e14942471e196">Tags::tag_size_maximum</a>)) <a name="l00855"></a>00855 <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="a00012.html#a7a9884c8c6faa099cbeac64a0e04b1eb">getSizeMaximum</a>()); <a name="l00856"></a>00856 <span class="keywordflow">return</span> <a class="code" href="a00012.html#af131c8bbe4797a65df984c7715ebb07a">Buffer::getattro</a>(attr); <a name="l00857"></a>00857 } <a name="l00858"></a>00858 <a name="l00859"></a>00859 <a name="l00860"></a><a class="code" href="a00012.html#a658c30657777eef355b7207b9b1d13b1">00860</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00012.html#a658c30657777eef355b7207b9b1d13b1">BufferProcure::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& 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>& field) <a name="l00861"></a>00861 { <a name="l00862"></a>00862 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a587d0f9a5d6f1fb11616b7f578d075f8">Tags::tag_leadtime</a>)) <a name="l00863"></a>00863 <a class="code" href="a00012.html#a5535e9a0e34a8de45a7de084de382678">setLeadtime</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>()); <a name="l00864"></a>00864 <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#af591555c3d70008ed7920e769cd9e6c9">Tags::tag_mininventory</a>)) <a name="l00865"></a>00865 <a class="code" href="a00012.html#af2b20b3639c672ba2a5ead0e1c7b7abe">setMinimumInventory</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00866"></a>00866 <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#a42b2887f5af01b8c6f1663a5738bcb9d">Tags::tag_maxinventory</a>)) <a name="l00867"></a>00867 <a class="code" href="a00012.html#af34fbf7d13f57144d40a12a55598c4b3">setMaximumInventory</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00868"></a>00868 <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#a8df2b0dd36108f0c7dedbc60f8ffa97d">Tags::tag_mininterval</a>)) <a name="l00869"></a>00869 <a class="code" href="a00012.html#a93ddc7837d7dda3467a2137389b51922">setMinimumInterval</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>()); <a name="l00870"></a>00870 <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#a4f268e9e03b0f064a27662ba838da99d">Tags::tag_maxinterval</a>)) <a name="l00871"></a>00871 <a class="code" href="a00012.html#acb8b8ec59dc5d8e6a83323cc13a60b7d">setMaximumInterval</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>()); <a name="l00872"></a>00872 <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#ac4efa6667599d8cf4b76d8751ff8cfbe">Tags::tag_size_minimum</a>)) <a name="l00873"></a>00873 <a class="code" href="a00012.html#a4acf38cd5f6fc69ff2fcc079c4ae0ee9">setSizeMinimum</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00874"></a>00874 <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#aa65ff231e3095a71120ddd19573fdeb6">Tags::tag_size_multiple</a>)) <a name="l00875"></a>00875 <a class="code" href="a00012.html#ab8da024a595efd03f866131395f14c2d">setSizeMultiple</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00876"></a>00876 <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#a2a61d428da86cb99dc1e14942471e196">Tags::tag_size_maximum</a>)) <a name="l00877"></a>00877 <a class="code" href="a00012.html#a78af19d959dbbca11449c90037cdbddd">setSizeMaximum</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00878"></a>00878 <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#a15051acfb2b84d9d66739b35b1f25dc2">Tags::tag_fence</a>)) <a name="l00879"></a>00879 <a class="code" href="a00012.html#a544a240f3322d166adeaffabc2f524c6">setFence</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>()); <a name="l00880"></a>00880 <span class="keywordflow">else</span> <a name="l00881"></a>00881 <span class="keywordflow">return</span> <a class="code" href="a00012.html#a658c30657777eef355b7207b9b1d13b1">Buffer::setattro</a>(attr, field); <a name="l00882"></a>00882 <span class="keywordflow">return</span> 0; <a name="l00883"></a>00883 } <a name="l00884"></a>00884 <a name="l00885"></a>00885 } <span class="comment">// end namespace</span> </pre></div></div> <hr size="1"/><address style="align: right;"><small>Documentation generated for frePPLe by <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>