Sophie

Sophie

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

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

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

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

<div id="content">
<br/>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_88117dff2735251a69c8eb9084477714.html">src</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_25032d30b6d615a661c02e2ac1394b01.html">model</a>
  </div>
</div>
<div class="contents">
<h1>operation.cpp</h1><a href="a00223.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/operation.cpp $</span>
<a name="l00003"></a>00003 <span class="comment">  version : $LastChangedRevision: 1315 $  $LastChangedBy: jdetaeye $</span>
<a name="l00004"></a>00004 <span class="comment">  date : $LastChangedDate: 2010-07-17 18:08:53 +0200 (Sat, 17 Jul 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="a00223.html#a342983a479ae7a921be5face83fdb029">00028</a> <span class="preprocessor">#define FREPPLE_CORE</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include &quot;<a class="code" href="a00218.html">frepple/model.h</a>&quot;</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="keyword">namespace </span>frepple
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="keyword">template</span>&lt;<span class="keyword">class</span> Operation&gt; <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00181.html" title="This class implements a binary tree data structure. It is used as a container for...">Tree</a> utils::HasName&lt;Operation&gt;::st;
<a name="l00035"></a>00035 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> <a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>* <a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>;
<a name="l00036"></a>00036 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>* <a class="code" href="a00123.html#a4dc1ff9a0f9ee3e34f1cf5f2e75850a6">OperationFixedTime::metadata</a>,
<a name="l00037"></a>00037   *<a class="code" href="a00130.html#a4629757c5a8dbd6bce4c566717142aed">OperationTimePer::metadata</a>,
<a name="l00038"></a>00038   *<a class="code" href="a00128.html#aef5314cf5948eaf8b8f1958060b28f39">OperationRouting::metadata</a>,
<a name="l00039"></a>00039   *<a class="code" href="a00122.html#af55e7f4c9ea99a222e7433756f001d4a">OperationAlternate::metadata</a>,
<a name="l00040"></a>00040   *<a class="code" href="a00129.html#a615531dcb5e0218ab36901655f4c6052">OperationSetup::metadata</a>;
<a name="l00041"></a>00041 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00121.html#ae5c93377f652a5bdb9ec20e6bee898e9">Operation::Operationlist</a> Operation::nosubOperations;
<a name="l00042"></a>00042 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> Operation* <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>;
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 
<a name="l00045"></a><a class="code" href="a00121.html#ab5e2d2b189b10576cb3775b44e232f87">00045</a> <span class="keywordtype">int</span> <a class="code" href="a00121.html#ab5e2d2b189b10576cb3775b44e232f87">Operation::initialize</a>()
<a name="l00046"></a>00046 {
<a name="l00047"></a>00047   <span class="comment">// Initialize the metadata</span>
<a name="l00048"></a>00048   <a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">metadata</a> = <span class="keyword">new</span> <a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>(<span class="stringliteral">&quot;operation&quot;</span>, <span class="stringliteral">&quot;operations&quot;</span>, <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">reader</a>, <a class="code" href="a00085.html#a1071369052edea444a06baa35d7e991e">writer</a>);
<a name="l00049"></a>00049 
<a name="l00050"></a>00050   <span class="comment">// Initialize the Python class</span>
<a name="l00051"></a>00051   <span class="keywordflow">return</span> <a class="code" href="a00121.html#ab5e2d2b189b10576cb3775b44e232f87">FreppleCategory&lt;Operation&gt;::initialize</a>();
<a name="l00052"></a>00052 }
<a name="l00053"></a>00053 
<a name="l00054"></a>00054 
<a name="l00055"></a><a class="code" href="a00123.html#a5875fc9b4f9a69c217405e805572a1a0">00055</a> <span class="keywordtype">int</span> <a class="code" href="a00123.html#a5875fc9b4f9a69c217405e805572a1a0">OperationFixedTime::initialize</a>()
<a name="l00056"></a>00056 {
<a name="l00057"></a>00057   <span class="comment">// Initialize the metadata</span>
<a name="l00058"></a>00058   <a class="code" href="a00123.html#a4dc1ff9a0f9ee3e34f1cf5f2e75850a6">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>(<span class="stringliteral">&quot;operation&quot;</span>, <span class="stringliteral">&quot;operation_fixed_time&quot;</span>,
<a name="l00059"></a>00059     Object::createString&lt;OperationFixedTime&gt;, <span class="keyword">true</span>);
<a name="l00060"></a>00060 
<a name="l00061"></a>00061   <span class="comment">// Initialize the Python class</span>
<a name="l00062"></a>00062   <span class="keywordflow">return</span> <a class="code" href="a00123.html#a5875fc9b4f9a69c217405e805572a1a0">FreppleClass&lt;OperationFixedTime,Operation&gt;::initialize</a>();
<a name="l00063"></a>00063 }
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 
<a name="l00066"></a><a class="code" href="a00130.html#afaf1fe00da0ede538f58d58f9c6bdea8">00066</a> <span class="keywordtype">int</span> <a class="code" href="a00130.html#afaf1fe00da0ede538f58d58f9c6bdea8">OperationTimePer::initialize</a>()
<a name="l00067"></a>00067 {
<a name="l00068"></a>00068   <span class="comment">// Initialize the metadata</span>
<a name="l00069"></a>00069   <a class="code" href="a00130.html#a4629757c5a8dbd6bce4c566717142aed">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>(<span class="stringliteral">&quot;operation&quot;</span>, <span class="stringliteral">&quot;operation_time_per&quot;</span>,
<a name="l00070"></a>00070     Object::createString&lt;OperationTimePer&gt;);
<a name="l00071"></a>00071 
<a name="l00072"></a>00072   <span class="comment">// Initialize the Python class</span>
<a name="l00073"></a>00073   <span class="keywordflow">return</span> <a class="code" href="a00130.html#afaf1fe00da0ede538f58d58f9c6bdea8">FreppleClass&lt;OperationTimePer,Operation&gt;::initialize</a>();
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 
<a name="l00077"></a><a class="code" href="a00122.html#a0fd492b1c7b1c0d52270bd77cde6ffef">00077</a> <span class="keywordtype">int</span> <a class="code" href="a00122.html#a0fd492b1c7b1c0d52270bd77cde6ffef">OperationAlternate::initialize</a>()
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079   <span class="comment">// Initialize the metadata</span>
<a name="l00080"></a>00080   <a class="code" href="a00122.html#af55e7f4c9ea99a222e7433756f001d4a">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>(<span class="stringliteral">&quot;operation&quot;</span>, <span class="stringliteral">&quot;operation_alternate&quot;</span>,
<a name="l00081"></a>00081     Object::createString&lt;OperationAlternate&gt;);
<a name="l00082"></a>00082 
<a name="l00083"></a>00083   <span class="comment">// Initialize the Python class</span>
<a name="l00084"></a>00084   <a class="code" href="a00122.html#a909fec5736d2bd90dc6052aa8f4b7b94">FreppleClass&lt;OperationAlternate,Operation&gt;::getType</a>().addMethod(<span class="stringliteral">&quot;addAlternate&quot;</span>, <a class="code" href="a00122.html#accd0dc05a16c25a96b3fad2c22834ccc">OperationAlternate::addAlternate</a>, METH_KEYWORDS, <span class="stringliteral">&quot;add an alternate&quot;</span>);
<a name="l00085"></a>00085   <span class="keywordflow">return</span> <a class="code" href="a00122.html#a0fd492b1c7b1c0d52270bd77cde6ffef">FreppleClass&lt;OperationAlternate,Operation&gt;::initialize</a>();
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087 
<a name="l00088"></a>00088 
<a name="l00089"></a><a class="code" href="a00128.html#ac514629e1d2c8580682296357c3572dd">00089</a> <span class="keywordtype">int</span> <a class="code" href="a00128.html#ac514629e1d2c8580682296357c3572dd">OperationRouting::initialize</a>()
<a name="l00090"></a>00090 {
<a name="l00091"></a>00091   <span class="comment">// Initialize the metadata</span>
<a name="l00092"></a>00092   <a class="code" href="a00128.html#aef5314cf5948eaf8b8f1958060b28f39">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>(<span class="stringliteral">&quot;operation&quot;</span>, <span class="stringliteral">&quot;operation_routing&quot;</span>,
<a name="l00093"></a>00093     Object::createString&lt;OperationRouting&gt;);
<a name="l00094"></a>00094 
<a name="l00095"></a>00095   <span class="comment">// Initialize the Python class</span>
<a name="l00096"></a>00096   <a class="code" href="a00128.html#a5fe9bbd17ea3a5854143fcf7580eda99">FreppleClass&lt;OperationRouting,Operation&gt;::getType</a>().addMethod(<span class="stringliteral">&quot;addStep&quot;</span>, <a class="code" href="a00128.html#afd7538ad741943ee47c1aa2e9162e439">OperationRouting::addStep</a>, METH_VARARGS , <span class="stringliteral">&quot;add steps to the routing&quot;</span>);
<a name="l00097"></a>00097   <span class="keywordflow">return</span> <a class="code" href="a00128.html#ac514629e1d2c8580682296357c3572dd">FreppleClass&lt;OperationRouting,Operation&gt;::initialize</a>();
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 
<a name="l00101"></a><a class="code" href="a00129.html#abfeacc412756b3ccb6707c371f683a29">00101</a> <span class="keywordtype">int</span> <a class="code" href="a00129.html#abfeacc412756b3ccb6707c371f683a29">OperationSetup::initialize</a>()
<a name="l00102"></a>00102 {
<a name="l00103"></a>00103   <span class="comment">// Initialize the metadata.</span>
<a name="l00104"></a>00104   <span class="comment">// There is NO factory method</span>
<a name="l00105"></a>00105   <a class="code" href="a00129.html#a615531dcb5e0218ab36901655f4c6052">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>(<span class="stringliteral">&quot;operation&quot;</span>, <span class="stringliteral">&quot;operation_setup&quot;</span>);
<a name="l00106"></a>00106 
<a name="l00107"></a>00107   <span class="comment">// Initialize the Python class</span>
<a name="l00108"></a>00108   <span class="keywordtype">int</span> tmp = <a class="code" href="a00129.html#abfeacc412756b3ccb6707c371f683a29">FreppleClass&lt;OperationSetup,Operation&gt;::initialize</a>();
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   <span class="comment">// Create a generic setup operation.</span>
<a name="l00111"></a>00111   <span class="comment">// This will be the only instance of this class.</span>
<a name="l00112"></a>00112   <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">setupoperation</a> = <a class="code" href="a00085.html#a63b0e8c75aecc6fde9f4053ece52fde0">add</a>(<span class="keyword">new</span> <a class="code" href="a00129.html#a115a2310ed09327f4e750682a7c2433a">OperationSetup</a>(<span class="stringliteral">&quot;setup operation&quot;</span>));
<a name="l00113"></a>00113 
<a name="l00114"></a>00114   <span class="keywordflow">return</span> tmp;
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 
<a name="l00118"></a><a class="code" href="a00121.html#a2e795f6e702142d34e41ed03f8729a41">00118</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00121.html#a2e795f6e702142d34e41ed03f8729a41">Operation::~Operation</a>()
<a name="l00119"></a>00119 {
<a name="l00120"></a>00120   <span class="comment">// Delete all existing operationplans (even locked ones)</span>
<a name="l00121"></a>00121   <a class="code" href="a00121.html#acdd8d982c710c49a32648dd37bc559a2">deleteOperationPlans</a>(<span class="keyword">true</span>);
<a name="l00122"></a>00122 
<a name="l00123"></a>00123   <span class="comment">// The Flow and Load objects are automatically deleted by the destructor</span>
<a name="l00124"></a>00124   <span class="comment">// of the Association list class.</span>
<a name="l00125"></a>00125 
<a name="l00126"></a>00126   <span class="comment">// Remove the reference to this operation from all items</span>
<a name="l00127"></a>00127   <span class="keywordflow">for</span> (Item::iterator k = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Item::begin</a>(); k != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Item::end</a>(); ++k)
<a name="l00128"></a>00128     <span class="keywordflow">if</span> (k-&gt;getOperation() == <span class="keyword">this</span>) k-&gt;setOperation(NULL);
<a name="l00129"></a>00129 
<a name="l00130"></a>00130   <span class="comment">// Remove the reference to this operation from all demands</span>
<a name="l00131"></a>00131   <span class="keywordflow">for</span> (Demand::iterator l = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Demand::begin</a>(); l != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Demand::end</a>(); ++l)
<a name="l00132"></a>00132     <span class="keywordflow">if</span> (l-&gt;getOperation() == <span class="keyword">this</span>) l-&gt;setOperation(NULL);
<a name="l00133"></a>00133 
<a name="l00134"></a>00134   <span class="comment">// Remove the reference to this operation from all buffers</span>
<a name="l00135"></a>00135   <span class="keywordflow">for</span> (Buffer::iterator m = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Buffer::begin</a>(); m != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Buffer::end</a>(); ++m)
<a name="l00136"></a>00136     <span class="keywordflow">if</span> (m-&gt;getProducingOperation() == <span class="keyword">this</span>) m-&gt;setProducingOperation(NULL);
<a name="l00137"></a>00137 
<a name="l00138"></a>00138   <span class="comment">// Remove the operation from its super-operations and sub-operations</span>
<a name="l00139"></a>00139   <span class="comment">// Note that we are not using a for-loop since our function is actually</span>
<a name="l00140"></a>00140   <span class="comment">// updating the list of super-operations at the same time as we move</span>
<a name="l00141"></a>00141   <span class="comment">// through it.</span>
<a name="l00142"></a>00142   <span class="keywordflow">while</span> (!<a class="code" href="a00121.html#a0dbbd3263c4284b776f62f542ef09850">getSuperOperations</a>().<a class="code" href="a00085.html#a5514c78c650d5d2cc5dadc72869259fc">empty</a>())
<a name="l00143"></a>00143     <a class="code" href="a00121.html#a77405539fd34571c1256c92f59ad9b45">removeSuperOperation</a>(*<a class="code" href="a00121.html#a0dbbd3263c4284b776f62f542ef09850">getSuperOperations</a>().<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>());
<a name="l00144"></a>00144 }
<a name="l00145"></a>00145 
<a name="l00146"></a>00146 
<a name="l00147"></a><a class="code" href="a00128.html#a557402651b823972386b5f5f19a436e2">00147</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00128.html#a557402651b823972386b5f5f19a436e2">OperationRouting::~OperationRouting</a>()
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149   <span class="comment">// Note that we are not using a for-loop since our function is actually</span>
<a name="l00150"></a>00150   <span class="comment">// updating the list of super-operations at the same time as we move</span>
<a name="l00151"></a>00151   <span class="comment">// through it.</span>
<a name="l00152"></a>00152   <span class="keywordflow">while</span> (!<a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().<a class="code" href="a00085.html#a5514c78c650d5d2cc5dadc72869259fc">empty</a>())
<a name="l00153"></a>00153     <a class="code" href="a00128.html#a0687ee8feacc2b4a5645f176ae7be5a5">removeSubOperation</a>(*<a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>());
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 
<a name="l00156"></a>00156 
<a name="l00157"></a><a class="code" href="a00122.html#ab0389a8a75d09bd9c12560e0eee782b4">00157</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00122.html#ab0389a8a75d09bd9c12560e0eee782b4">OperationAlternate::~OperationAlternate</a>()
<a name="l00158"></a>00158 {
<a name="l00159"></a>00159   <span class="comment">// Note that we are not using a for-loop since our function is actually</span>
<a name="l00160"></a>00160   <span class="comment">// updating the list of super-operations at the same time as we move</span>
<a name="l00161"></a>00161   <span class="comment">// through it.</span>
<a name="l00162"></a>00162   <span class="keywordflow">while</span> (!<a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().<a class="code" href="a00085.html#a5514c78c650d5d2cc5dadc72869259fc">empty</a>())
<a name="l00163"></a>00163     <a class="code" href="a00122.html#a8067158022e2bd145cc9dad06c4e685b">removeSubOperation</a>(*<a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>());
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165 
<a name="l00166"></a>00166 
<a name="l00167"></a><a class="code" href="a00121.html#ad183a2e72b75cdd83f9e71f6bc235424">00167</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a>* <a class="code" href="a00121.html#ad183a2e72b75cdd83f9e71f6bc235424">Operation::createOperationPlan</a> (<span class="keywordtype">double</span> q, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> s, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> e,
<a name="l00168"></a>00168     <a class="code" href="a00051.html" title="Represents the (independent) demand in the system. It can represent a customer order...">Demand</a>* l, <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a>* ow, <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> i,
<a name="l00169"></a>00169     <span class="keywordtype">bool</span> makeflowsloads)<span class="keyword"> const</span>
<a name="l00170"></a>00170 <span class="keyword"></span>{
<a name="l00171"></a>00171   <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 = <span class="keyword">new</span> <a class="code" href="a00121.html#afbc1095d8768decf47335581f018cd01">OperationPlan</a>();
<a name="l00172"></a>00172   <a class="code" href="a00121.html#a9f0764e58b94d8f51fb2ca349d745027">initOperationPlan</a>(opplan,q,s,e,l,ow,i,makeflowsloads);
<a name="l00173"></a>00173   <span class="keywordflow">return</span> opplan;
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> <a class="code" href="a00121.html#a53bed8ce50df21b809e1cf7d1e39fd95">Operation::calculateOperationTime</a>
<a name="l00178"></a><a class="code" href="a00121.html#a53bed8ce50df21b809e1cf7d1e39fd95">00178</a>   (<a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> thedate, <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> duration, <span class="keywordtype">bool</span> forward,
<a name="l00179"></a>00179     <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> *actualduration) <span class="keyword">const</span>
<a name="l00180"></a>00180 {
<a name="l00181"></a>00181   <span class="keywordtype">int</span> calcount = 0;
<a name="l00182"></a>00182   <span class="comment">// Initial size of 10 should do for 99.99% of all cases</span>
<a name="l00183"></a>00183   vector&lt;Calendar::EventIterator*&gt; cals(10);
<a name="l00184"></a>00184 
<a name="l00185"></a>00185   <span class="comment">// Default actual duration</span>
<a name="l00186"></a>00186   <span class="keywordflow">if</span> (actualduration) *actualduration = duration;
<a name="l00187"></a>00187 
<a name="l00188"></a>00188   <span class="keywordflow">try</span>
<a name="l00189"></a>00189   {
<a name="l00190"></a>00190     <span class="comment">// Step 1: Create an iterator on each of the calendars</span>
<a name="l00191"></a>00191     <span class="comment">// a) operation&apos;s location</span>
<a name="l00192"></a>00192     <span class="keywordflow">if</span> (loc &amp;&amp; loc-&gt;getAvailable())
<a name="l00193"></a>00193       cals[calcount++] = <span class="keyword">new</span> <a class="code" href="a00061.html" title="An iterator class to go through all dates where the calendar value changes.">Calendar::EventIterator</a>(loc-&gt;getAvailable(), thedate, forward);
<a name="l00194"></a>00194     <span class="comment">/* @todo multiple availability calendars are not implmented yet</span>
<a name="l00195"></a>00195 <span class="comment">      for (Operation::loadlist::const_iterator g=loaddata.begin();</span>
<a name="l00196"></a>00196 <span class="comment">        g!=loaddata.end(); ++g)</span>
<a name="l00197"></a>00197 <span class="comment">    {</span>
<a name="l00198"></a>00198 <span class="comment">      Resource* res = g-&gt;getResource();</span>
<a name="l00199"></a>00199 <span class="comment">      if (res-&gt;getMaximum())</span>
<a name="l00200"></a>00200 <span class="comment">        // b) resource size calendar</span>
<a name="l00201"></a>00201 <span class="comment">        cals[calcount++] = new Calendar::EventIterator(</span>
<a name="l00202"></a>00202 <span class="comment">          res-&gt;getMaximum(),</span>
<a name="l00203"></a>00203 <span class="comment">          thedate</span>
<a name="l00204"></a>00204 <span class="comment">          );</span>
<a name="l00205"></a>00205 <span class="comment">      if (res-&gt;getLocation() &amp;&amp; res-&gt;getLocation()-&gt;getAvailable())</span>
<a name="l00206"></a>00206 <span class="comment">        // c) resource location</span>
<a name="l00207"></a>00207 <span class="comment">        cals[calcount++] = new Calendar::EventIterator(</span>
<a name="l00208"></a>00208 <span class="comment">          res-&gt;getLocation()-&gt;getAvailable(),</span>
<a name="l00209"></a>00209 <span class="comment">          thedate</span>
<a name="l00210"></a>00210 <span class="comment">          );</span>
<a name="l00211"></a>00211 <span class="comment">    }</span>
<a name="l00212"></a>00212 <span class="comment">    */</span>
<a name="l00213"></a>00213 
<a name="l00214"></a>00214     <span class="comment">// Special case: no calendars at all</span>
<a name="l00215"></a>00215     <span class="keywordflow">if</span> (calcount == 0)
<a name="l00216"></a>00216       <span class="keywordflow">return</span> forward ?
<a name="l00217"></a>00217         <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a>(thedate, thedate+duration) :
<a name="l00218"></a>00218         DateRange(thedate-duration, thedate);
<a name="l00219"></a>00219 
<a name="l00220"></a>00220     <span class="comment">// Step 2: Iterate over the calendar dates to find periods where all</span>
<a name="l00221"></a>00221     <span class="comment">// calendars are simultaneously effective.</span>
<a name="l00222"></a>00222     DateRange result;
<a name="l00223"></a>00223     <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> curdate = thedate;
<a name="l00224"></a>00224     <span class="keywordtype">bool</span> status = <span class="keyword">false</span>;
<a name="l00225"></a>00225     <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> curduration = duration;
<a name="l00226"></a>00226     <span class="keywordflow">while</span> (<span class="keyword">true</span>)
<a name="l00227"></a>00227     {
<a name="l00228"></a>00228       <span class="comment">// Check whether all calendars are available</span>
<a name="l00229"></a>00229       <span class="keywordtype">bool</span> available = <span class="keyword">true</span>;
<a name="l00230"></a>00230       <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c = 0; c &lt; calcount &amp;&amp; available; c++)
<a name="l00231"></a>00231       {
<a name="l00232"></a>00232         <span class="keywordflow">if</span> (cals[c]-&gt;getBucket())
<a name="l00233"></a>00233           available = cals[c]-&gt;getBucket()-&gt;getBool();
<a name="l00234"></a>00234         <span class="keywordflow">else</span>
<a name="l00235"></a>00235           available = cals[c]-&gt;getCalendar()-&gt;getBool();
<a name="l00236"></a>00236       }
<a name="l00237"></a>00237       curdate = cals[0]-&gt;getDate();
<a name="l00238"></a>00238 
<a name="l00239"></a>00239       <span class="keywordflow">if</span> (available &amp;&amp; !status)
<a name="l00240"></a>00240       {
<a name="l00241"></a>00241         <span class="comment">// Becoming available after unavailable period</span>
<a name="l00242"></a>00242         thedate = curdate;
<a name="l00243"></a>00243         status = <span class="keyword">true</span>;
<a name="l00244"></a>00244         <span class="keywordflow">if</span> (forward &amp;&amp; result.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>() == Date::infinitePast)
<a name="l00245"></a>00245           <span class="comment">// First available time - make operation start at this time</span>
<a name="l00246"></a>00246           result.<a class="code" href="a00050.html#a301068faa83a2a88fdb46ffb26f56502">setStart</a>(curdate);
<a name="l00247"></a>00247         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!forward &amp;&amp; result.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>() == Date::infiniteFuture)
<a name="l00248"></a>00248           <span class="comment">// First available time - make operation end at this time</span>
<a name="l00249"></a>00249           result.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(curdate);
<a name="l00250"></a>00250       }
<a name="l00251"></a>00251       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!available &amp;&amp; status)
<a name="l00252"></a>00252       {
<a name="l00253"></a>00253         <span class="comment">// Becoming unavailable after available period</span>
<a name="l00254"></a>00254         status = <span class="keyword">false</span>;
<a name="l00255"></a>00255         <span class="keywordflow">if</span> (forward)
<a name="l00256"></a>00256         {
<a name="l00257"></a>00257           <span class="comment">// Forward</span>
<a name="l00258"></a>00258           <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> delta = curdate - thedate;
<a name="l00259"></a>00259           <span class="keywordflow">if</span> (delta &gt;= curduration)
<a name="l00260"></a>00260           {
<a name="l00261"></a>00261             result.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(thedate + curduration);
<a name="l00262"></a>00262             <span class="keywordflow">break</span>;
<a name="l00263"></a>00263           }
<a name="l00264"></a>00264           <span class="keywordflow">else</span>
<a name="l00265"></a>00265             curduration -= delta;
<a name="l00266"></a>00266         }
<a name="l00267"></a>00267         <span class="keywordflow">else</span>
<a name="l00268"></a>00268         {
<a name="l00269"></a>00269           <span class="comment">// Backward</span>
<a name="l00270"></a>00270           <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> delta = thedate - curdate;
<a name="l00271"></a>00271           <span class="keywordflow">if</span> (delta &gt;= curduration)
<a name="l00272"></a>00272           {
<a name="l00273"></a>00273             result.<a class="code" href="a00050.html#a301068faa83a2a88fdb46ffb26f56502">setStart</a>(thedate - curduration);
<a name="l00274"></a>00274             <span class="keywordflow">break</span>;
<a name="l00275"></a>00275           }
<a name="l00276"></a>00276           <span class="keywordflow">else</span>
<a name="l00277"></a>00277             curduration -= delta;
<a name="l00278"></a>00278         }
<a name="l00279"></a>00279       }
<a name="l00280"></a>00280       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (forward &amp;&amp; curdate == Date::infiniteFuture)
<a name="l00281"></a>00281       {
<a name="l00282"></a>00282         <span class="comment">// End of forward iteration</span>
<a name="l00283"></a>00283         <span class="keywordflow">if</span> (available)
<a name="l00284"></a>00284         {
<a name="l00285"></a>00285           <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> delta = curdate - thedate;
<a name="l00286"></a>00286           <span class="keywordflow">if</span> (delta &gt;= curduration)
<a name="l00287"></a>00287             result.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(thedate + curduration);
<a name="l00288"></a>00288           <span class="keywordflow">else</span> <span class="keywordflow">if</span> (actualduration)
<a name="l00289"></a>00289             *actualduration = duration - curduration;
<a name="l00290"></a>00290         }
<a name="l00291"></a>00291         <span class="keywordflow">else</span>  <span class="keywordflow">if</span> (actualduration)
<a name="l00292"></a>00292           *actualduration = duration - curduration;
<a name="l00293"></a>00293         <span class="keywordflow">break</span>;
<a name="l00294"></a>00294       }
<a name="l00295"></a>00295       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!forward &amp;&amp; curdate == Date::infinitePast)
<a name="l00296"></a>00296       {
<a name="l00297"></a>00297         <span class="comment">// End of backward iteration</span>
<a name="l00298"></a>00298         <span class="keywordflow">if</span> (available)
<a name="l00299"></a>00299         {
<a name="l00300"></a>00300           <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> delta = thedate - curdate;
<a name="l00301"></a>00301           <span class="keywordflow">if</span> (delta &gt;= curduration)
<a name="l00302"></a>00302             result.<a class="code" href="a00050.html#a301068faa83a2a88fdb46ffb26f56502">setStart</a>(thedate - curduration);
<a name="l00303"></a>00303           <span class="keywordflow">else</span> <span class="keywordflow">if</span> (actualduration)
<a name="l00304"></a>00304             *actualduration = duration - curduration;
<a name="l00305"></a>00305         }
<a name="l00306"></a>00306         <span class="keywordflow">else</span> <span class="keywordflow">if</span> (actualduration)
<a name="l00307"></a>00307           *actualduration = duration - curduration;
<a name="l00308"></a>00308         <span class="keywordflow">break</span>;
<a name="l00309"></a>00309       }
<a name="l00310"></a>00310 
<a name="l00311"></a>00311       <span class="comment">// Advance to the next event</span>
<a name="l00312"></a>00312       <span class="keywordflow">if</span> (forward) ++(*cals[0]);
<a name="l00313"></a>00313       <span class="keywordflow">else</span> --(*cals[0]);
<a name="l00314"></a>00314     }
<a name="l00315"></a>00315 
<a name="l00316"></a>00316     <span class="comment">// Step 3: Clean up</span>
<a name="l00317"></a>00317     <span class="keywordflow">while</span> (calcount) <span class="keyword">delete</span> cals[--calcount];
<a name="l00318"></a>00318     <span class="keywordflow">return</span> result;
<a name="l00319"></a>00319   }
<a name="l00320"></a>00320   <span class="keywordflow">catch</span> (...)
<a name="l00321"></a>00321   {
<a name="l00322"></a>00322     <span class="comment">// Clean up</span>
<a name="l00323"></a>00323     <span class="keywordflow">while</span> (calcount) <span class="keyword">delete</span> cals[calcount--];
<a name="l00324"></a>00324     <span class="comment">// Rethrow the exception</span>
<a name="l00325"></a>00325     <span class="keywordflow">throw</span>;
<a name="l00326"></a>00326   }
<a name="l00327"></a>00327 }
<a name="l00328"></a>00328 
<a name="l00329"></a>00329 
<a name="l00330"></a>00330 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> <a class="code" href="a00121.html#a53bed8ce50df21b809e1cf7d1e39fd95">Operation::calculateOperationTime</a>
<a name="l00331"></a><a class="code" href="a00121.html#a9e22f3865dd34fd7f2e4efcec6f8221d">00331</a>   (<a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> start, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> end, <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> *actualduration) <span class="keyword">const</span>
<a name="l00332"></a>00332 {
<a name="l00333"></a>00333   <span class="comment">// Switch start and end if required</span>
<a name="l00334"></a>00334   <span class="keywordflow">if</span> (end &lt; start)
<a name="l00335"></a>00335   {
<a name="l00336"></a>00336     <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> tmp = start;
<a name="l00337"></a>00337     start = end;
<a name="l00338"></a>00338     end = tmp;
<a name="l00339"></a>00339   }
<a name="l00340"></a>00340 
<a name="l00341"></a>00341   <span class="keywordtype">int</span> calcount = 0;
<a name="l00342"></a>00342   <span class="comment">// Initial size of 10 should do for 99.99% of all cases</span>
<a name="l00343"></a>00343   vector&lt;Calendar::EventIterator*&gt; cals(10);
<a name="l00344"></a>00344 
<a name="l00345"></a>00345   <span class="comment">// Default actual duration</span>
<a name="l00346"></a>00346    <span class="keywordflow">if</span> (actualduration) *actualduration = 0L;
<a name="l00347"></a>00347 
<a name="l00348"></a>00348   <span class="keywordflow">try</span>
<a name="l00349"></a>00349   {
<a name="l00350"></a>00350     <span class="comment">// Step 1: Create an iterator on each of the calendars</span>
<a name="l00351"></a>00351     <span class="comment">// a) operation&apos;s location</span>
<a name="l00352"></a>00352     <span class="keywordflow">if</span> (loc &amp;&amp; loc-&gt;getAvailable())
<a name="l00353"></a>00353       cals[calcount++] = <span class="keyword">new</span> <a class="code" href="a00061.html" title="An iterator class to go through all dates where the calendar value changes.">Calendar::EventIterator</a>(loc-&gt;getAvailable(), start);
<a name="l00354"></a>00354     <span class="comment">/* @todo multiple availability calendars are not implmented yet</span>
<a name="l00355"></a>00355 <span class="comment">      for (Operation::loadlist::const_iterator g=loaddata.begin();</span>
<a name="l00356"></a>00356 <span class="comment">        g!=loaddata.end(); ++g)</span>
<a name="l00357"></a>00357 <span class="comment">    {</span>
<a name="l00358"></a>00358 <span class="comment">      Resource* res = g-&gt;getResource();</span>
<a name="l00359"></a>00359 <span class="comment">      if (res-&gt;getMaximum())</span>
<a name="l00360"></a>00360 <span class="comment">        // b) resource size calendar</span>
<a name="l00361"></a>00361 <span class="comment">        cals[calcount++] = new Calendar::EventIterator(</span>
<a name="l00362"></a>00362 <span class="comment">          res-&gt;getMaximum(),</span>
<a name="l00363"></a>00363 <span class="comment">          start</span>
<a name="l00364"></a>00364 <span class="comment">          );</span>
<a name="l00365"></a>00365 <span class="comment">      if (res-&gt;getLocation() &amp;&amp; res-&gt;getLocation()-&gt;getAvailable())</span>
<a name="l00366"></a>00366 <span class="comment">        // c) resource location</span>
<a name="l00367"></a>00367 <span class="comment">        cals[calcount++] = new Calendar::EventIterator(</span>
<a name="l00368"></a>00368 <span class="comment">          res-&gt;getLocation()-&gt;getAvailable(),</span>
<a name="l00369"></a>00369 <span class="comment">          start</span>
<a name="l00370"></a>00370 <span class="comment">          );</span>
<a name="l00371"></a>00371 <span class="comment">    }</span>
<a name="l00372"></a>00372 <span class="comment">    */</span>
<a name="l00373"></a>00373 
<a name="l00374"></a>00374     <span class="comment">// Special case: no calendars at all</span>
<a name="l00375"></a>00375     <span class="keywordflow">if</span> (calcount == 0)
<a name="l00376"></a>00376     {
<a name="l00377"></a>00377        <span class="keywordflow">if</span> (actualduration) *actualduration = end - start;
<a name="l00378"></a>00378       <span class="keywordflow">return</span> <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a>(start, end);
<a name="l00379"></a>00379     }
<a name="l00380"></a>00380 
<a name="l00381"></a>00381     <span class="comment">// Step 2: Iterate over the calendar dates to find periods where all</span>
<a name="l00382"></a>00382     <span class="comment">// calendars are simultaneously effective.</span>
<a name="l00383"></a>00383     <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> result;
<a name="l00384"></a>00384     <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> curdate = start;
<a name="l00385"></a>00385     <span class="keywordtype">bool</span> status = <span class="keyword">false</span>;
<a name="l00386"></a>00386     <span class="keywordflow">while</span> (<span class="keyword">true</span>)
<a name="l00387"></a>00387     {
<a name="l00388"></a>00388       <span class="comment">// Check whether all calendar are available</span>
<a name="l00389"></a>00389       <span class="keywordtype">bool</span> available = <span class="keyword">true</span>;
<a name="l00390"></a>00390       <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c = 0; c &lt; calcount &amp;&amp; available; c++)
<a name="l00391"></a>00391       {
<a name="l00392"></a>00392         <span class="keywordflow">if</span> (cals[c]-&gt;getBucket())
<a name="l00393"></a>00393           available = cals[c]-&gt;getBucket()-&gt;getBool();
<a name="l00394"></a>00394         <span class="keywordflow">else</span>
<a name="l00395"></a>00395           available = cals[c]-&gt;getCalendar()-&gt;getBool();
<a name="l00396"></a>00396       }
<a name="l00397"></a>00397       curdate = cals[0]-&gt;getDate();
<a name="l00398"></a>00398 
<a name="l00399"></a>00399       <span class="keywordflow">if</span> (available &amp;&amp; !status)
<a name="l00400"></a>00400       {
<a name="l00401"></a>00401         <span class="comment">// Becoming available after unavailable period</span>
<a name="l00402"></a>00402         <span class="keywordflow">if</span> (curdate &gt;= end)
<a name="l00403"></a>00403         {
<a name="l00404"></a>00404           <span class="comment">// Leaving the desired date range</span>
<a name="l00405"></a>00405           result.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(start);
<a name="l00406"></a>00406           <span class="keywordflow">break</span>;
<a name="l00407"></a>00407         }
<a name="l00408"></a>00408         start = curdate;
<a name="l00409"></a>00409         status = <span class="keyword">true</span>;
<a name="l00410"></a>00410         <span class="keywordflow">if</span> (result.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>() == Date::infinitePast)
<a name="l00411"></a>00411           <span class="comment">// First available time - make operation start at this time</span>
<a name="l00412"></a>00412           result.<a class="code" href="a00050.html#a301068faa83a2a88fdb46ffb26f56502">setStart</a>(curdate);
<a name="l00413"></a>00413       }
<a name="l00414"></a>00414       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!available &amp;&amp; status)
<a name="l00415"></a>00415       {
<a name="l00416"></a>00416         <span class="comment">// Becoming unavailable after available period</span>
<a name="l00417"></a>00417         <span class="keywordflow">if</span> (curdate &gt;= end)
<a name="l00418"></a>00418         {
<a name="l00419"></a>00419           <span class="comment">// Leaving the desired date range</span>
<a name="l00420"></a>00420            <span class="keywordflow">if</span> (actualduration) *actualduration += end - start;
<a name="l00421"></a>00421           result.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(end);
<a name="l00422"></a>00422           <span class="keywordflow">break</span>;
<a name="l00423"></a>00423         }
<a name="l00424"></a>00424         status = <span class="keyword">false</span>;
<a name="l00425"></a>00425          <span class="keywordflow">if</span> (actualduration) *actualduration += curdate - start;
<a name="l00426"></a>00426         start = curdate;
<a name="l00427"></a>00427       }
<a name="l00428"></a>00428       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (curdate &gt;= end)
<a name="l00429"></a>00429       {
<a name="l00430"></a>00430         <span class="comment">// Leaving the desired date range</span>
<a name="l00431"></a>00431         <span class="keywordflow">if</span> (available)
<a name="l00432"></a>00432         {
<a name="l00433"></a>00433            <span class="keywordflow">if</span> (actualduration) *actualduration += end - start;
<a name="l00434"></a>00434           result.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(end);
<a name="l00435"></a>00435           <span class="keywordflow">break</span>;
<a name="l00436"></a>00436         }
<a name="l00437"></a>00437         <span class="keywordflow">else</span>
<a name="l00438"></a>00438           result.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(start);
<a name="l00439"></a>00439         <span class="keywordflow">break</span>;
<a name="l00440"></a>00440       }
<a name="l00441"></a>00441 
<a name="l00442"></a>00442       <span class="comment">// Advance to the next event</span>
<a name="l00443"></a>00443       ++(*cals[0]);
<a name="l00444"></a>00444     }
<a name="l00445"></a>00445 
<a name="l00446"></a>00446     <span class="comment">// Step 3: Clean up</span>
<a name="l00447"></a>00447     <span class="keywordflow">while</span> (calcount) <span class="keyword">delete</span> cals[--calcount];
<a name="l00448"></a>00448     <span class="keywordflow">return</span> result;
<a name="l00449"></a>00449   }
<a name="l00450"></a>00450   <span class="keywordflow">catch</span> (...)
<a name="l00451"></a>00451   {
<a name="l00452"></a>00452     <span class="comment">// Clean up</span>
<a name="l00453"></a>00453     <span class="keywordflow">while</span> (calcount) <span class="keyword">delete</span> cals[calcount--];
<a name="l00454"></a>00454     <span class="comment">// Rethrow the exception</span>
<a name="l00455"></a>00455     <span class="keywordflow">throw</span>;
<a name="l00456"></a>00456   }
<a name="l00457"></a>00457 }
<a name="l00458"></a>00458 
<a name="l00459"></a>00459 
<a name="l00460"></a><a class="code" href="a00121.html#a9f0764e58b94d8f51fb2ca349d745027">00460</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00121.html#a9f0764e58b94d8f51fb2ca349d745027">Operation::initOperationPlan</a> (<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,
<a name="l00461"></a>00461     <span class="keywordtype">double</span> q, <span class="keyword">const</span> <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a>&amp; s, <span class="keyword">const</span> <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a>&amp; e, <a class="code" href="a00051.html" title="Represents the (independent) demand in the system. It can represent a customer order...">Demand</a>* l, <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a>* ow,
<a name="l00462"></a>00462     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> i, <span class="keywordtype">bool</span> makeflowsloads)<span class="keyword"> const</span>
<a name="l00463"></a>00463 <span class="keyword"></span>{
<a name="l00464"></a>00464   opplan-&gt;oper = <span class="keyword">const_cast&lt;</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">&gt;</span>(<span class="keyword">this</span>);
<a name="l00465"></a>00465   opplan-&gt;<a class="code" href="a00125.html#a94c3d23a9b1ea2a802cc58718187ef8a">setDemand</a>(l);
<a name="l00466"></a>00466   opplan-&gt;id = i;
<a name="l00467"></a>00467 
<a name="l00468"></a>00468   <span class="comment">// Setting the owner first. Note that the order is important here!</span>
<a name="l00469"></a>00469   <span class="comment">// For alternates &amp; routings the quantity needs to be set through the owner.</span>
<a name="l00470"></a>00470   opplan-&gt;<a class="code" href="a00125.html#a1a08b007136515186cc22cd95007f122">setOwner</a>(ow);
<a name="l00471"></a>00471 
<a name="l00472"></a>00472   <span class="comment">// Setting the dates and quantity</span>
<a name="l00473"></a>00473   <a class="code" href="a00121.html#a744480cdd80e70a2b0a7606114e1ab73">setOperationPlanParameters</a>(opplan,q,s,e);
<a name="l00474"></a>00474 
<a name="l00475"></a>00475   <span class="comment">// Create the loadplans and flowplans, if allowed</span>
<a name="l00476"></a>00476   <span class="keywordflow">if</span> (makeflowsloads) opplan-&gt;<a class="code" href="a00125.html#a1c0ab58f6d41e2fd26e50f09158042ee">createFlowLoads</a>();
<a name="l00477"></a>00477 
<a name="l00478"></a>00478   <span class="comment">// Update flow and loadplans, and mark for problem detection</span>
<a name="l00479"></a>00479   opplan-&gt;update();
<a name="l00480"></a>00480 }
<a name="l00481"></a>00481 
<a name="l00482"></a>00482 
<a name="l00483"></a><a class="code" href="a00121.html#acdd8d982c710c49a32648dd37bc559a2">00483</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00121.html#acdd8d982c710c49a32648dd37bc559a2">Operation::deleteOperationPlans</a>(<span class="keywordtype">bool</span> deleteLockedOpplans)
<a name="l00484"></a>00484 {
<a name="l00485"></a>00485   <a class="code" href="a00121.html#acdd8d982c710c49a32648dd37bc559a2">OperationPlan::deleteOperationPlans</a>(<span class="keyword">this</span>, deleteLockedOpplans);
<a name="l00486"></a>00486 }
<a name="l00487"></a>00487 
<a name="l00488"></a>00488 
<a name="l00489"></a><a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">00489</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">Operation::writeElement</a>(<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&amp; tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m)<span class="keyword"> const</span>
<a name="l00490"></a>00490 <span class="keyword"></span>{
<a name="l00491"></a>00491   <span class="comment">// Note that this class is abstract and never instantiated directly. There is</span>
<a name="l00492"></a>00492   <span class="comment">// therefore no reason to ever write a header.</span>
<a name="l00493"></a>00493   assert(m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>);
<a name="l00494"></a>00494 
<a name="l00495"></a>00495   <span class="comment">// Write the fields</span>
<a name="l00496"></a>00496   <a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">HasDescription::writeElement</a>(o, tag);
<a name="l00497"></a>00497   <a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">Plannable::writeElement</a>(o, tag);
<a name="l00498"></a>00498   <span class="keywordflow">if</span> (post_time)
<a name="l00499"></a>00499     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#acc636e19133af3f4c3897bde9633543a">Tags::tag_posttime</a>, post_time);
<a name="l00500"></a>00500   <span class="keywordflow">if</span> (pre_time)
<a name="l00501"></a>00501     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ab45db3e14bc139292860766d13a426ab">Tags::tag_pretime</a>, pre_time);
<a name="l00502"></a>00502   <span class="keywordflow">if</span> (<a class="code" href="a00121.html#ab69b08d57703a9d7809530270a6b86bf">getCost</a>() != 0.0)
<a name="l00503"></a>00503     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>, <a class="code" href="a00121.html#ab69b08d57703a9d7809530270a6b86bf">getCost</a>());
<a name="l00504"></a>00504   <span class="keywordflow">if</span> (fence)
<a name="l00505"></a>00505     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a15051acfb2b84d9d66739b35b1f25dc2">Tags::tag_fence</a>, fence);
<a name="l00506"></a>00506   <span class="keywordflow">if</span> (size_minimum != 1.0)
<a name="l00507"></a>00507     o-&gt;<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="l00508"></a>00508   <span class="keywordflow">if</span> (size_multiple &gt; 0.0)
<a name="l00509"></a>00509     o-&gt;<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="l00510"></a>00510   <span class="keywordflow">if</span> (size_maximum &lt; DBL_MAX)
<a name="l00511"></a>00511     o-&gt;<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="l00512"></a>00512   <span class="keywordflow">if</span> (loc)
<a name="l00513"></a>00513     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a3355294c37c4e6cd3a72a17115567071">Tags::tag_location</a>, loc);
<a name="l00514"></a>00514 
<a name="l00515"></a>00515   <span class="comment">// Write extra plan information</span>
<a name="l00516"></a>00516   <span class="keywordflow">if</span> ((o-&gt;<a class="code" href="a00189.html#a364e86ed0671915df858bc52adadd29f">getContentType</a>() == XMLOutput::PLAN
<a name="l00517"></a>00517       || o-&gt;<a class="code" href="a00189.html#a364e86ed0671915df858bc52adadd29f">getContentType</a>() == XMLOutput::PLANDETAIL) &amp;&amp; first_opplan)
<a name="l00518"></a>00518   {
<a name="l00519"></a>00519     o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(<a class="code" href="a00177.html#aadee013608238a2c7309cb6960496126">Tags::tag_operationplans</a>);
<a name="l00520"></a>00520     <span class="keywordflow">for</span> (<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(<span class="keyword">this</span>); i!=<a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">OperationPlan::end</a>(); ++i)
<a name="l00521"></a>00521       o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a6c742342d4a7f8112aca62435d43912a">Tags::tag_operationplan</a>, *i, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398ae6f8960699e19b8d77b093b7e2c48619">FULL</a>);
<a name="l00522"></a>00522     o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(<a class="code" href="a00177.html#aadee013608238a2c7309cb6960496126">Tags::tag_operationplans</a>);
<a name="l00523"></a>00523   }
<a name="l00524"></a>00524 }
<a name="l00525"></a>00525 
<a name="l00526"></a>00526 
<a name="l00527"></a><a class="code" href="a00121.html#a1ea5ed57a9d9cf0ffd71db2c1122ecf5">00527</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00121.html#a1ea5ed57a9d9cf0ffd71db2c1122ecf5">Operation::beginElement</a>(<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr)
<a name="l00528"></a>00528 {
<a name="l00529"></a>00529   <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="l00530"></a>00530       &amp;&amp; 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="l00531"></a>00531   {
<a name="l00532"></a>00532     <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="l00533"></a>00533       <span class="keyword">dynamic_cast&lt;</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">&gt;</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="l00534"></a>00534     <span class="keywordflow">if</span> (f) f-&gt;<a class="code" href="a00065.html#a6d954f1d4e61bd68fcb4cafb8a30d24a">setOperation</a>(<span class="keyword">this</span>);
<a name="l00535"></a>00535     pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>(f);
<a name="l00536"></a>00536   }
<a name="l00537"></a>00537   <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#ad82a69d14ccb381f200a1af582cb98e2">Tags::tag_load</a>)
<a name="l00538"></a>00538       &amp;&amp; pIn.<a class="code" href="a00186.html#a407522e9d0dde7f7eebfafe182d050cf">getParentElement</a>().first.isA(<a class="code" href="a00177.html#a2e32d4c89079c071ec2bd8e634e9b440">Tags::tag_loads</a>))
<a name="l00539"></a>00539   {
<a name="l00540"></a>00540     <a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a>* l = <span class="keyword">new</span> <a class="code" href="a00121.html#ada8f776cb873ad4dc1202c73c08d0f53">Load</a>();
<a name="l00541"></a>00541     l-&gt;<a class="code" href="a00103.html#a5f1714647aeb77dd01095bd74c3e9830">setOperation</a>(<span class="keyword">this</span>);
<a name="l00542"></a>00542     pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>(&amp;*l);
<a name="l00543"></a>00543   }
<a name="l00544"></a>00544   <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#a6c742342d4a7f8112aca62435d43912a">Tags::tag_operationplan</a>))
<a name="l00545"></a>00545     pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>(<a class="code" href="a00125.html#acabc6d5f06b157c155355d04b3e2e4ef">OperationPlan::createOperationPlan</a>(<a class="code" href="a00125.html#a31cde691d7cdf2ce2db1fb0eb595e34a">OperationPlan::metadata</a>, pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()));
<a name="l00546"></a>00546   <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="l00547"></a>00547     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="l00548"></a>00548 }
<a name="l00549"></a>00549 
<a name="l00550"></a>00550 
<a name="l00551"></a><a class="code" href="a00121.html#aa201f6f1dd9d0194ac419345333a5a7f">00551</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00121.html#aa201f6f1dd9d0194ac419345333a5a7f">Operation::endElement</a> (<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>&amp; pElement)
<a name="l00552"></a>00552 {
<a name="l00553"></a>00553   <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="l00554"></a>00554     <a class="code" href="a00121.html#a24fa469d1f7e5bce42ab27389a15db92">setFence</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>());
<a name="l00555"></a>00555   <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="l00556"></a>00556     <a class="code" href="a00121.html#a0bf699cb21a1431b85441a4fc9675f86">setSizeMinimum</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>());
<a name="l00557"></a>00557   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>))
<a name="l00558"></a>00558     <a class="code" href="a00121.html#a258d1a1dbd72994a5c351560b579264b">setCost</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>());
<a name="l00559"></a>00559   <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="l00560"></a>00560     <a class="code" href="a00121.html#aade8f5a9ecbdc851a1fdcfed6f76387f">setSizeMultiple</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>());
<a name="l00561"></a>00561   <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="l00562"></a>00562     <a class="code" href="a00121.html#aba8019ede4a8d42c9ef7c26e2c82b7ed">setSizeMaximum</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>());
<a name="l00563"></a>00563   <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#ab45db3e14bc139292860766d13a426ab">Tags::tag_pretime</a>))
<a name="l00564"></a>00564     <a class="code" href="a00121.html#ac72b630ad4d0e25b8999bf769b992355">setPreTime</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>());
<a name="l00565"></a>00565   <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#acc636e19133af3f4c3897bde9633543a">Tags::tag_posttime</a>))
<a name="l00566"></a>00566     <a class="code" href="a00121.html#abbdf4639868202354b5dac66bb957442">setPostTime</a>(pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>());
<a name="l00567"></a>00567   <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="l00568"></a>00568   {
<a name="l00569"></a>00569     <a class="code" href="a00108.html" title="This abstract class is used to associate buffers and resources with a physical or...">Location</a> *l = <span class="keyword">dynamic_cast&lt;</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">&gt;</span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>());
<a name="l00570"></a>00570     <span class="keywordflow">if</span> (l) <a class="code" href="a00121.html#a9244c0638313cf9f830916196d4d17ff">setLocation</a>(l);
<a name="l00571"></a>00571     <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">&quot;Incorrect object type during read operation&quot;</span>);
<a name="l00572"></a>00572   }
<a name="l00573"></a>00573   <span class="keywordflow">else</span>
<a name="l00574"></a>00574   {
<a name="l00575"></a>00575     <a class="code" href="a00121.html#aa201f6f1dd9d0194ac419345333a5a7f">Plannable::endElement</a>(pIn, pAttr, pElement);
<a name="l00576"></a>00576     <a class="code" href="a00121.html#aa201f6f1dd9d0194ac419345333a5a7f">HasDescription::endElement</a>(pIn, pAttr, pElement);
<a name="l00577"></a>00577   }
<a name="l00578"></a>00578 }
<a name="l00579"></a>00579 
<a name="l00580"></a>00580 
<a name="l00581"></a>00581 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>
<a name="l00582"></a>00582 <a class="code" href="a00123.html#abecd797cb671e1cbb6b94e60445f2518">OperationFixedTime::setOperationPlanParameters</a>
<a name="l00583"></a><a class="code" href="a00123.html#abecd797cb671e1cbb6b94e60445f2518">00583</a> (<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, <span class="keywordtype">double</span> q, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> s, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> e, <span class="keywordtype">bool</span> preferEnd, <span class="keywordtype">bool</span> execute) <span class="keyword">const</span>
<a name="l00584"></a>00584 {
<a name="l00585"></a>00585   <span class="comment">// Invalid call to the function, or locked operationplan.</span>
<a name="l00586"></a>00586   <span class="keywordflow">if</span> (!opplan || q&lt;0)
<a name="l00587"></a>00587     <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Incorrect parameters for fixedtime operationplan&quot;</span>);
<a name="l00588"></a>00588   <span class="keywordflow">if</span> (opplan-&gt;<a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>())
<a name="l00589"></a>00589     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l00590"></a>00590 
<a name="l00591"></a>00591   <span class="comment">// All quantities are valid, as long as they are above the minimum size and </span>
<a name="l00592"></a>00592   <span class="comment">// below the maximum size</span>
<a name="l00593"></a>00593   <span class="keywordflow">if</span> (q &gt; 0 &amp;&amp; q &lt; getSizeMinimum()) q = getSizeMinimum();
<a name="l00594"></a>00594   <span class="keywordflow">if</span> (q &gt; getSizeMaximum()) q = getSizeMaximum();
<a name="l00595"></a>00595   <span class="keywordflow">if</span> (fabs(q - opplan-&gt;<a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>()) &gt; <a class="code" href="a00252.html#a42d90a6275119e1b4ce73c50f1867e60">ROUNDING_ERROR</a>)
<a name="l00596"></a>00596     q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q, <span class="keyword">false</span>, <span class="keyword">false</span>, execute);
<a name="l00597"></a>00597 
<a name="l00598"></a>00598   <span class="comment">// Set the start and end date.</span>
<a name="l00599"></a>00599   <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> x;
<a name="l00600"></a>00600   <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> actualduration;
<a name="l00601"></a>00601   <span class="keywordflow">if</span> (e &amp;&amp; s)
<a name="l00602"></a>00602   {
<a name="l00603"></a>00603     <span class="keywordflow">if</span> (preferEnd) x = calculateOperationTime(e, duration, <span class="keyword">false</span>, &amp;actualduration);
<a name="l00604"></a>00604     <span class="keywordflow">else</span> x = calculateOperationTime(s, duration, <span class="keyword">true</span>, &amp;actualduration);
<a name="l00605"></a>00605   }
<a name="l00606"></a>00606   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (s) x = calculateOperationTime(s, duration, <span class="keyword">true</span>, &amp;actualduration);
<a name="l00607"></a>00607   <span class="keywordflow">else</span> x = calculateOperationTime(e, duration, <span class="keyword">false</span>, &amp;actualduration);
<a name="l00608"></a>00608   <span class="keywordflow">if</span> (!execute)
<a name="l00609"></a>00609     <span class="comment">// Simulation only</span>
<a name="l00610"></a>00610     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, actualduration == duration ? q : 0);
<a name="l00611"></a>00611   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (actualduration == duration)
<a name="l00612"></a>00612     <span class="comment">// Update succeeded</span>
<a name="l00613"></a>00613     opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(x.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(), x.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>());
<a name="l00614"></a>00614   <span class="keywordflow">else</span>
<a name="l00615"></a>00615     <span class="comment">// Update failed - Not enough available time</span>
<a name="l00616"></a>00616     opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(0);
<a name="l00617"></a>00617 
<a name="l00618"></a>00618   <span class="comment">// Return value</span>
<a name="l00619"></a>00619   <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l00620"></a>00620 }
<a name="l00621"></a>00621 
<a name="l00622"></a>00622 
<a name="l00623"></a><a class="code" href="a00123.html#ad4bdd7531824452d710d9f427514f44b">00623</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">bool</span> <a class="code" href="a00123.html#ad4bdd7531824452d710d9f427514f44b">OperationFixedTime::extraInstantiate</a>(<a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a>* o)
<a name="l00624"></a>00624 {
<a name="l00625"></a>00625   <span class="comment">// See if we can consolidate this operationplan with an existing one.</span>
<a name="l00626"></a>00626   <span class="comment">// Merging is possible only when all the following conditions are met:</span>
<a name="l00627"></a>00627   <span class="comment">//   - id of the new opplan is not set</span>
<a name="l00628"></a>00628   <span class="comment">//   - id of the old opplan is set</span>
<a name="l00629"></a>00629   <span class="comment">//   - it is a fixedtime operation</span>
<a name="l00630"></a>00630   <span class="comment">//   - it doesn&apos;t load any resources</span>
<a name="l00631"></a>00631   <span class="comment">//   - both operationplans aren&apos;t locked</span>
<a name="l00632"></a>00632   <span class="comment">//   - both operationplans have no owner</span>
<a name="l00633"></a>00633   <span class="comment">//   - start and end date of both operationplans are the same</span>
<a name="l00634"></a>00634   <span class="comment">//   - demand of both operationplans are the same</span>
<a name="l00635"></a>00635   <span class="comment">//   - maximum operation size is not exceeded</span>
<a name="l00636"></a>00636   <span class="comment">//   - alternate flowplans need to be on the same alternate</span>
<a name="l00637"></a>00637   <span class="keywordflow">if</span> (!o-&gt;<a class="code" href="a00125.html#a2fc22f86c78b34f91bf535c742e2e740">getIdentifier</a>() &amp;&amp; !o-&gt;<a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>() &amp;&amp; !o-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>() &amp;&amp; <a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().empty())
<a name="l00638"></a>00638   {
<a name="l00639"></a>00639     <span class="comment">// Loop through candidates</span>
<a name="l00640"></a>00640     <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> x(<span class="keyword">this</span>);
<a name="l00641"></a>00641     <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a> *y = NULL;
<a name="l00642"></a>00642     <span class="keywordflow">for</span> (; x != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">OperationPlan::end</a>() &amp;&amp; *x &lt; *o; ++x)
<a name="l00643"></a>00643       y = &amp;*x;
<a name="l00644"></a>00644     <span class="keywordflow">if</span> (y &amp;&amp; y-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>() == o-&gt;getDates() &amp;&amp; !y-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()
<a name="l00645"></a>00645       &amp;&amp; y-&gt;<a class="code" href="a00125.html#a4cd571d01df7194dd232d07f7cbba03f">getDemand</a>() == o-&gt;getDemand() &amp;&amp; !y-&gt;<a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>() &amp;&amp; y-&gt;<a class="code" href="a00125.html#a2fc22f86c78b34f91bf535c742e2e740">getIdentifier</a>()
<a name="l00646"></a>00646       &amp;&amp; y-&gt;<a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>() + o-&gt;getQuantity() &lt; <a class="code" href="a00121.html#af720f657b00a661e76f3ba7304053071">getSizeMaximum</a>())  <span class="comment">// @todo ignores multiple qty</span>
<a name="l00647"></a>00647     {
<a name="l00648"></a>00648       <span class="comment">// Check that the flowplans are on identical alternates</span>
<a name="l00649"></a>00649       <a class="code" href="a00069.html" title="An iterator class to go through all flowplans of an operationplan.">OperationPlan::FlowPlanIterator</a> fp1 = o-&gt;beginFlowPlans();
<a name="l00650"></a>00650       <a class="code" href="a00069.html" title="An iterator class to go through all flowplans of an operationplan.">OperationPlan::FlowPlanIterator</a> fp2 = y-&gt;<a class="code" href="a00125.html#a4fb68598ded2db1ae3a9f5f975dd09c6">beginFlowPlans</a>();
<a name="l00651"></a>00651       <span class="keywordflow">while</span> (fp1 != o-&gt;endFlowPlans())
<a name="l00652"></a>00652       {
<a name="l00653"></a>00653         <span class="keywordflow">if</span> (fp1-&gt;getBuffer() != fp2-&gt;getBuffer())
<a name="l00654"></a>00654           <span class="comment">// Different alternates - no merge possible</span>
<a name="l00655"></a>00655           <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00656"></a>00656         ++fp1;
<a name="l00657"></a>00657         ++fp2;
<a name="l00658"></a>00658       }
<a name="l00659"></a>00659       <span class="comment">// Merging with the &apos;next&apos; operationplan</span>
<a name="l00660"></a>00660       y-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(y-&gt;<a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>() + o-&gt;getQuantity());
<a name="l00661"></a>00661       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00662"></a>00662     }
<a name="l00663"></a>00663     <span class="keywordflow">if</span> (x!= <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>() &amp;&amp; x-&gt;getDates() == o-&gt;getDates() &amp;&amp; !x-&gt;getOwner()
<a name="l00664"></a>00664       &amp;&amp; x-&gt;getDemand() == o-&gt;getDemand() &amp;&amp; !x-&gt;getLocked() &amp;&amp; x-&gt;getIdentifier()
<a name="l00665"></a>00665       &amp;&amp; x-&gt;getQuantity() + o-&gt;getQuantity() &lt; <a class="code" href="a00121.html#af720f657b00a661e76f3ba7304053071">getSizeMaximum</a>()) <span class="comment">// @todo ignores multiple qty</span>
<a name="l00666"></a>00666     {
<a name="l00667"></a>00667       <span class="comment">// Check that the flowplans are on identical alternates</span>
<a name="l00668"></a>00668       <a class="code" href="a00069.html" title="An iterator class to go through all flowplans of an operationplan.">OperationPlan::FlowPlanIterator</a> fp1 = o-&gt;beginFlowPlans();
<a name="l00669"></a>00669       <a class="code" href="a00069.html" title="An iterator class to go through all flowplans of an operationplan.">OperationPlan::FlowPlanIterator</a> fp2 = x-&gt;beginFlowPlans();
<a name="l00670"></a>00670       <span class="keywordflow">while</span> (fp1 != o-&gt;endFlowPlans())
<a name="l00671"></a>00671       {
<a name="l00672"></a>00672         <span class="keywordflow">if</span> (fp1-&gt;getBuffer() != fp2-&gt;getBuffer())
<a name="l00673"></a>00673           <span class="comment">// Different alternates - no merge possible</span>
<a name="l00674"></a>00674           <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00675"></a>00675         ++fp1;
<a name="l00676"></a>00676         ++fp2;
<a name="l00677"></a>00677       }
<a name="l00678"></a>00678       <span class="comment">// Merging with the &apos;previous&apos; operationplan</span>
<a name="l00679"></a>00679       x-&gt;setQuantity(x-&gt;getQuantity() + o-&gt;getQuantity());
<a name="l00680"></a>00680       <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00681"></a>00681     }
<a name="l00682"></a>00682   }
<a name="l00683"></a>00683   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00684"></a>00684 }
<a name="l00685"></a>00685 
<a name="l00686"></a>00686 
<a name="l00687"></a>00687 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00123.html#aaa6f2f9a016a3af3db4d3703b0ef469f">OperationFixedTime::writeElement</a>
<a name="l00688"></a><a class="code" href="a00123.html#aaa6f2f9a016a3af3db4d3703b0ef469f">00688</a> (<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&amp; tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m) <span class="keyword">const</span>
<a name="l00689"></a>00689 {
<a name="l00690"></a>00690   <span class="comment">// Writing a reference</span>
<a name="l00691"></a>00691   <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>)
<a name="l00692"></a>00692   {
<a name="l00693"></a>00693     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>
<a name="l00694"></a>00694       (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l00695"></a>00695     <span class="keywordflow">return</span>;
<a name="l00696"></a>00696   }
<a name="l00697"></a>00697 
<a name="l00698"></a>00698   <span class="comment">// Write the complete object</span>
<a name="l00699"></a>00699   <span class="keywordflow">if</span> (m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>
<a name="l00700"></a>00700     (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l00701"></a>00701 
<a name="l00702"></a>00702   <span class="comment">// Write the fields</span>
<a name="l00703"></a>00703   <a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">Operation::writeElement</a>(o, tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>);
<a name="l00704"></a>00704   <span class="keywordflow">if</span> (duration) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a> (<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>, duration);
<a name="l00705"></a>00705   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a> (tag);
<a name="l00706"></a>00706 }
<a name="l00707"></a>00707 
<a name="l00708"></a>00708 
<a name="l00709"></a><a class="code" href="a00123.html#aa83d7a485466fa68f047cd9bcacb5bf7">00709</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00123.html#aa83d7a485466fa68f047cd9bcacb5bf7">OperationFixedTime::endElement</a> (<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>&amp; pElement)
<a name="l00710"></a>00710 {
<a name="l00711"></a>00711   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l00712"></a>00712     <a class="code" href="a00123.html#ab66256eb7de650cf65ad8d87ba2685ef">setDuration</a> (pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>());
<a name="l00713"></a>00713   <span class="keywordflow">else</span>
<a name="l00714"></a>00714     <a class="code" href="a00123.html#aa83d7a485466fa68f047cd9bcacb5bf7">Operation::endElement</a> (pIn, pAttr, pElement);
<a name="l00715"></a>00715 }
<a name="l00716"></a>00716 
<a name="l00717"></a>00717 
<a name="l00718"></a>00718 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>
<a name="l00719"></a>00719 <a class="code" href="a00130.html#afec0c7c63afb92c941b26c2d64736d66">OperationTimePer::setOperationPlanParameters</a>
<a name="l00720"></a><a class="code" href="a00130.html#afec0c7c63afb92c941b26c2d64736d66">00720</a> (<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, <span class="keywordtype">double</span> q, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> s, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> e, <span class="keywordtype">bool</span> preferEnd, <span class="keywordtype">bool</span> execute) <span class="keyword">const</span>
<a name="l00721"></a>00721 {
<a name="l00722"></a>00722   <span class="comment">// Invalid call to the function.</span>
<a name="l00723"></a>00723   <span class="keywordflow">if</span> (!opplan || q&lt;0)
<a name="l00724"></a>00724     <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Incorrect parameters for timeper operationplan&quot;</span>);
<a name="l00725"></a>00725   <span class="keywordflow">if</span> (opplan-&gt;<a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>())
<a name="l00726"></a>00726     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l00727"></a>00727 
<a name="l00728"></a>00728   <span class="comment">// Respect minimum and maximum size</span>
<a name="l00729"></a>00729   <span class="keywordflow">if</span> (q &gt; 0 &amp;&amp; q &lt; getSizeMinimum()) q = getSizeMinimum();
<a name="l00730"></a>00730   <span class="keywordflow">if</span> (q &gt; getSizeMaximum()) q = getSizeMaximum();
<a name="l00731"></a>00731 
<a name="l00732"></a>00732   <span class="comment">// The logic depends on which dates are being passed along</span>
<a name="l00733"></a>00733   <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> x;
<a name="l00734"></a>00734   <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> actual;
<a name="l00735"></a>00735   <span class="keywordflow">if</span> (s &amp;&amp; e)
<a name="l00736"></a>00736   {
<a name="l00737"></a>00737     <span class="comment">// Case 1: Both the start and end date are specified: Compute the quantity.</span>
<a name="l00738"></a>00738     <span class="comment">// Calculate the available time between those dates</span>
<a name="l00739"></a>00739     x = calculateOperationTime(s,e,&amp;actual);
<a name="l00740"></a>00740     <span class="keywordflow">if</span> (actual &lt; duration)
<a name="l00741"></a>00741     {
<a name="l00742"></a>00742       <span class="comment">// Start and end aren&apos;t far enough from each other to fit the constant</span>
<a name="l00743"></a>00743       <span class="comment">// part of the operation duration. This is infeasible.</span>
<a name="l00744"></a>00744       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x,0);
<a name="l00745"></a>00745       opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(0,<span class="keyword">true</span>,<span class="keyword">false</span>,execute);
<a name="l00746"></a>00746       opplan-&gt;<a class="code" href="a00125.html#af70f6b33dcda3739d1c090a632408cd4">setEnd</a>(e);  
<a name="l00747"></a>00747     }
<a name="l00748"></a>00748     <span class="keywordflow">else</span>
<a name="l00749"></a>00749     {
<a name="l00750"></a>00750       <span class="comment">// Calculate the quantity, respecting minimum, maximum and multiple size.</span>
<a name="l00751"></a>00751       <span class="keywordflow">if</span> (duration_per)
<a name="l00752"></a>00752       {
<a name="l00753"></a>00753         <span class="keywordflow">if</span> (q * duration_per &lt; static_cast&lt;double&gt;(actual - duration) + 1)
<a name="l00754"></a>00754           <span class="comment">// Provided quantity is acceptable.</span>
<a name="l00755"></a>00755           <span class="comment">// Note that we allow a margin of 1 second to accept.</span>
<a name="l00756"></a>00756           q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q, <span class="keyword">true</span>, <span class="keyword">false</span>, execute);
<a name="l00757"></a>00757         <span class="keywordflow">else</span>
<a name="l00758"></a>00758           <span class="comment">// Calculate the maximum operationplan that will fit in the window</span>
<a name="l00759"></a>00759           q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(
<a name="l00760"></a>00760             static_cast&lt;double&gt;(actual - duration) / duration_per, 
<a name="l00761"></a>00761             <span class="keyword">true</span>, <span class="keyword">false</span>, execute);
<a name="l00762"></a>00762       }
<a name="l00763"></a>00763       <span class="keywordflow">else</span>
<a name="l00764"></a>00764         <span class="comment">// No duration_per field given, so any quantity will go</span>
<a name="l00765"></a>00765         q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q, <span class="keyword">true</span>, <span class="keyword">false</span>, execute);
<a name="l00766"></a>00766 
<a name="l00767"></a>00767       <span class="comment">// Updates the dates</span>
<a name="l00768"></a>00768       <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> wanted(
<a name="l00769"></a>00769         duration + static_cast&lt;long&gt;(duration_per * q)
<a name="l00770"></a>00770         );
<a name="l00771"></a>00771       <span class="keywordflow">if</span> (preferEnd) x = calculateOperationTime(e, wanted, <span class="keyword">false</span>, &amp;actual);
<a name="l00772"></a>00772       <span class="keywordflow">else</span> x = calculateOperationTime(s, wanted, <span class="keyword">true</span>, &amp;actual);
<a name="l00773"></a>00773       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x,q);
<a name="l00774"></a>00774       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(x.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(),x.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>());
<a name="l00775"></a>00775     }
<a name="l00776"></a>00776   }
<a name="l00777"></a>00777   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (e || !s)
<a name="l00778"></a>00778   {
<a name="l00779"></a>00779     <span class="comment">// Case 2: Only an end date is specified. Respect the quantity and</span>
<a name="l00780"></a>00780     <span class="comment">// compute the start date</span>
<a name="l00781"></a>00781     <span class="comment">// Case 4: No date was given at all. Respect the quantity and the</span>
<a name="l00782"></a>00782     <span class="comment">// existing end date of the operationplan.</span>
<a name="l00783"></a>00783     q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q,<span class="keyword">true</span>,<span class="keyword">false</span>,execute); <span class="comment">// Round and size the quantity</span>
<a name="l00784"></a>00784     <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> wanted(duration + static_cast&lt;long&gt;(duration_per * q));
<a name="l00785"></a>00785     x = calculateOperationTime(e, wanted, <span class="keyword">false</span>, &amp;actual);
<a name="l00786"></a>00786     <span class="keywordflow">if</span> (actual == wanted)
<a name="l00787"></a>00787     {
<a name="l00788"></a>00788       <span class="comment">// Size is as desired</span>
<a name="l00789"></a>00789       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, q);
<a name="l00790"></a>00790       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(x.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(),x.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>());
<a name="l00791"></a>00791     }
<a name="l00792"></a>00792     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (actual &lt; duration)
<a name="l00793"></a>00793     {
<a name="l00794"></a>00794       <span class="comment">// Not feasible</span>
<a name="l00795"></a>00795       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, 0);
<a name="l00796"></a>00796       opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(0,<span class="keyword">true</span>,<span class="keyword">false</span>);
<a name="l00797"></a>00797       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(e,e);
<a name="l00798"></a>00798     }
<a name="l00799"></a>00799     <span class="keywordflow">else</span>
<a name="l00800"></a>00800     {
<a name="l00801"></a>00801       <span class="comment">// Resize the quantity to be feasible</span>
<a name="l00802"></a>00802       <span class="keywordtype">double</span> max_q = duration_per ?
<a name="l00803"></a>00803         <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(actual-duration) / duration_per :
<a name="l00804"></a>00804         q;
<a name="l00805"></a>00805       q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q &lt; max_q ? q : max_q, <span class="keyword">true</span>, <span class="keyword">false</span>, execute);
<a name="l00806"></a>00806       wanted = duration + <span class="keyword">static_cast&lt;</span><span class="keywordtype">long</span><span class="keyword">&gt;</span>(duration_per * q);
<a name="l00807"></a>00807       x = calculateOperationTime(e, wanted, <span class="keyword">false</span>, &amp;actual);
<a name="l00808"></a>00808       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, q);
<a name="l00809"></a>00809       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(x.getStart(),x.getEnd());
<a name="l00810"></a>00810     }
<a name="l00811"></a>00811   }
<a name="l00812"></a>00812   <span class="keywordflow">else</span>
<a name="l00813"></a>00813   {
<a name="l00814"></a>00814     <span class="comment">// Case 3: Only a start date is specified. Respect the quantity and</span>
<a name="l00815"></a>00815     <span class="comment">// compute the end date</span>
<a name="l00816"></a>00816     q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q,<span class="keyword">true</span>,<span class="keyword">false</span>,execute); <span class="comment">// Round and size the quantity</span>
<a name="l00817"></a>00817     <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> wanted(
<a name="l00818"></a>00818       duration + static_cast&lt;long&gt;(duration_per * q)
<a name="l00819"></a>00819       );
<a name="l00820"></a>00820     <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> actual;
<a name="l00821"></a>00821     x = calculateOperationTime(s, wanted, <span class="keyword">true</span>, &amp;actual);
<a name="l00822"></a>00822     <span class="keywordflow">if</span> (actual == wanted)
<a name="l00823"></a>00823     {
<a name="l00824"></a>00824       <span class="comment">// Size is as desired</span>
<a name="l00825"></a>00825       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, q);
<a name="l00826"></a>00826       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(x.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(),x.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>());
<a name="l00827"></a>00827     }
<a name="l00828"></a>00828     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (actual &lt; duration)
<a name="l00829"></a>00829     {
<a name="l00830"></a>00830       <span class="comment">// Not feasible</span>
<a name="l00831"></a>00831       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, 0);
<a name="l00832"></a>00832       opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(0,<span class="keyword">true</span>,<span class="keyword">false</span>);
<a name="l00833"></a>00833       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(s,s);
<a name="l00834"></a>00834     }
<a name="l00835"></a>00835     <span class="keywordflow">else</span>
<a name="l00836"></a>00836     {
<a name="l00837"></a>00837       <span class="comment">// Resize the quantity to be feasible</span>
<a name="l00838"></a>00838       <span class="keywordtype">double</span> max_q = duration_per ?
<a name="l00839"></a>00839         <span class="keyword">static_cast&lt;</span><span class="keywordtype">double</span><span class="keyword">&gt;</span>(actual-duration) / duration_per :
<a name="l00840"></a>00840         q;
<a name="l00841"></a>00841       q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q &lt; max_q ? q : max_q, <span class="keyword">true</span>, <span class="keyword">false</span>, execute);
<a name="l00842"></a>00842       wanted = duration + <span class="keyword">static_cast&lt;</span><span class="keywordtype">long</span><span class="keyword">&gt;</span>(duration_per * q);
<a name="l00843"></a>00843       x = calculateOperationTime(e, wanted, <span class="keyword">false</span>, &amp;actual);
<a name="l00844"></a>00844       <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, q);
<a name="l00845"></a>00845       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(x.getStart(),x.getEnd());
<a name="l00846"></a>00846     }
<a name="l00847"></a>00847   }
<a name="l00848"></a>00848 
<a name="l00849"></a>00849   <span class="comment">// Return value</span>
<a name="l00850"></a>00850   <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l00851"></a>00851 }
<a name="l00852"></a>00852 
<a name="l00853"></a>00853 
<a name="l00854"></a>00854 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00130.html#a3b99f67bf66dd84414770ce2ee8617a4">OperationTimePer::writeElement</a>
<a name="l00855"></a><a class="code" href="a00130.html#a3b99f67bf66dd84414770ce2ee8617a4">00855</a> (<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&amp; tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m) <span class="keyword">const</span>
<a name="l00856"></a>00856 {
<a name="l00857"></a>00857   <span class="comment">// Writing a reference</span>
<a name="l00858"></a>00858   <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>)
<a name="l00859"></a>00859   {
<a name="l00860"></a>00860     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>
<a name="l00861"></a>00861       (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l00862"></a>00862     <span class="keywordflow">return</span>;
<a name="l00863"></a>00863   }
<a name="l00864"></a>00864 
<a name="l00865"></a>00865   <span class="comment">// Write the complete object</span>
<a name="l00866"></a>00866   <span class="keywordflow">if</span> (m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>
<a name="l00867"></a>00867     (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l00868"></a>00868 
<a name="l00869"></a>00869   <span class="comment">// Write the complete object</span>
<a name="l00870"></a>00870   <a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">Operation::writeElement</a>(o, tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>);
<a name="l00871"></a>00871   o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>, duration);
<a name="l00872"></a>00872   o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#afdb7bb96906c802c415ff0952ca76d0b">Tags::tag_duration_per</a>, duration_per);
<a name="l00873"></a>00873   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag);
<a name="l00874"></a>00874 }
<a name="l00875"></a>00875 
<a name="l00876"></a>00876 
<a name="l00877"></a><a class="code" href="a00130.html#a19fb3f3759863a01b23df6566c602495">00877</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00130.html#a19fb3f3759863a01b23df6566c602495">OperationTimePer::endElement</a> (<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>&amp; pElement)
<a name="l00878"></a>00878 {
<a name="l00879"></a>00879   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l00880"></a>00880     <a class="code" href="a00130.html#ad21e39c7f989db95207963d9f04e1ed6">setDuration</a> (pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>());
<a name="l00881"></a>00881   <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#afdb7bb96906c802c415ff0952ca76d0b">Tags::tag_duration_per</a>))
<a name="l00882"></a>00882     <a class="code" href="a00130.html#a49d469ae1cafe9dcee7ffd9914b01aac">setDurationPer</a> (pElement.<a class="code" href="a00047.html#a41d128a13b3037cba281931330f7bdc1">getTimeperiod</a>());
<a name="l00883"></a>00883   <span class="keywordflow">else</span>
<a name="l00884"></a>00884     <a class="code" href="a00130.html#a19fb3f3759863a01b23df6566c602495">Operation::endElement</a> (pIn, pAttr, pElement);
<a name="l00885"></a>00885 }
<a name="l00886"></a>00886 
<a name="l00887"></a>00887 
<a name="l00888"></a>00888 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00128.html#a6b681054d10d974688b5a0d92ea4d5f7">OperationRouting::writeElement</a>
<a name="l00889"></a><a class="code" href="a00128.html#a6b681054d10d974688b5a0d92ea4d5f7">00889</a> (<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&amp; tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m) <span class="keyword">const</span>
<a name="l00890"></a>00890 {
<a name="l00891"></a>00891   <span class="comment">// Writing a reference</span>
<a name="l00892"></a>00892   <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>)
<a name="l00893"></a>00893   {
<a name="l00894"></a>00894     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>
<a name="l00895"></a>00895       (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l00896"></a>00896     <span class="keywordflow">return</span>;
<a name="l00897"></a>00897   }
<a name="l00898"></a>00898 
<a name="l00899"></a>00899   <span class="comment">// Write the complete object</span>
<a name="l00900"></a>00900   <span class="keywordflow">if</span> (m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>
<a name="l00901"></a>00901     (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l00902"></a>00902 
<a name="l00903"></a>00903   <span class="comment">// Write the fields</span>
<a name="l00904"></a>00904   <a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">Operation::writeElement</a>(o, tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>);
<a name="l00905"></a>00905   <span class="keywordflow">if</span> (steps.size())
<a name="l00906"></a>00906   {
<a name="l00907"></a>00907     o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(<a class="code" href="a00177.html#a8d66ef09f0794d06a1cd24c9fe7a6343">Tags::tag_steps</a>);
<a name="l00908"></a>00908     <span class="keywordflow">for</span> (Operationlist::const_iterator i = steps.begin(); i!=steps.end(); ++i)
<a name="l00909"></a>00909       o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>, *i, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>);
<a name="l00910"></a>00910     o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(<a class="code" href="a00177.html#a8d66ef09f0794d06a1cd24c9fe7a6343">Tags::tag_steps</a>);
<a name="l00911"></a>00911   }
<a name="l00912"></a>00912   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag);
<a name="l00913"></a>00913 }
<a name="l00914"></a>00914 
<a name="l00915"></a>00915 
<a name="l00916"></a><a class="code" href="a00128.html#aaf6ac7b995513f4f4590f656e372aeb8">00916</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00128.html#aaf6ac7b995513f4f4590f656e372aeb8">OperationRouting::beginElement</a>(<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr)
<a name="l00917"></a>00917 {
<a name="l00918"></a>00918   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>))
<a name="l00919"></a>00919     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="l00920"></a>00920   <span class="keywordflow">else</span>
<a name="l00921"></a>00921     <a class="code" href="a00128.html#aaf6ac7b995513f4f4590f656e372aeb8">Operation::beginElement</a>(pIn, pAttr);
<a name="l00922"></a>00922 }
<a name="l00923"></a>00923 
<a name="l00924"></a>00924 
<a name="l00925"></a><a class="code" href="a00128.html#a17ba27923c4f9e18199c48a9e4c7c980">00925</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00128.html#a17ba27923c4f9e18199c48a9e4c7c980">OperationRouting::endElement</a> (<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>&amp; pElement)
<a name="l00926"></a>00926 {
<a name="l00927"></a>00927   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>)
<a name="l00928"></a>00928       &amp;&amp; pIn.<a class="code" href="a00186.html#a407522e9d0dde7f7eebfafe182d050cf">getParentElement</a>().first.isA(<a class="code" href="a00177.html#a8d66ef09f0794d06a1cd24c9fe7a6343">Tags::tag_steps</a>))
<a name="l00929"></a>00929   {
<a name="l00930"></a>00930     <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a> *oper = <span class="keyword">dynamic_cast&lt;</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">&gt;</span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>());
<a name="l00931"></a>00931     <span class="keywordflow">if</span> (oper) <a class="code" href="a00128.html#ab32a4a3eb91accc121cc95c56044cc0c">addStepBack</a> (oper);
<a name="l00932"></a>00932     <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">&quot;Incorrect object type during read operation&quot;</span>);
<a name="l00933"></a>00933   }
<a name="l00934"></a>00934   <a class="code" href="a00128.html#a17ba27923c4f9e18199c48a9e4c7c980">Operation::endElement</a> (pIn, pAttr, pElement);
<a name="l00935"></a>00935 }
<a name="l00936"></a>00936 
<a name="l00937"></a>00937 
<a name="l00938"></a>00938 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a> <a class="code" href="a00128.html#a0c888f038ba3135b8987f894f9b61537">OperationRouting::setOperationPlanParameters</a>
<a name="l00939"></a><a class="code" href="a00128.html#a0c888f038ba3135b8987f894f9b61537">00939</a> (<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, <span class="keywordtype">double</span> q, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> s, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> e, <span class="keywordtype">bool</span> preferEnd, <span class="keywordtype">bool</span> execute) <span class="keyword">const</span>
<a name="l00940"></a>00940 {
<a name="l00941"></a>00941   <span class="comment">// Invalid call to the function</span>
<a name="l00942"></a>00942   <span class="keywordflow">if</span> (!opplan || q&lt;0)
<a name="l00943"></a>00943     <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Incorrect parameters for routing operationplan&quot;</span>);
<a name="l00944"></a>00944   <span class="keywordflow">if</span> (opplan-&gt;<a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>())
<a name="l00945"></a>00945     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l00946"></a>00946 
<a name="l00947"></a>00947   <span class="keywordflow">if</span> (!opplan-&gt;lastsubopplan || opplan-&gt;lastsubopplan-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>() == <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>) <span class="comment">// @todo replace with proper iterator</span>
<a name="l00948"></a>00948   {
<a name="l00949"></a>00949     <span class="comment">// No step operationplans to work with. Just apply the requested quantity</span>
<a name="l00950"></a>00950     <span class="comment">// and dates.</span>
<a name="l00951"></a>00951     q = opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q,<span class="keyword">false</span>,<span class="keyword">false</span>,execute);
<a name="l00952"></a>00952     <span class="keywordflow">if</span> (!s &amp;&amp; e) s = e;
<a name="l00953"></a>00953     <span class="keywordflow">if</span> (s &amp;&amp; !e) e = s;
<a name="l00954"></a>00954     <span class="keywordflow">if</span> (!execute) <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(s, e, q);
<a name="l00955"></a>00955     opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(s,e);
<a name="l00956"></a>00956     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l00957"></a>00957   }
<a name="l00958"></a>00958 
<a name="l00959"></a>00959   <span class="comment">// Behavior depends on the dates being passed.</span>
<a name="l00960"></a>00960   <span class="comment">// Move all sub-operationplans in an orderly fashion, either starting from</span>
<a name="l00961"></a>00961   <span class="comment">// the specified end date or the specified start date.</span>
<a name="l00962"></a>00962   <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a> x;
<a name="l00963"></a>00963   <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> y;
<a name="l00964"></a>00964   <span class="keywordtype">bool</span> realfirst = <span class="keyword">true</span>;
<a name="l00965"></a>00965   <span class="keywordflow">if</span> (e)
<a name="l00966"></a>00966   {
<a name="l00967"></a>00967     <span class="comment">// Case 1: an end date is specified</span>
<a name="l00968"></a>00968     <span class="keywordflow">for</span> (<a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a>* i = opplan-&gt;lastsubopplan; i; i = i-&gt;prevsubopplan)
<a name="l00969"></a>00969     {
<a name="l00970"></a>00970       <span class="keywordflow">if</span> (i-&gt;getOperation() == <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>) <span class="keywordflow">continue</span>;
<a name="l00971"></a>00971       x = i-&gt;getOperation()-&gt;setOperationPlanParameters(i,q,Date::infinitePast,e,preferEnd,execute);
<a name="l00972"></a>00972       e = x.<a class="code" href="a00127.html#adc56f9e1f5ddccca5f50c50229e18c27">start</a>;
<a name="l00973"></a>00973       <span class="keywordflow">if</span> (realfirst) 
<a name="l00974"></a>00974       {
<a name="l00975"></a>00975         y = x.<a class="code" href="a00127.html#ab641b640c894007052c4207d353a1f5b">end</a>;
<a name="l00976"></a>00976         realfirst = <span class="keyword">false</span>;
<a name="l00977"></a>00977       }
<a name="l00978"></a>00978     }
<a name="l00979"></a>00979     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x.<a class="code" href="a00127.html#adc56f9e1f5ddccca5f50c50229e18c27">start</a>, y, x.<a class="code" href="a00127.html#aae1454106ec8147edd0eb7f6e5f647d7">quantity</a>);
<a name="l00980"></a>00980   }
<a name="l00981"></a>00981   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (s)
<a name="l00982"></a>00982   {
<a name="l00983"></a>00983     <span class="comment">// Case 2: a start date is specified</span>
<a name="l00984"></a>00984     <span class="keywordflow">for</span> (<a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a> *i = opplan-&gt;firstsubopplan; i; i = i-&gt;nextsubopplan)
<a name="l00985"></a>00985     {
<a name="l00986"></a>00986       <span class="keywordflow">if</span> (i-&gt;getOperation() == <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>) <span class="keywordflow">continue</span>;
<a name="l00987"></a>00987       x = i-&gt;getOperation()-&gt;setOperationPlanParameters(i,q,s,Date::infinitePast,preferEnd,execute);
<a name="l00988"></a>00988       s = x.<a class="code" href="a00127.html#ab641b640c894007052c4207d353a1f5b">end</a>;
<a name="l00989"></a>00989       <span class="keywordflow">if</span> (realfirst)
<a name="l00990"></a>00990       {
<a name="l00991"></a>00991         y = x.<a class="code" href="a00127.html#adc56f9e1f5ddccca5f50c50229e18c27">start</a>;
<a name="l00992"></a>00992         realfirst = <span class="keyword">false</span>;
<a name="l00993"></a>00993       }
<a name="l00994"></a>00994     }
<a name="l00995"></a>00995     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(y, x.<a class="code" href="a00127.html#ab641b640c894007052c4207d353a1f5b">end</a>, x.<a class="code" href="a00127.html#aae1454106ec8147edd0eb7f6e5f647d7">quantity</a>);
<a name="l00996"></a>00996   }
<a name="l00997"></a>00997   <span class="keywordflow">else</span>
<a name="l00998"></a>00998     <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>(
<a name="l00999"></a>00999       <span class="stringliteral">&quot;Updating a routing operationplan without start or end date argument&quot;</span>
<a name="l01000"></a>01000     );
<a name="l01001"></a>01001 }
<a name="l01002"></a>01002 
<a name="l01003"></a>01003 
<a name="l01004"></a><a class="code" href="a00128.html#a94629eb8c0ea5f23bc616998a2864324">01004</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">bool</span> <a class="code" href="a00128.html#a94629eb8c0ea5f23bc616998a2864324">OperationRouting::extraInstantiate</a>(<a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a>* o)
<a name="l01005"></a>01005 {
<a name="l01006"></a>01006   <span class="comment">// Create step suboperationplans if they don&apos;t exist yet.</span>
<a name="l01007"></a>01007   <span class="keywordflow">if</span> (!o-&gt;lastsubopplan || o-&gt;lastsubopplan-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>() == <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>)
<a name="l01008"></a>01008   {
<a name="l01009"></a>01009     <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> d = o-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>();
<a name="l01010"></a>01010     <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a> *p = NULL;
<a name="l01011"></a>01011     <span class="comment">// @todo not possible to initialize a routing oplan based on a start date</span>
<a name="l01012"></a>01012     <span class="keywordflow">if</span> (d != Date::infiniteFuture)
<a name="l01013"></a>01013     {
<a name="l01014"></a>01014       <span class="comment">// Using the end date</span>
<a name="l01015"></a>01015       <span class="keywordflow">for</span> (Operation::Operationlist::const_reverse_iterator e =
<a name="l01016"></a>01016             <a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().rbegin(); e != <a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().rend(); ++e)
<a name="l01017"></a>01017       {
<a name="l01018"></a>01018         p = (*e)-&gt;<a class="code" href="a00125.html#acabc6d5f06b157c155355d04b3e2e4ef">createOperationPlan</a>(o-&gt;<a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>(), Date::infinitePast,
<a name="l01019"></a>01019             d, NULL, o, 0, <span class="keyword">true</span>);
<a name="l01020"></a>01020         d = p-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>();
<a name="l01021"></a>01021       }
<a name="l01022"></a>01022     }
<a name="l01023"></a>01023     <span class="keywordflow">else</span>
<a name="l01024"></a>01024     {
<a name="l01025"></a>01025       <span class="comment">// Using the start date when there is no end date</span>
<a name="l01026"></a>01026       d = o-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>();
<a name="l01027"></a>01027       <span class="comment">// Using the current date when both the start and end date are missing</span>
<a name="l01028"></a>01028       <span class="keywordflow">if</span> (!d) d = <a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>().<a class="code" href="a00132.html#a6a07002deb9c4f380a54a3e3465e487b">getCurrent</a>();
<a name="l01029"></a>01029       <span class="keywordflow">for</span> (Operation::Operationlist::const_iterator e =
<a name="l01030"></a>01030             <a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>(); e != <a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().end(); ++e)
<a name="l01031"></a>01031       {
<a name="l01032"></a>01032         p = (*e)-&gt;<a class="code" href="a00125.html#acabc6d5f06b157c155355d04b3e2e4ef">createOperationPlan</a>(o-&gt;<a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>(), d,
<a name="l01033"></a>01033             Date::infinitePast, NULL, o, 0, <span class="keyword">true</span>);
<a name="l01034"></a>01034         d = p-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>();
<a name="l01035"></a>01035       }
<a name="l01036"></a>01036     }
<a name="l01037"></a>01037   }
<a name="l01038"></a>01038   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01039"></a>01039 }
<a name="l01040"></a>01040 
<a name="l01041"></a>01041 
<a name="l01042"></a>01042 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00256.html#aa439ebf4ddfb4983ac3d44abacb9b749">SearchMode</a> <a class="code" href="a00256.html#ad2ba94b6dd8b668fa920837e6c73c13d">decodeSearchMode</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; c)
<a name="l01043"></a>01043 {
<a name="l01044"></a>01044   <span class="keywordflow">if</span> (c == <span class="stringliteral">&quot;PRIORITY&quot;</span>) <span class="keywordflow">return</span> <a class="code" href="a00256.html#aa439ebf4ddfb4983ac3d44abacb9b749a20f9fef00fcbc3cd9fbd27a8a41c1d83">PRIORITY</a>;
<a name="l01045"></a>01045   <span class="keywordflow">if</span> (c == <span class="stringliteral">&quot;MINCOST&quot;</span>) <span class="keywordflow">return</span> <a class="code" href="a00256.html#aa439ebf4ddfb4983ac3d44abacb9b749ad9914aabe4dd320523d45a0a647dec6e">MINCOST</a>;
<a name="l01046"></a>01046   <span class="keywordflow">if</span> (c == <span class="stringliteral">&quot;MINPENALTY&quot;</span>) <span class="keywordflow">return</span> <a class="code" href="a00256.html#aa439ebf4ddfb4983ac3d44abacb9b749aa0b35fa57d0c5ce3728116ed47f06ca9">MINPENALTY</a>;
<a name="l01047"></a>01047   <span class="keywordflow">if</span> (c == <span class="stringliteral">&quot;MINCOSTPENALTY&quot;</span>) <span class="keywordflow">return</span> <a class="code" href="a00256.html#aa439ebf4ddfb4983ac3d44abacb9b749acffaea7c05036f503a543806f02f51d1">MINCOSTPENALTY</a>;
<a name="l01048"></a>01048   <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Invalid search mode &quot;</span> + c);
<a name="l01049"></a>01049 }
<a name="l01050"></a>01050 
<a name="l01051"></a>01051 
<a name="l01052"></a>01052 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00122.html#accd0dc05a16c25a96b3fad2c22834ccc">OperationAlternate::addAlternate</a>
<a name="l01053"></a><a class="code" href="a00122.html#accd0dc05a16c25a96b3fad2c22834ccc">01053</a>   (<a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>* o, <span class="keywordtype">int</span> prio, <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> eff)
<a name="l01054"></a>01054 {
<a name="l01055"></a>01055   <span class="keywordflow">if</span> (!o) <span class="keywordflow">return</span>;
<a name="l01056"></a>01056   Operationlist::iterator altIter = alternates.begin();
<a name="l01057"></a>01057   alternatePropertyList::iterator propIter = alternateProperties.begin();
<a name="l01058"></a>01058   <span class="keywordflow">while</span> (altIter!=alternates.end() &amp;&amp; prio &gt;= propIter-&gt;first)
<a name="l01059"></a>01059   {
<a name="l01060"></a>01060     ++propIter;
<a name="l01061"></a>01061     ++altIter;
<a name="l01062"></a>01062   }
<a name="l01063"></a>01063   alternateProperties.insert(propIter,alternateProperty(prio,eff));
<a name="l01064"></a>01064   alternates.insert(altIter,o);
<a name="l01065"></a>01065   o-&gt;<a class="code" href="a00121.html#a0a41514b52fc52172c2899f2ae931701">addSuperOperation</a>(<span class="keyword">this</span>);
<a name="l01066"></a>01066 }
<a name="l01067"></a>01067 
<a name="l01068"></a>01068 
<a name="l01069"></a>01069 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> <a class="code" href="a00122.html#a21276a85b32a20ee590af9e02445d5f8">OperationAlternate::alternateProperty</a>&amp;
<a name="l01070"></a><a class="code" href="a00122.html#afa54c209215c9841187cecfb0c9e2808">01070</a>   <a class="code" href="a00122.html#afa54c209215c9841187cecfb0c9e2808">OperationAlternate::getProperties</a>(<a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>* o)<span class="keyword"> const</span>
<a name="l01071"></a>01071 <span class="keyword"></span>{
<a name="l01072"></a>01072   <span class="keywordflow">if</span> (!o)
<a name="l01073"></a>01073     <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Null pointer passed when searching for a \</span>
<a name="l01074"></a>01074 <span class="stringliteral">        suboperation of alternate operation &apos;&quot;</span> + <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l01075"></a>01075   Operationlist::const_iterator altIter = alternates.begin();
<a name="l01076"></a>01076   alternatePropertyList::const_iterator propIter = alternateProperties.begin();
<a name="l01077"></a>01077   <span class="keywordflow">while</span> (altIter!=alternates.end() &amp;&amp; *altIter != o)
<a name="l01078"></a>01078   {
<a name="l01079"></a>01079     ++propIter;
<a name="l01080"></a>01080     ++altIter;
<a name="l01081"></a>01081   }
<a name="l01082"></a>01082   <span class="keywordflow">if</span> (*altIter == o) <span class="keywordflow">return</span> *propIter;
<a name="l01083"></a>01083   <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Operation &apos;&quot;</span> + o-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() +
<a name="l01084"></a>01084       <span class="stringliteral">&quot;&apos; isn&apos;t a suboperation of alternate operation &apos;&quot;</span> + <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l01085"></a>01085 }
<a name="l01086"></a>01086 
<a name="l01087"></a>01087 
<a name="l01088"></a><a class="code" href="a00122.html#a552b0c104bec99d2bdeb153cf7189b8d">01088</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00122.html#a552b0c104bec99d2bdeb153cf7189b8d">OperationAlternate::setPriority</a>(<a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>* o, <span class="keywordtype">int</span> f)
<a name="l01089"></a>01089 {
<a name="l01090"></a>01090   <span class="keywordflow">if</span> (!o) <span class="keywordflow">return</span>;
<a name="l01091"></a>01091   Operationlist::const_iterator altIter = alternates.begin();
<a name="l01092"></a>01092   alternatePropertyList::iterator propIter = alternateProperties.begin();
<a name="l01093"></a>01093   <span class="keywordflow">while</span> (altIter!=alternates.end() &amp;&amp; *altIter != o)
<a name="l01094"></a>01094   {
<a name="l01095"></a>01095     ++propIter;
<a name="l01096"></a>01096     ++altIter;
<a name="l01097"></a>01097   }
<a name="l01098"></a>01098   <span class="keywordflow">if</span> (*altIter == o)
<a name="l01099"></a>01099     propIter-&gt;first = f;
<a name="l01100"></a>01100   <span class="keywordflow">else</span>
<a name="l01101"></a>01101     <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Operation &apos;&quot;</span> + o-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() +
<a name="l01102"></a>01102         <span class="stringliteral">&quot;&apos; isn&apos;t a suboperation of alternate operation &apos;&quot;</span> + <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l01103"></a>01103 }
<a name="l01104"></a>01104 
<a name="l01105"></a>01105 
<a name="l01106"></a><a class="code" href="a00122.html#ac5c3ebcb02f8d7b61ec15f2c0318c3c5">01106</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00122.html#ac5c3ebcb02f8d7b61ec15f2c0318c3c5">OperationAlternate::setEffective</a>(<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="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> dr)
<a name="l01107"></a>01107 {
<a name="l01108"></a>01108   <span class="keywordflow">if</span> (!o) <span class="keywordflow">return</span>;
<a name="l01109"></a>01109   Operationlist::const_iterator altIter = alternates.begin();
<a name="l01110"></a>01110   alternatePropertyList::iterator propIter = alternateProperties.begin();
<a name="l01111"></a>01111   <span class="keywordflow">while</span> (altIter!=alternates.end() &amp;&amp; *altIter != o)
<a name="l01112"></a>01112   {
<a name="l01113"></a>01113     ++propIter;
<a name="l01114"></a>01114     ++altIter;
<a name="l01115"></a>01115   }
<a name="l01116"></a>01116   <span class="keywordflow">if</span> (*altIter == o)
<a name="l01117"></a>01117     propIter-&gt;second = dr;
<a name="l01118"></a>01118   <span class="keywordflow">else</span>
<a name="l01119"></a>01119     <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Operation &apos;&quot;</span> + o-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() +
<a name="l01120"></a>01120         <span class="stringliteral">&quot;&apos; isn&apos;t a suboperation of alternate operation &apos;&quot;</span> + <a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l01121"></a>01121 }
<a name="l01122"></a>01122 
<a name="l01123"></a>01123 
<a name="l01124"></a>01124 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00122.html#abc8519120ca9ff5e0be1a65131751a09">OperationAlternate::writeElement</a>
<a name="l01125"></a><a class="code" href="a00122.html#abc8519120ca9ff5e0be1a65131751a09">01125</a> (<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>&amp; tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m) <span class="keyword">const</span>
<a name="l01126"></a>01126 {
<a name="l01127"></a>01127   <span class="comment">// Writing a reference</span>
<a name="l01128"></a>01128   <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>)
<a name="l01129"></a>01129   {
<a name="l01130"></a>01130     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>
<a name="l01131"></a>01131       (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l01132"></a>01132     <span class="keywordflow">return</span>;
<a name="l01133"></a>01133   }
<a name="l01134"></a>01134 
<a name="l01135"></a>01135   <span class="comment">// Write the complete object</span>
<a name="l01136"></a>01136   <span class="keywordflow">if</span> (m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>) o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>
<a name="l01137"></a>01137     (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="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">type</a>);
<a name="l01138"></a>01138 
<a name="l01139"></a>01139   <span class="comment">// Write the standard fields</span>
<a name="l01140"></a>01140   <a class="code" href="a00121.html#a3db91252184523fa8246064446d56b60">Operation::writeElement</a>(o, tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>);
<a name="l01141"></a>01141   <span class="keywordflow">if</span> (search != <a class="code" href="a00256.html#aa439ebf4ddfb4983ac3d44abacb9b749a20f9fef00fcbc3cd9fbd27a8a41c1d83">PRIORITY</a>)
<a name="l01142"></a>01142     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a0364c7fc29b0d795dfa1624947efd387">Tags::tag_search</a>, search);
<a name="l01143"></a>01143 
<a name="l01144"></a>01144   <span class="comment">// Write the extra fields</span>
<a name="l01145"></a>01145   o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(<a class="code" href="a00177.html#a1db462103ca0f7689146070b09e0d903">Tags::tag_alternates</a>);
<a name="l01146"></a>01146   alternatePropertyList::const_iterator propIter = alternateProperties.begin();
<a name="l01147"></a>01147   <span class="keywordflow">for</span> (Operationlist::const_iterator i = alternates.begin();
<a name="l01148"></a>01148       i != alternates.end(); ++i)
<a name="l01149"></a>01149   {
<a name="l01150"></a>01150     o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>);
<a name="l01151"></a>01151     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>, *i, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>);
<a name="l01152"></a>01152     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>, propIter-&gt;first);
<a name="l01153"></a>01153     <span class="keywordflow">if</span> (propIter-&gt;second.getStart() != Date::infinitePast)
<a name="l01154"></a>01154       o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ae1f2e352a23d5deaddd90a377e1980cd">Tags::tag_effective_start</a>, propIter-&gt;second.getStart());
<a name="l01155"></a>01155     <span class="keywordflow">if</span> (propIter-&gt;second.getEnd() != Date::infiniteFuture)
<a name="l01156"></a>01156       o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a0bd36aad5b52bb4ec75d969fe351f583">Tags::tag_effective_end</a>, propIter-&gt;second.getEnd());
<a name="l01157"></a>01157     o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a> (<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>);
<a name="l01158"></a>01158     ++propIter;
<a name="l01159"></a>01159   }
<a name="l01160"></a>01160   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(<a class="code" href="a00177.html#a1db462103ca0f7689146070b09e0d903">Tags::tag_alternates</a>);
<a name="l01161"></a>01161 
<a name="l01162"></a>01162   <span class="comment">// Ending tag</span>
<a name="l01163"></a>01163   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag);
<a name="l01164"></a>01164 }
<a name="l01165"></a>01165 
<a name="l01166"></a>01166 
<a name="l01167"></a><a class="code" href="a00122.html#a21d641b55fcac1c0be9e52df180056c9">01167</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00122.html#a21d641b55fcac1c0be9e52df180056c9">OperationAlternate::beginElement</a>(<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr)
<a name="l01168"></a>01168 {
<a name="l01169"></a>01169   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>))
<a name="l01170"></a>01170     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="l01171"></a>01171   <span class="keywordflow">else</span>
<a name="l01172"></a>01172     <a class="code" href="a00122.html#a21d641b55fcac1c0be9e52df180056c9">Operation::beginElement</a>(pIn, pAttr);
<a name="l01173"></a>01173 }
<a name="l01174"></a>01174 
<a name="l01175"></a>01175 
<a name="l01176"></a><a class="code" href="a00122.html#aa1a730f69090603825c925e332491b4c">01176</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00122.html#aa1a730f69090603825c925e332491b4c">OperationAlternate::endElement</a> (<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>&amp; pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>&amp; pElement)
<a name="l01177"></a>01177 {
<a name="l01178"></a>01178   <span class="comment">// Saving some typing...</span>
<a name="l01179"></a>01179   <span class="keyword">typedef</span> pair&lt;Operation*,alternateProperty&gt; tempData;
<a name="l01180"></a>01180 
<a name="l01181"></a>01181   <span class="comment">// Create a temporary object</span>
<a name="l01182"></a>01182   <span class="keywordflow">if</span> (!pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>())
<a name="l01183"></a>01183     pIn.<a class="code" href="a00186.html#af76fa6f3fe40bd167a36b4ab859e0ff6">setUserArea</a>(<span class="keyword">new</span> tempData(static_cast&lt;Operation*&gt;(NULL),<a class="code" href="a00122.html#a21276a85b32a20ee590af9e02445d5f8">alternateProperty</a>(1,<a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a>())));
<a name="l01184"></a>01184   tempData* tmp = <span class="keyword">static_cast&lt;</span>tempData*<span class="keyword">&gt;</span>(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>());
<a name="l01185"></a>01185 
<a name="l01186"></a>01186   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>))
<a name="l01187"></a>01187   {
<a name="l01188"></a>01188     <a class="code" href="a00122.html#accd0dc05a16c25a96b3fad2c22834ccc">addAlternate</a>(tmp-&gt;first, tmp-&gt;second.first, tmp-&gt;second.second);
<a name="l01189"></a>01189     <span class="comment">// Reset the defaults</span>
<a name="l01190"></a>01190     tmp-&gt;first = NULL;
<a name="l01191"></a>01191     tmp-&gt;second.first = 1;
<a name="l01192"></a>01192     tmp-&gt;second.second = <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a>();
<a name="l01193"></a>01193   }
<a name="l01194"></a>01194   <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#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>))
<a name="l01195"></a>01195     tmp-&gt;second.first = pElement.<a class="code" href="a00047.html#a0d8c973cc584400f5ea5d8acfd82ace2">getInt</a>();
<a name="l01196"></a>01196   <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#a0364c7fc29b0d795dfa1624947efd387">Tags::tag_search</a>))
<a name="l01197"></a>01197     <a class="code" href="a00122.html#a59b4283e24286d5b9d19671379eb4ecf">setSearch</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>());
<a name="l01198"></a>01198   <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#ae1f2e352a23d5deaddd90a377e1980cd">Tags::tag_effective_start</a>))
<a name="l01199"></a>01199     tmp-&gt;second.second.setStart(pElement.<a class="code" href="a00047.html#abe8c2019e5f79328a6a1fa1f3bb4bbae">getDate</a>());
<a name="l01200"></a>01200   <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#a0bd36aad5b52bb4ec75d969fe351f583">Tags::tag_effective_end</a>))
<a name="l01201"></a>01201     tmp-&gt;second.second.setEnd(pElement.<a class="code" href="a00047.html#abe8c2019e5f79328a6a1fa1f3bb4bbae">getDate</a>());
<a name="l01202"></a>01202   <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#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>)
<a name="l01203"></a>01203       &amp;&amp; pIn.<a class="code" href="a00186.html#a407522e9d0dde7f7eebfafe182d050cf">getParentElement</a>().first.isA(<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>))
<a name="l01204"></a>01204   {
<a name="l01205"></a>01205     <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&lt;</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">&gt;</span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>());
<a name="l01206"></a>01206     <span class="keywordflow">if</span> (b) tmp-&gt;first = b;
<a name="l01207"></a>01207     <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">&quot;Incorrect object type during read operation&quot;</span>);
<a name="l01208"></a>01208   }
<a name="l01209"></a>01209   <a class="code" href="a00122.html#aa1a730f69090603825c925e332491b4c">Operation::endElement</a> (pIn, pAttr, pElement);
<a name="l01210"></a>01210 
<a name="l01211"></a>01211   <span class="comment">// Delete the temporary object</span>
<a name="l01212"></a>01212   <span class="keywordflow">if</span> (pIn.<a class="code" href="a00186.html#a42fe5e4ae141efb84744b8a359e38bd9">isObjectEnd</a>()) <span class="keyword">delete</span> static_cast&lt;tempData*&gt;(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>());
<a name="l01213"></a>01213 }
<a name="l01214"></a>01214 
<a name="l01215"></a>01215 
<a name="l01216"></a>01216 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>
<a name="l01217"></a>01217 <a class="code" href="a00122.html#affd8bc828a150f258619aec11c4559b0">OperationAlternate::setOperationPlanParameters</a>
<a name="l01218"></a><a class="code" href="a00122.html#affd8bc828a150f258619aec11c4559b0">01218</a>   (<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, <span class="keywordtype">double</span> q, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> s, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> e, <span class="keywordtype">bool</span> preferEnd,
<a name="l01219"></a>01219   <span class="keywordtype">bool</span> execute) <span class="keyword">const</span>
<a name="l01220"></a>01220 {
<a name="l01221"></a>01221   <span class="comment">// Invalid calls to this function</span>
<a name="l01222"></a>01222   <span class="keywordflow">if</span> (!opplan || q&lt;0)
<a name="l01223"></a>01223     <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Incorrect parameters for alternate operationplan&quot;</span>);
<a name="l01224"></a>01224   <span class="keywordflow">if</span> (opplan-&gt;<a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>())
<a name="l01225"></a>01225     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l01226"></a>01226 
<a name="l01227"></a>01227   <a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a> *x = opplan-&gt;lastsubopplan;
<a name="l01228"></a>01228   <span class="keywordflow">while</span> (x &amp;&amp; x-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>() == <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>) 
<a name="l01229"></a>01229     x = x-&gt;prevsubopplan;
<a name="l01230"></a>01230   if (!x)
<a name="l01231"></a>01231   {
<a name="l01232"></a>01232     <span class="comment">// Blindly accept the parameters if there is no suboperationplan</span>
<a name="l01233"></a>01233     <span class="keywordflow">if</span> (execute)
<a name="l01234"></a>01234     {
<a name="l01235"></a>01235       opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q,<span class="keyword">false</span>,<span class="keyword">false</span>);
<a name="l01236"></a>01236       opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(s, e);
<a name="l01237"></a>01237       <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l01238"></a>01238     }
<a name="l01239"></a>01239     <span class="keywordflow">else</span>
<a name="l01240"></a>01240       <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(s, e, opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(q,<span class="keyword">false</span>,<span class="keyword">false</span>,<span class="keyword">false</span>));
<a name="l01241"></a>01241   }
<a name="l01242"></a>01242   <span class="keywordflow">else</span>
<a name="l01243"></a>01243     <span class="comment">// Pass the call to the sub-operation</span>
<a name="l01244"></a>01244     <span class="keywordflow">return</span> x-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>()
<a name="l01245"></a>01245       -&gt;<a class="code" href="a00121.html#a744480cdd80e70a2b0a7606114e1ab73">setOperationPlanParameters</a>(x,q,s,e,preferEnd, execute);
<a name="l01246"></a>01246 }
<a name="l01247"></a>01247 
<a name="l01248"></a>01248 
<a name="l01249"></a><a class="code" href="a00122.html#a76ab3ec452cd87b5a3bc72af13454458">01249</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">bool</span> <a class="code" href="a00122.html#a76ab3ec452cd87b5a3bc72af13454458">OperationAlternate::extraInstantiate</a>(<a class="code" href="a00125.html" title="An operationplan is the key dynamic element of a plan. It represents a certain quantity...">OperationPlan</a>* o)
<a name="l01250"></a>01250 {
<a name="l01251"></a>01251   <span class="comment">// Create a suboperationplan if one doesn&apos;t exist yet.</span>
<a name="l01252"></a>01252   <span class="comment">// We use the first effective alternate by default.</span>
<a name="l01253"></a>01253   <span class="keywordflow">if</span> (!o-&gt;lastsubopplan || o-&gt;lastsubopplan-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>() == <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>)
<a name="l01254"></a>01254   {
<a name="l01255"></a>01255     <span class="comment">// Find the right operation</span>
<a name="l01256"></a>01256     Operationlist::const_iterator altIter = <a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().begin();
<a name="l01257"></a>01257     <span class="keywordflow">for</span> (; altIter != <a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().end(); )
<a name="l01258"></a>01258     {
<a name="l01259"></a>01259       <span class="keyword">const</span> <a class="code" href="a00122.html#a21276a85b32a20ee590af9e02445d5f8">OperationAlternate::alternateProperty</a>&amp; props = <a class="code" href="a00122.html#afa54c209215c9841187cecfb0c9e2808">getProperties</a>(*altIter);
<a name="l01260"></a>01260       <span class="comment">// Filter out alternates that are not suitable</span>
<a name="l01261"></a>01261       <span class="keywordflow">if</span> (props.first != 0.0 &amp;&amp; props.second.within(o-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>()))
<a name="l01262"></a>01262         <span class="keywordflow">break</span>;
<a name="l01263"></a>01263     }
<a name="l01264"></a>01264     <span class="keywordflow">if</span> (altIter != <a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().end())
<a name="l01265"></a>01265       <span class="comment">// Create an operationplan instance</span>
<a name="l01266"></a>01266       (*altIter)-&gt;createOperationPlan(
<a name="l01267"></a>01267         o-&gt;<a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>(), o-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(),
<a name="l01268"></a>01268         o-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>(), NULL, o, 0, <span class="keyword">true</span>);
<a name="l01269"></a>01269   }
<a name="l01270"></a>01270   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l01271"></a>01271 }
<a name="l01272"></a>01272 
<a name="l01273"></a>01273 
<a name="l01274"></a><a class="code" href="a00122.html#a8067158022e2bd145cc9dad06c4e685b">01274</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00122.html#a8067158022e2bd145cc9dad06c4e685b">OperationAlternate::removeSubOperation</a>(<a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a> *o)
<a name="l01275"></a>01275 {
<a name="l01276"></a>01276   Operationlist::iterator altIter = alternates.begin();
<a name="l01277"></a>01277   alternatePropertyList::iterator propIter = alternateProperties.begin();
<a name="l01278"></a>01278   <span class="keywordflow">while</span> (altIter!=alternates.end() &amp;&amp; *altIter != o)
<a name="l01279"></a>01279   {
<a name="l01280"></a>01280     ++propIter;
<a name="l01281"></a>01281     ++altIter;
<a name="l01282"></a>01282   }
<a name="l01283"></a>01283   <span class="keywordflow">if</span> (*altIter == o)
<a name="l01284"></a>01284   {
<a name="l01285"></a>01285     alternates.erase(altIter);
<a name="l01286"></a>01286     alternateProperties.erase(propIter);
<a name="l01287"></a>01287     o-&gt;superoplist.remove(<span class="keyword">this</span>);
<a name="l01288"></a>01288     <a class="code" href="a00133.html#a11a86a6e020664a337325a96a64f6d2c">setChanged</a>();
<a name="l01289"></a>01289   }
<a name="l01290"></a>01290   <span class="keywordflow">else</span>
<a name="l01291"></a>01291     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Warning: operation &apos;&quot;</span> &lt;&lt; *o
<a name="l01292"></a>01292     &lt;&lt; <span class="stringliteral">&quot;&apos; isn&apos;t a suboperation of alternate operation &apos;&quot;</span> &lt;&lt; *<span class="keyword">this</span>
<a name="l01293"></a>01293     &lt;&lt; <span class="stringliteral">&quot;&apos;&quot;</span> &lt;&lt; endl;
<a name="l01294"></a>01294 }
<a name="l01295"></a>01295 
<a name="l01296"></a>01296 
<a name="l01297"></a>01297 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a> <a class="code" href="a00129.html#aa06543c742d743b48f916fb99beb3129">OperationSetup::setOperationPlanParameters</a>
<a name="l01298"></a><a class="code" href="a00129.html#aa06543c742d743b48f916fb99beb3129">01298</a> (<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, <span class="keywordtype">double</span> q, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> s, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> e, <span class="keywordtype">bool</span> preferEnd, <span class="keywordtype">bool</span> execute) <span class="keyword">const</span>
<a name="l01299"></a>01299 {
<a name="l01300"></a>01300   <span class="comment">// Find or create a loadplan</span>
<a name="l01301"></a>01301   <a class="code" href="a00106.html" title="An iterator class to go through all loadplans of an operationplan.">OperationPlan::LoadPlanIterator</a> i = opplan-&gt;<a class="code" href="a00125.html#af14047934961e9c5f04c0ecc70df649c">beginLoadPlans</a>();
<a name="l01302"></a>01302   <a class="code" href="a00105.html" title="This class represents the resource capacity of an operationplan.">LoadPlan</a> *ldplan = NULL;
<a name="l01303"></a>01303   <span class="keywordflow">if</span> (i != opplan-&gt;<a class="code" href="a00125.html#af4b4401df92ad9e292edd56d3272b79c">endLoadPlans</a>())
<a name="l01304"></a>01304     <span class="comment">// Already exists</span>
<a name="l01305"></a>01305     ldplan = &amp;*i;
<a name="l01306"></a>01306   <span class="keywordflow">else</span>
<a name="l01307"></a>01307   {
<a name="l01308"></a>01308     <span class="comment">// Create a new one</span>
<a name="l01309"></a>01309     <span class="keywordflow">if</span> (!opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>())
<a name="l01310"></a>01310       <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Setup operationplan always must have an owner&quot;</span>);
<a name="l01311"></a>01311     <span class="keywordflow">for</span> (loadlist::const_iterator g=opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>()-&gt;<a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().begin(); 
<a name="l01312"></a>01312       g!=opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>()-&gt;<a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().end(); ++g)
<a name="l01313"></a>01313       <span class="keywordflow">if</span> (g-&gt;getResource()-&gt;getSetupMatrix() &amp;&amp; !g-&gt;getSetup().empty())
<a name="l01314"></a>01314       {
<a name="l01315"></a>01315         ldplan = <span class="keyword">new</span> <a class="code" href="a00105.html" title="This class represents the resource capacity of an operationplan.">LoadPlan</a>(opplan, &amp;*g);
<a name="l01316"></a>01316         <span class="keywordflow">break</span>;
<a name="l01317"></a>01317       }
<a name="l01318"></a>01318     <span class="keywordflow">if</span> (!ldplan)
<a name="l01319"></a>01319       <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Can&apos;t find a setup on operation &apos;&quot;</span> 
<a name="l01320"></a>01320         + opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>()-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l01321"></a>01321   }
<a name="l01322"></a>01322 
<a name="l01323"></a>01323   <span class="comment">// Find the setup of the resource at the start of the conversion</span>
<a name="l01324"></a>01324   <span class="keyword">const</span> <a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a>* lastld = NULL;
<a name="l01325"></a>01325   <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> boundary = s ? s : e;
<a name="l01326"></a>01326   <span class="keywordflow">if</span> (ldplan-&gt;<a class="code" href="a00058.html#a965645e70dd9f99b0bd4f1325fb382aa">getDate</a>() &lt; boundary)
<a name="l01327"></a>01327   {
<a name="l01328"></a>01328     <span class="keywordflow">for</span> (<a class="code" href="a00178.html" title="This class implements a &amp;quot;sorted list&amp;quot; data structure, sorting &amp;quot;events&amp;quot;...">TimeLine&lt;LoadPlan&gt;::const_iterator</a> i = ldplan-&gt;<a class="code" href="a00105.html#a88541f3fad5fb0f1b12fc2cb91908e7e">getResource</a>()-&gt;<a class="code" href="a00156.html#a2788d75fc71a151629e8ef557e722314">getLoadPlans</a>().begin(ldplan);
<a name="l01329"></a>01329       i != ldplan-&gt;<a class="code" href="a00105.html#a88541f3fad5fb0f1b12fc2cb91908e7e">getResource</a>()-&gt;<a class="code" href="a00156.html#a2788d75fc71a151629e8ef557e722314">getLoadPlans</a>().end() &amp;&amp; i-&gt;getDate() &lt;= boundary; ++i)
<a name="l01330"></a>01330     {
<a name="l01331"></a>01331       <span class="keyword">const</span> <a class="code" href="a00105.html" title="This class represents the resource capacity of an operationplan.">LoadPlan</a> *l = <span class="keyword">dynamic_cast&lt;</span><span class="keyword">const </span><a class="code" href="a00105.html" title="This class represents the resource capacity of an operationplan.">LoadPlan</a>*<span class="keyword">&gt;</span>(&amp;*i);
<a name="l01332"></a>01332       <span class="keywordflow">if</span> (l &amp;&amp; i-&gt;getQuantity() != 0.0 
<a name="l01333"></a>01333         &amp;&amp; l-&gt;<a class="code" href="a00105.html#a0969aca89148ba44b97211d25177cbed">getOperationPlan</a>() != opplan
<a name="l01334"></a>01334         &amp;&amp; l-&gt;<a class="code" href="a00105.html#a0969aca89148ba44b97211d25177cbed">getOperationPlan</a>() != opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()
<a name="l01335"></a>01335         &amp;&amp; !l-&gt;<a class="code" href="a00105.html#aa62c4a262f2146c1f53f032314aebe97">getLoad</a>()-&gt;<a class="code" href="a00103.html#a7cab9031b62cd9d89a924ff5dcb2aa60">getSetup</a>().empty())
<a name="l01336"></a>01336           lastld = l-&gt;<a class="code" href="a00105.html#aa62c4a262f2146c1f53f032314aebe97">getLoad</a>();
<a name="l01337"></a>01337     }
<a name="l01338"></a>01338   }
<a name="l01339"></a>01339   <span class="keywordflow">if</span> (!lastld)
<a name="l01340"></a>01340   {
<a name="l01341"></a>01341     <span class="keywordflow">for</span> (<a class="code" href="a00178.html" title="This class implements a &amp;quot;sorted list&amp;quot; data structure, sorting &amp;quot;events&amp;quot;...">TimeLine&lt;LoadPlan&gt;::const_iterator</a> i = ldplan-&gt;<a class="code" href="a00105.html#a88541f3fad5fb0f1b12fc2cb91908e7e">getResource</a>()-&gt;<a class="code" href="a00156.html#a2788d75fc71a151629e8ef557e722314">getLoadPlans</a>().begin(ldplan);
<a name="l01342"></a>01342       i != ldplan-&gt;<a class="code" href="a00105.html#a88541f3fad5fb0f1b12fc2cb91908e7e">getResource</a>()-&gt;<a class="code" href="a00156.html#a2788d75fc71a151629e8ef557e722314">getLoadPlans</a>().end(); --i)
<a name="l01343"></a>01343     {
<a name="l01344"></a>01344       <span class="keyword">const</span> <a class="code" href="a00105.html" title="This class represents the resource capacity of an operationplan.">LoadPlan</a> *l = <span class="keyword">dynamic_cast&lt;</span><span class="keyword">const </span><a class="code" href="a00105.html" title="This class represents the resource capacity of an operationplan.">LoadPlan</a>*<span class="keyword">&gt;</span>(&amp;*i);
<a name="l01345"></a>01345       <span class="keywordflow">if</span> (l &amp;&amp; i-&gt;getQuantity() != 0.0 
<a name="l01346"></a>01346         &amp;&amp; l-&gt;<a class="code" href="a00105.html#a0969aca89148ba44b97211d25177cbed">getOperationPlan</a>() != opplan
<a name="l01347"></a>01347         &amp;&amp; l-&gt;<a class="code" href="a00105.html#a0969aca89148ba44b97211d25177cbed">getOperationPlan</a>() != opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()
<a name="l01348"></a>01348         &amp;&amp; !l-&gt;<a class="code" href="a00105.html#aa62c4a262f2146c1f53f032314aebe97">getLoad</a>()-&gt;<a class="code" href="a00103.html#a7cab9031b62cd9d89a924ff5dcb2aa60">getSetup</a>().empty()
<a name="l01349"></a>01349         &amp;&amp; l-&gt;<a class="code" href="a00058.html#a965645e70dd9f99b0bd4f1325fb382aa">getDate</a>() &lt;= boundary)
<a name="l01350"></a>01350         {
<a name="l01351"></a>01351           lastld = l-&gt;<a class="code" href="a00105.html#aa62c4a262f2146c1f53f032314aebe97">getLoad</a>();
<a name="l01352"></a>01352           <span class="keywordflow">break</span>;
<a name="l01353"></a>01353         }
<a name="l01354"></a>01354     }
<a name="l01355"></a>01355   }
<a name="l01356"></a>01356   <span class="keywordtype">string</span> lastsetup = lastld ? lastld-&gt;<a class="code" href="a00103.html#a7cab9031b62cd9d89a924ff5dcb2aa60">getSetup</a>() : ldplan-&gt;<a class="code" href="a00105.html#a88541f3fad5fb0f1b12fc2cb91908e7e">getResource</a>()-&gt;<a class="code" href="a00156.html#a2c8506a14137a874a02280ce0933a90e">getSetup</a>();
<a name="l01357"></a>01357 
<a name="l01358"></a>01358   <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> duration(0L);
<a name="l01359"></a>01359   <span class="keywordflow">if</span> (lastsetup != ldplan-&gt;<a class="code" href="a00105.html#aa62c4a262f2146c1f53f032314aebe97">getLoad</a>()-&gt;<a class="code" href="a00103.html#a7cab9031b62cd9d89a924ff5dcb2aa60">getSetup</a>())
<a name="l01360"></a>01360   {
<a name="l01361"></a>01361     <span class="comment">// Calculate the setup time</span>
<a name="l01362"></a>01362     <a class="code" href="a00160.html" title="An specific changeover rule in a setup matrix.">SetupMatrix::Rule</a> *conversionrule = ldplan-&gt;<a class="code" href="a00105.html#aa62c4a262f2146c1f53f032314aebe97">getLoad</a>()-&gt;<a class="code" href="a00103.html#ab929aafe9c6085a216ad3084ec23c93b">getResource</a>()-&gt;<a class="code" href="a00156.html#a364f95ef308af4b2be6e202d71f4f630">getSetupMatrix</a>()
<a name="l01363"></a>01363       -&gt;<a class="code" href="a00165.html#a2bde77a78252ad83c4429eeec7ff0348">calculateSetup</a>(lastsetup, ldplan-&gt;<a class="code" href="a00105.html#aa62c4a262f2146c1f53f032314aebe97">getLoad</a>()-&gt;<a class="code" href="a00103.html#a7cab9031b62cd9d89a924ff5dcb2aa60">getSetup</a>());
<a name="l01364"></a>01364     duration = conversionrule ? conversionrule-&gt;<a class="code" href="a00160.html#a86db8a7f88eb9abd1dd3c099ca7a944e">getDuration</a>() : <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a>(365L*86400L);
<a name="l01365"></a>01365   }
<a name="l01366"></a>01366 
<a name="l01367"></a>01367   <span class="comment">// Set the start and end date.</span>
<a name="l01368"></a>01368   <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> x;
<a name="l01369"></a>01369   <a class="code" href="a00179.html" title="This class represents a time duration with an accuracy of one second.">TimePeriod</a> actualduration;
<a name="l01370"></a>01370   <span class="keywordflow">if</span> (e &amp;&amp; s)
<a name="l01371"></a>01371   {
<a name="l01372"></a>01372     <span class="keywordflow">if</span> (preferEnd) x = calculateOperationTime(e, duration, <span class="keyword">false</span>, &amp;actualduration);
<a name="l01373"></a>01373     <span class="keywordflow">else</span> x = calculateOperationTime(s, duration, <span class="keyword">true</span>, &amp;actualduration);
<a name="l01374"></a>01374   }
<a name="l01375"></a>01375   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (s) x = calculateOperationTime(s, duration, <span class="keyword">true</span>, &amp;actualduration);
<a name="l01376"></a>01376   <span class="keywordflow">else</span> x = calculateOperationTime(e, duration, <span class="keyword">false</span>, &amp;actualduration);
<a name="l01377"></a>01377   <span class="keywordflow">if</span> (!execute)
<a name="l01378"></a>01378     <span class="comment">// Simulation only</span>
<a name="l01379"></a>01379     <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(x, actualduration == duration ? q : 0);
<a name="l01380"></a>01380   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (actualduration == duration)
<a name="l01381"></a>01381   {
<a name="l01382"></a>01382     <span class="comment">// Update succeeded</span>
<a name="l01383"></a>01383     opplan-&gt;<a class="code" href="a00125.html#a78fc77e6efcae27817fa12ff5cfdaee4">setStartAndEnd</a>(x.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(), x.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>());
<a name="l01384"></a>01384     <span class="keywordflow">if</span> (opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>() != opplan-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>())
<a name="l01385"></a>01385       opplan-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>()-&gt;<a class="code" href="a00125.html#a2265d1554215f7185b8556f53c5805f2">setStart</a>(opplan-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>().<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>());
<a name="l01386"></a>01386   }
<a name="l01387"></a>01387   <span class="keywordflow">else</span>
<a name="l01388"></a>01388     <span class="comment">// Update failed - Not enough available time @todo setting the qty to 0 is not enough</span>
<a name="l01389"></a>01389     opplan-&gt;<a class="code" href="a00125.html#aa33a70a23ad111e4b2a35ec96757a1fb">setQuantity</a>(0);
<a name="l01390"></a>01390 
<a name="l01391"></a>01391   <span class="keywordflow">return</span> <a class="code" href="a00127.html" title="A simple class to easily remember the date and quantity of an operationplan.">OperationPlanState</a>(opplan);
<a name="l01392"></a>01392 }
<a name="l01393"></a>01393 
<a name="l01394"></a>01394 
<a name="l01395"></a><a class="code" href="a00121.html#a0681225944aef2db5421e5a5f7f710c1">01395</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00121.html#a0681225944aef2db5421e5a5f7f710c1">Operation::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr)
<a name="l01396"></a>01396 {
<a name="l01397"></a>01397   <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="l01398"></a>01398     <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="l01399"></a>01399   <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="l01400"></a>01400     <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="l01401"></a>01401   <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="l01402"></a>01402     <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="l01403"></a>01403   <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="l01404"></a>01404     <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="l01405"></a>01405   <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="l01406"></a>01406     <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="a00121.html#ac1bee1aad414a31708cc0e5c73cc1fa3">getLocation</a>());
<a name="l01407"></a>01407   <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="l01408"></a>01408     <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="a00121.html#a0ad8ad3a837a2d93c2811cf568bf2cf0">getFence</a>());
<a name="l01409"></a>01409   <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="l01410"></a>01410     <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="a00121.html#ae1ef1417d3f6b89561e6c0909f772782">getSizeMinimum</a>());
<a name="l01411"></a>01411   <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="l01412"></a>01412     <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="a00121.html#a3b55372755baff92fa8fcc0d47ed717f">getSizeMultiple</a>());
<a name="l01413"></a>01413   <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="l01414"></a>01414     <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="a00121.html#af720f657b00a661e76f3ba7304053071">getSizeMaximum</a>());
<a name="l01415"></a>01415   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>))
<a name="l01416"></a>01416     <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="a00121.html#ab69b08d57703a9d7809530270a6b86bf">getCost</a>());
<a name="l01417"></a>01417   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ab45db3e14bc139292860766d13a426ab">Tags::tag_pretime</a>))
<a name="l01418"></a>01418     <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="a00121.html#abe0e2d32e84f135f6023eb78922f1ac2">getPreTime</a>());
<a name="l01419"></a>01419   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#acc636e19133af3f4c3897bde9633543a">Tags::tag_posttime</a>))
<a name="l01420"></a>01420     <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="a00121.html#a1154c9b0b9d3f732f27f6dcd538174bb">getPostTime</a>());
<a name="l01421"></a>01421   <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="l01422"></a>01422     <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="a00121.html#a69cb37b254f41a64896a8de3076697a8">getHidden</a>());
<a name="l01423"></a>01423   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a2e32d4c89079c071ec2bd8e634e9b440">Tags::tag_loads</a>))
<a name="l01424"></a>01424     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="a00104.html">LoadIterator</a>(<span class="keyword">this</span>);
<a name="l01425"></a>01425   <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="l01426"></a>01426     <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="l01427"></a>01427   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#aadee013608238a2c7309cb6960496126">Tags::tag_operationplans</a>))
<a name="l01428"></a>01428     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="a00126.html">OperationPlanIterator</a>(<span class="keyword">this</span>);
<a name="l01429"></a>01429   <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="l01430"></a>01430     <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="l01431"></a>01431   <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="l01432"></a>01432     <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="l01433"></a>01433   <span class="keywordflow">return</span> NULL;
<a name="l01434"></a>01434 }
<a name="l01435"></a>01435 
<a name="l01436"></a>01436 
<a name="l01437"></a><a class="code" href="a00121.html#a494bac93a19785d858ed4553eb444166">01437</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00121.html#a494bac93a19785d858ed4553eb444166">Operation::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>&amp; field)
<a name="l01438"></a>01438 {
<a name="l01439"></a>01439   <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="l01440"></a>01440     <a class="code" href="a00085.html#a97d855d8c9bc9774da9cd8905e242dde">setName</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l01441"></a>01441   <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="l01442"></a>01442     <a class="code" href="a00082.html#a86430aaf17c259450986d8ad73aa2fbf">setDescription</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l01443"></a>01443   <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="l01444"></a>01444     <a class="code" href="a00082.html#a765bec78ade5db873ae5d2c1a56238ab">setCategory</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l01445"></a>01445   <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="l01446"></a>01446     <a class="code" href="a00082.html#abd65cc21a6a0636f3569e90e89e54e5f">setSubCategory</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l01447"></a>01447   <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="l01448"></a>01448   {
<a name="l01449"></a>01449     <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="l01450"></a>01450     {
<a name="l01451"></a>01451       PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">&quot;buffer location must be of type location&quot;</span>);
<a name="l01452"></a>01452       <span class="keywordflow">return</span> -1;
<a name="l01453"></a>01453     }
<a name="l01454"></a>01454     <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&lt;</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">&gt;</span>(<span class="keyword">static_cast&lt;</span>PyObject*<span class="keyword">&gt;</span>(field));
<a name="l01455"></a>01455     <a class="code" href="a00121.html#a9244c0638313cf9f830916196d4d17ff">setLocation</a>(y);
<a name="l01456"></a>01456   }
<a name="l01457"></a>01457   <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="l01458"></a>01458     <a class="code" href="a00121.html#a24fa469d1f7e5bce42ab27389a15db92">setFence</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>());
<a name="l01459"></a>01459   <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="l01460"></a>01460     <a class="code" href="a00121.html#a0bf699cb21a1431b85441a4fc9675f86">setSizeMinimum</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>());
<a name="l01461"></a>01461   <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="l01462"></a>01462     <a class="code" href="a00121.html#aade8f5a9ecbdc851a1fdcfed6f76387f">setSizeMultiple</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>());
<a name="l01463"></a>01463   <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="l01464"></a>01464     <a class="code" href="a00121.html#aba8019ede4a8d42c9ef7c26e2c82b7ed">setSizeMaximum</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>());
<a name="l01465"></a>01465   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a26ba9b767f074c42558fe812da43c8ab">Tags::tag_cost</a>))
<a name="l01466"></a>01466     <a class="code" href="a00121.html#a258d1a1dbd72994a5c351560b579264b">setCost</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>());
<a name="l01467"></a>01467   <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#ab45db3e14bc139292860766d13a426ab">Tags::tag_pretime</a>))
<a name="l01468"></a>01468     <a class="code" href="a00121.html#ac72b630ad4d0e25b8999bf769b992355">setPreTime</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>());
<a name="l01469"></a>01469   <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#acc636e19133af3f4c3897bde9633543a">Tags::tag_posttime</a>))
<a name="l01470"></a>01470     <a class="code" href="a00121.html#abbdf4639868202354b5dac66bb957442">setPostTime</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>());
<a name="l01471"></a>01471   <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="l01472"></a>01472     <a class="code" href="a00121.html#a5ad84f4daa4e5f5d018ba46c8896a585">setHidden</a>(field.<a class="code" href="a00154.html#a804b478fb76759d334882ee468fc84f9">getBool</a>());
<a name="l01473"></a>01473   <span class="keywordflow">else</span>
<a name="l01474"></a>01474     <span class="keywordflow">return</span> -1;  <span class="comment">// Error</span>
<a name="l01475"></a>01475   <span class="keywordflow">return</span> 0;  <span class="comment">// OK</span>
<a name="l01476"></a>01476 }
<a name="l01477"></a>01477 
<a name="l01478"></a>01478 
<a name="l01479"></a><a class="code" href="a00123.html#ac5f14aa11baf05605a6db60ecef1b288">01479</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00123.html#ac5f14aa11baf05605a6db60ecef1b288">OperationFixedTime::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr)
<a name="l01480"></a>01480 {
<a name="l01481"></a>01481   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l01482"></a>01482     <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="a00123.html#a7ae8b7106dd8aaf60ba6c159616270d3">getDuration</a>());
<a name="l01483"></a>01483   <span class="keywordflow">return</span> <a class="code" href="a00123.html#ac5f14aa11baf05605a6db60ecef1b288">Operation::getattro</a>(attr);
<a name="l01484"></a>01484 }
<a name="l01485"></a>01485 
<a name="l01486"></a>01486 
<a name="l01487"></a><a class="code" href="a00123.html#aa34a37033c58f0777fc76a3824f35586">01487</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00123.html#aa34a37033c58f0777fc76a3824f35586">OperationFixedTime::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>&amp; field)
<a name="l01488"></a>01488 {
<a name="l01489"></a>01489   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l01490"></a>01490     <a class="code" href="a00123.html#ab66256eb7de650cf65ad8d87ba2685ef">setDuration</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>());
<a name="l01491"></a>01491   <span class="keywordflow">else</span>
<a name="l01492"></a>01492     <span class="keywordflow">return</span> <a class="code" href="a00123.html#aa34a37033c58f0777fc76a3824f35586">Operation::setattro</a>(attr, field);
<a name="l01493"></a>01493   <span class="keywordflow">return</span> 0;
<a name="l01494"></a>01494 }
<a name="l01495"></a>01495 
<a name="l01496"></a>01496 
<a name="l01497"></a><a class="code" href="a00130.html#ab848b039e95e902500a35497babc9cf5">01497</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00130.html#ab848b039e95e902500a35497babc9cf5">OperationTimePer::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr)
<a name="l01498"></a>01498 {
<a name="l01499"></a>01499   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l01500"></a>01500     <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="a00130.html#a470f9cf304ff10f51759034f76ffc94c">getDuration</a>());
<a name="l01501"></a>01501   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l01502"></a>01502     <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="a00130.html#a8a247b78bfa721a3d5c57bf36aed66cd">getDurationPer</a>());
<a name="l01503"></a>01503   <span class="keywordflow">return</span> <a class="code" href="a00130.html#ab848b039e95e902500a35497babc9cf5">Operation::getattro</a>(attr);
<a name="l01504"></a>01504 }
<a name="l01505"></a>01505 
<a name="l01506"></a>01506 
<a name="l01507"></a><a class="code" href="a00130.html#a943a4be921c6a204fbd101a4878609d4">01507</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00130.html#a943a4be921c6a204fbd101a4878609d4">OperationTimePer::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>&amp; field)
<a name="l01508"></a>01508 {
<a name="l01509"></a>01509   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ac9d9c202abb6e19f0158084ea3671179">Tags::tag_duration</a>))
<a name="l01510"></a>01510     <a class="code" href="a00130.html#ad21e39c7f989db95207963d9f04e1ed6">setDuration</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>());
<a name="l01511"></a>01511   <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#afdb7bb96906c802c415ff0952ca76d0b">Tags::tag_duration_per</a>))
<a name="l01512"></a>01512     <a class="code" href="a00130.html#a49d469ae1cafe9dcee7ffd9914b01aac">setDurationPer</a>(field.<a class="code" href="a00154.html#a8add60e92982666a4a13b499d9c74d58">getTimeperiod</a>());
<a name="l01513"></a>01513   <span class="keywordflow">else</span>
<a name="l01514"></a>01514     <span class="keywordflow">return</span> <a class="code" href="a00130.html#a943a4be921c6a204fbd101a4878609d4">Operation::setattro</a>(attr, field);
<a name="l01515"></a>01515   <span class="keywordflow">return</span> 0;
<a name="l01516"></a>01516 }
<a name="l01517"></a>01517 
<a name="l01518"></a>01518 
<a name="l01519"></a><a class="code" href="a00122.html#aca0c41e63d37719114c08f1c0e709664">01519</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00122.html#aca0c41e63d37719114c08f1c0e709664">OperationAlternate::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr)
<a name="l01520"></a>01520 {
<a name="l01521"></a>01521   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a1db462103ca0f7689146070b09e0d903">Tags::tag_alternates</a>))
<a name="l01522"></a>01522   {
<a name="l01523"></a>01523     PyObject* result = PyTuple_New(<a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().<a class="code" href="a00085.html#a942c27efb3a90dba22215a6e4287d8e4">size</a>());
<a name="l01524"></a>01524     <span class="keywordtype">int</span> count = 0;
<a name="l01525"></a>01525     <span class="keywordflow">for</span> (Operation::Operationlist::const_iterator i = <a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>(); i != <a class="code" href="a00122.html#a15e4ba08a35bb3a364e2f6ce2512f3c6">getSubOperations</a>().end(); ++i)
<a name="l01526"></a>01526       PyTuple_SetItem(result, count++, <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(*i));
<a name="l01527"></a>01527     <span class="keywordflow">return</span> result;
<a name="l01528"></a>01528   }
<a name="l01529"></a>01529   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a0364c7fc29b0d795dfa1624947efd387">Tags::tag_search</a>))
<a name="l01530"></a>01530   {
<a name="l01531"></a>01531     ostringstream ch;
<a name="l01532"></a>01532     ch &lt;&lt; <a class="code" href="a00122.html#a9eee64d0bb881e81d0fe9ba7dbe05c66">getSearch</a>();
<a name="l01533"></a>01533     <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>(ch.str());
<a name="l01534"></a>01534   }
<a name="l01535"></a>01535   <span class="keywordflow">return</span> <a class="code" href="a00122.html#aca0c41e63d37719114c08f1c0e709664">Operation::getattro</a>(attr);
<a name="l01536"></a>01536 }
<a name="l01537"></a>01537 
<a name="l01538"></a>01538 
<a name="l01539"></a><a class="code" href="a00122.html#a4adc5f876e7f8719b61f27770e0ed4e0">01539</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00122.html#a4adc5f876e7f8719b61f27770e0ed4e0">OperationAlternate::setattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>&amp; field)
<a name="l01540"></a>01540 {
<a name="l01541"></a>01541   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a0364c7fc29b0d795dfa1624947efd387">Tags::tag_search</a>))
<a name="l01542"></a>01542     <a class="code" href="a00122.html#a59b4283e24286d5b9d19671379eb4ecf">setSearch</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l01543"></a>01543   <span class="keywordflow">else</span>
<a name="l01544"></a>01544     <span class="keywordflow">return</span> <a class="code" href="a00122.html#a4adc5f876e7f8719b61f27770e0ed4e0">Operation::setattro</a>(attr, field);
<a name="l01545"></a>01545   <span class="keywordflow">return</span> 0;
<a name="l01546"></a>01546 }
<a name="l01547"></a>01547 
<a name="l01548"></a>01548 
<a name="l01549"></a><a class="code" href="a00122.html#a6efec2ca0c191b0630f0e915f860c5df">01549</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00122.html#accd0dc05a16c25a96b3fad2c22834ccc">OperationAlternate::addAlternate</a>(PyObject* <span class="keyword">self</span>, PyObject* args, PyObject* kwdict)
<a name="l01550"></a>01550 {
<a name="l01551"></a>01551   <span class="keywordflow">try</span>
<a name="l01552"></a>01552   {
<a name="l01553"></a>01553     <span class="comment">// Pick up the alternate operation</span>
<a name="l01554"></a>01554     <a class="code" href="a00122.html" title="This class represents a choice between multiple operations. The alternates are sorted...">OperationAlternate</a> *altoper = <span class="keyword">static_cast&lt;</span><a class="code" href="a00122.html" title="This class represents a choice between multiple operations. The alternates are sorted...">OperationAlternate</a>*<span class="keyword">&gt;</span>(<span class="keyword">self</span>);
<a name="l01555"></a>01555     <span class="keywordflow">if</span> (!altoper) <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Can&apos;t add alternates to NULL alternate&quot;</span>);
<a name="l01556"></a>01556 
<a name="l01557"></a>01557     <span class="comment">// Parse the arguments</span>
<a name="l01558"></a>01558     PyObject *oper = NULL;
<a name="l01559"></a>01559     <span class="keywordtype">int</span> prio = 1;
<a name="l01560"></a>01560     PyObject *eff_start = NULL;
<a name="l01561"></a>01561     PyObject *eff_end = NULL;
<a name="l01562"></a>01562     <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *kwlist[] = {<span class="stringliteral">&quot;operation&quot;</span>, <span class="stringliteral">&quot;priority&quot;</span>, <span class="stringliteral">&quot;effective_start&quot;</span>, <span class="stringliteral">&quot;effective_end&quot;</span>, NULL};
<a name="l01563"></a>01563     <span class="keywordflow">if</span> (!PyArg_ParseTupleAndKeywords(args, kwdict,
<a name="l01564"></a>01564       <span class="stringliteral">&quot;O|iOO:addAlternate&quot;</span>,
<a name="l01565"></a>01565       const_cast&lt;char**&gt;(kwlist), &amp;oper, &amp;prio, &amp;eff_start, &amp;eff_end))
<a name="l01566"></a>01566         <span class="keywordflow">return</span> NULL;
<a name="l01567"></a>01567     <span class="keywordflow">if</span> (!PyObject_TypeCheck(oper, <a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>-&gt;pythonClass))
<a name="l01568"></a>01568       <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;alternate operation must be of type operation&quot;</span>);
<a name="l01569"></a>01569     <a class="code" href="a00050.html" title="This class defines a date-range, i.e. a start-date and end-date pair.">DateRange</a> eff;
<a name="l01570"></a>01570     <span class="keywordflow">if</span> (eff_start)
<a name="l01571"></a>01571     {
<a name="l01572"></a>01572       <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a> d(eff_start);
<a name="l01573"></a>01573       eff.<a class="code" href="a00050.html#a301068faa83a2a88fdb46ffb26f56502">setStart</a>(d.<a class="code" href="a00154.html#aa72c83cab5f89f71aff63f0bfad26bd1">getDate</a>());
<a name="l01574"></a>01574     }
<a name="l01575"></a>01575     <span class="keywordflow">if</span> (eff_end)
<a name="l01576"></a>01576     {
<a name="l01577"></a>01577       <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a> d(eff_end);
<a name="l01578"></a>01578       eff.<a class="code" href="a00050.html#a953ee79781eee836ae07bd389aca5515">setEnd</a>(d.<a class="code" href="a00154.html#aa72c83cab5f89f71aff63f0bfad26bd1">getDate</a>());
<a name="l01579"></a>01579     }
<a name="l01580"></a>01580 
<a name="l01581"></a>01581     <span class="comment">// Add the alternate</span>
<a name="l01582"></a>01582     altoper-&gt;<a class="code" href="a00122.html#accd0dc05a16c25a96b3fad2c22834ccc">addAlternate</a>(static_cast&lt;Operation*&gt;(oper), prio, eff);
<a name="l01583"></a>01583  }
<a name="l01584"></a>01584   <span class="keywordflow">catch</span>(...)
<a name="l01585"></a>01585   {
<a name="l01586"></a>01586     PythonType::evalException();
<a name="l01587"></a>01587     <span class="keywordflow">return</span> NULL;
<a name="l01588"></a>01588   }
<a name="l01589"></a>01589   <span class="keywordflow">return</span> Py_BuildValue(<span class="stringliteral">&quot;&quot;</span>);
<a name="l01590"></a>01590 }
<a name="l01591"></a>01591 
<a name="l01592"></a>01592 
<a name="l01593"></a><a class="code" href="a00128.html#a5d33554349a36ca63ed8062504e8759c">01593</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00128.html#a5d33554349a36ca63ed8062504e8759c">OperationRouting::getattro</a>(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>&amp; attr)
<a name="l01594"></a>01594 {
<a name="l01595"></a>01595   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a8d66ef09f0794d06a1cd24c9fe7a6343">Tags::tag_steps</a>))
<a name="l01596"></a>01596   {
<a name="l01597"></a>01597     PyObject* result = PyTuple_New(<a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().<a class="code" href="a00085.html#a942c27efb3a90dba22215a6e4287d8e4">size</a>());
<a name="l01598"></a>01598     <span class="keywordtype">int</span> count = 0;
<a name="l01599"></a>01599     <span class="keywordflow">for</span> (Operation::Operationlist::const_iterator i = <a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>(); i != <a class="code" href="a00128.html#a2630402ce9db63798fd471795b65c155">getSubOperations</a>().end(); ++i)
<a name="l01600"></a>01600       PyTuple_SetItem(result, count++, <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(*i));
<a name="l01601"></a>01601     <span class="keywordflow">return</span> result;
<a name="l01602"></a>01602   }
<a name="l01603"></a>01603   <span class="keywordflow">return</span> <a class="code" href="a00128.html#a5d33554349a36ca63ed8062504e8759c">Operation::getattro</a>(attr);
<a name="l01604"></a>01604 }
<a name="l01605"></a>01605 
<a name="l01606"></a>01606 
<a name="l01607"></a><a class="code" href="a00128.html#afd7538ad741943ee47c1aa2e9162e439">01607</a> PyObject *<a class="code" href="a00128.html#afd7538ad741943ee47c1aa2e9162e439">OperationRouting::addStep</a>(PyObject *<span class="keyword">self</span>, PyObject *args)
<a name="l01608"></a>01608 {
<a name="l01609"></a>01609   <span class="keywordflow">try</span>
<a name="l01610"></a>01610   {
<a name="l01611"></a>01611     <span class="comment">// Pick up the routing operation</span>
<a name="l01612"></a>01612     <a class="code" href="a00128.html" title="Represents a routing operation, i.e. an operation consisting of multiple, sequential...">OperationRouting</a> *oper = <span class="keyword">static_cast&lt;</span><a class="code" href="a00128.html" title="Represents a routing operation, i.e. an operation consisting of multiple, sequential...">OperationRouting</a>*<span class="keyword">&gt;</span>(<span class="keyword">self</span>);
<a name="l01613"></a>01613     <span class="keywordflow">if</span> (!oper) <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">&quot;Can&apos;t add steps to NULL routing&quot;</span>);
<a name="l01614"></a>01614 
<a name="l01615"></a>01615     <span class="comment">// Parse the arguments</span>
<a name="l01616"></a>01616     PyObject *steps[4];
<a name="l01617"></a>01617     <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;4; ++i) steps[i] = NULL;
<a name="l01618"></a>01618     <span class="keywordflow">if</span> (PyArg_UnpackTuple(args, <span class="stringliteral">&quot;addStep&quot;</span>, 1, 4, &amp;steps[0], &amp;steps[1], &amp;steps[2], &amp;steps[3]))
<a name="l01619"></a>01619       <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i&lt;4 &amp;&amp; steps[i]; ++i)
<a name="l01620"></a>01620       {
<a name="l01621"></a>01621         <span class="keywordflow">if</span> (!PyObject_TypeCheck(steps[i], <a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>-&gt;pythonClass))
<a name="l01622"></a>01622           <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;routing steps must be of type operation&quot;</span>);
<a name="l01623"></a>01623         oper-&gt;<a class="code" href="a00128.html#ab32a4a3eb91accc121cc95c56044cc0c">addStepBack</a>(static_cast&lt;Operation*&gt;(steps[i]));
<a name="l01624"></a>01624       }
<a name="l01625"></a>01625   }
<a name="l01626"></a>01626   <span class="keywordflow">catch</span>(...)
<a name="l01627"></a>01627   {
<a name="l01628"></a>01628     PythonType::evalException();
<a name="l01629"></a>01629     <span class="keywordflow">return</span> NULL;
<a name="l01630"></a>01630   }
<a name="l01631"></a>01631   <span class="keywordflow">return</span> Py_BuildValue(<span class="stringliteral">&quot;&quot;</span>);
<a name="l01632"></a>01632 }
<a name="l01633"></a>01633 
<a name="l01634"></a>01634 } <span class="comment">// end namespace</span>
</pre></div></div>
<hr size="1"/><address style="align: right;"><small>Documentation generated for frePPLe by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"/></a></small></address>
</div>
</div>
</body>
</html>