Sophie

Sophie

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

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: load.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>load.cpp</h1><a href="a00212.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/load.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="a00212.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 <span class="keyword">namespace </span>frepple
<a name="l00031"></a>00031 {
<a name="l00032"></a>00032 
<a name="l00033"></a>00033 <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="a00103.html#a0abc6edc2b69b52286df209039c0c118">Load::metadata</a>;
<a name="l00034"></a>00034 
<a name="l00035"></a>00035 
<a name="l00036"></a><a class="code" href="a00103.html#a48ed20340de96da9265bf4afc6575d37">00036</a> <span class="keywordtype">int</span> <a class="code" href="a00103.html#a48ed20340de96da9265bf4afc6575d37">Load::initialize</a>()
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038   <span class="comment">// Initialize the metadata</span>
<a name="l00039"></a>00039   <a class="code" href="a00103.html#a0abc6edc2b69b52286df209039c0c118">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>
<a name="l00040"></a>00040     (<span class="stringliteral">&quot;load&quot;</span>, <span class="stringliteral">&quot;loads&quot;</span>, MetaCategory::ControllerDefault, <a class="code" href="a00103.html#ae1cacbcbdac199c21beb1f79bbdc0a97">writer</a>);
<a name="l00041"></a>00041   <span class="keyword">const_cast&lt;</span><a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>*<span class="keyword">&gt;</span>(<a class="code" href="a00103.html#a0abc6edc2b69b52286df209039c0c118">metadata</a>)-&gt;registerClass(
<a name="l00042"></a>00042     <span class="stringliteral">&quot;load&quot;</span>,<span class="stringliteral">&quot;load&quot;</span>,<span class="keyword">true</span>,Object::createDefault&lt;Load&gt;
<a name="l00043"></a>00043     );
<a name="l00044"></a>00044 
<a name="l00045"></a>00045   <span class="comment">// Initialize the Python class</span>
<a name="l00046"></a>00046   <a class="code" href="a00155.html" title="This class is a thin wrapper around the type information in Python.">PythonType</a>&amp; x = <a class="code" href="a00103.html#aeee91176d13b29bfef8ca0b680c382e7">FreppleCategory&lt;Load&gt;::getType</a>();
<a name="l00047"></a>00047   x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(<span class="stringliteral">&quot;load&quot;</span>);
<a name="l00048"></a>00048   x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">&quot;frePPLe load&quot;</span>);
<a name="l00049"></a>00049   x.<a class="code" href="a00155.html#a8d3f24e0357f41ac3bc0be78bd2ab268">supportgetattro</a>();
<a name="l00050"></a>00050   x.<a class="code" href="a00155.html#a83866bef191c69cf8506426fe38b8d19">supportsetattro</a>();
<a name="l00051"></a>00051   x.<a class="code" href="a00155.html#a001dc53b2dd832c001aee4d21bc7bf09">supportcreate</a>(create);
<a name="l00052"></a>00052   x.<a class="code" href="a00155.html#ab5950f891179f3ae7d31f4977580cb1d">addMethod</a>(<span class="stringliteral">&quot;toXML&quot;</span>, <a class="code" href="a00120.html#a936a4ac5b81ba4f9c9cbe54b9aeeda13">toXML</a>, METH_VARARGS, <span class="stringliteral">&quot;return a XML representation&quot;</span>);
<a name="l00053"></a>00053   <span class="keyword">const_cast&lt;</span><a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>*<span class="keyword">&gt;</span>(<a class="code" href="a00103.html#a0abc6edc2b69b52286df209039c0c118">Load::metadata</a>)-&gt;pythonClass = x.<a class="code" href="a00155.html#aed0915f1cc32c0c1e12e209abfedf615">type_object</a>();
<a name="l00054"></a>00054   <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>();
<a name="l00055"></a>00055 }
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 
<a name="l00058"></a><a class="code" href="a00103.html#ae1cacbcbdac199c21beb1f79bbdc0a97">00058</a> <span class="keywordtype">void</span> <a class="code" href="a00103.html#ae1cacbcbdac199c21beb1f79bbdc0a97">Load::writer</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>* c, <a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a>* o)
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060   <span class="keywordtype">bool</span> firstload = <span class="keyword">true</span>;
<a name="l00061"></a>00061   <span class="keywordflow">for</span> (Operation::iterator i = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Operation::begin</a>(); i != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Operation::end</a>(); ++i)
<a name="l00062"></a>00062     <span class="keywordflow">for</span> (Operation::loadlist::const_iterator j = i-&gt;getLoads().begin(); j != i-&gt;getLoads().end(); ++j)
<a name="l00063"></a>00063     {
<a name="l00064"></a>00064       <span class="keywordflow">if</span> (firstload)
<a name="l00065"></a>00065       {
<a name="l00066"></a>00066         o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(<a class="code" href="a00177.html#a2e32d4c89079c071ec2bd8e634e9b440">Tags::tag_loads</a>);
<a name="l00067"></a>00067         firstload = <span class="keyword">false</span>;
<a name="l00068"></a>00068       }
<a name="l00069"></a>00069       <span class="comment">// We use the FULL mode, to force the loads being written regardless</span>
<a name="l00070"></a>00070       <span class="comment">// of the depth in the XML tree.</span>
<a name="l00071"></a>00071       o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ad82a69d14ccb381f200a1af582cb98e2">Tags::tag_load</a>, &amp;*j, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398ae6f8960699e19b8d77b093b7e2c48619">FULL</a>);
<a name="l00072"></a>00072     }
<a name="l00073"></a>00073   <span class="keywordflow">if</span> (!firstload) o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(<a class="code" href="a00177.html#a2e32d4c89079c071ec2bd8e634e9b440">Tags::tag_loads</a>);
<a name="l00074"></a>00074 }
<a name="l00075"></a>00075 
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> Load::validate(<a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a> action)
<a name="l00078"></a>00078 {
<a name="l00079"></a>00079   <span class="comment">// Catch null operation and resource pointers</span>
<a name="l00080"></a>00080   <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a> *oper = <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>();
<a name="l00081"></a>00081   <a class="code" href="a00156.html" title="This class represents a workcentre, a physical or logical representation of capacity...">Resource</a> *res = <a class="code" href="a00103.html#ab929aafe9c6085a216ad3084ec23c93b">getResource</a>();
<a name="l00082"></a>00082   <span class="keywordflow">if</span> (!oper || !res)
<a name="l00083"></a>00083   {
<a name="l00084"></a>00084     <span class="comment">// Invalid load model</span>
<a name="l00085"></a>00085     <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00086"></a>00086     <span class="keywordflow">if</span> (!oper &amp;&amp; !res)
<a name="l00087"></a>00087       <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;Missing operation and resource on a load&quot;</span>);
<a name="l00088"></a>00088     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!oper)
<a name="l00089"></a>00089       <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;Missing operation on a load on resource &apos;&quot;</span>
<a name="l00090"></a>00090           + res-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l00091"></a>00091     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!res)
<a name="l00092"></a>00092       <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;Missing resource on a load on operation &apos;&quot;</span>
<a name="l00093"></a>00093           + oper-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l00094"></a>00094   }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096   <span class="comment">// Check if a load with 1) identical resource, 2) identical operation and</span>
<a name="l00097"></a>00097   <span class="comment">// 3) overlapping effectivity dates already exists</span>
<a name="l00098"></a>00098   Operation::loadlist::const_iterator i = oper-&gt;<a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().begin();
<a name="l00099"></a>00099   <span class="keywordflow">for</span> (;i != oper-&gt;<a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().end(); ++i)
<a name="l00100"></a>00100     <span class="keywordflow">if</span> (i-&gt;getResource() == res
<a name="l00101"></a>00101       &amp;&amp; i-&gt;getEffective().overlap(<a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>())
<a name="l00102"></a>00102       &amp;&amp; &amp;*i != <span class="keyword">this</span>)
<a name="l00103"></a>00103         <span class="keywordflow">break</span>;
<a name="l00104"></a>00104 
<a name="l00105"></a>00105   <span class="comment">// Apply the appropriate action</span>
<a name="l00106"></a>00106   <span class="keywordflow">switch</span> (action)
<a name="l00107"></a>00107   {
<a name="l00108"></a>00108     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a8f6183fcf54ca6985ff2b5ef80673a25">ADD</a>:
<a name="l00109"></a>00109       <span class="keywordflow">if</span> (i != oper-&gt;<a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().end())
<a name="l00110"></a>00110       {
<a name="l00111"></a>00111         <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00112"></a>00112         <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;Load of &apos;&quot;</span> + oper-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos; and &apos;&quot;</span>
<a name="l00113"></a>00113             + res-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos; already exists&quot;</span>);
<a name="l00114"></a>00114       }
<a name="l00115"></a>00115       <span class="keywordflow">break</span>;
<a name="l00116"></a>00116     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a1b9888c025bb8f78e322471fd5e14423">CHANGE</a>:
<a name="l00117"></a>00117       <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00118"></a>00118       <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Can&apos;t update a load&quot;</span>);
<a name="l00119"></a>00119     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a75b4aab762127e8083e16661b4021a00">ADD_CHANGE</a>:
<a name="l00120"></a>00120       <span class="comment">// ADD is handled in the code after the switch statement</span>
<a name="l00121"></a>00121       <span class="keywordflow">if</span> (i == oper-&gt;<a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().end()) <span class="keywordflow">break</span>;
<a name="l00122"></a>00122       <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00123"></a>00123       <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Can&apos;t update a load&quot;</span>);
<a name="l00124"></a>00124     <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a6b9fb19e9a6595385dec31b63e0054e1">REMOVE</a>:
<a name="l00125"></a>00125       <span class="comment">// This load was only used temporarily during the reading process</span>
<a name="l00126"></a>00126       <span class="keyword">delete</span> <span class="keyword">this</span>;
<a name="l00127"></a>00127       <span class="keywordflow">if</span> (i == oper-&gt;<a class="code" href="a00121.html#a7b95131f687f60ec30165e14876dac7c">getLoads</a>().end())
<a name="l00128"></a>00128         <span class="comment">// Nothing to delete</span>
<a name="l00129"></a>00129         <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Can&apos;t remove nonexistent load of &apos;&quot;</span>
<a name="l00130"></a>00130             + oper-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos; and &apos;&quot;</span> + res-&gt;<a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l00131"></a>00131       <span class="keyword">delete</span> &amp;*i;
<a name="l00132"></a>00132       <span class="comment">// Set a flag to make sure the level computation is triggered again</span>
<a name="l00133"></a>00133       <a class="code" href="a00084.html#a93fd169e7f2260c640cb278cac466025">HasLevel::triggerLazyRecomputation</a>();
<a name="l00134"></a>00134       <span class="keywordflow">return</span>;
<a name="l00135"></a>00135   }
<a name="l00136"></a>00136 
<a name="l00137"></a>00137   <span class="comment">// The statements below should be executed only when a new load is created.</span>
<a name="l00138"></a>00138 
<a name="l00139"></a>00139   <span class="comment">// If the resource has an owner, also load the owner</span>
<a name="l00140"></a>00140   <span class="comment">// Note that the owner load can create more loads if it has an owner too.</span>
<a name="l00141"></a>00141   <span class="keywordflow">if</span> (res-&gt;<a class="code" href="a00083.html#a82647634fd837064ba411d51495cfbbd">hasOwner</a>() &amp;&amp; action!=<a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a6b9fb19e9a6595385dec31b63e0054e1">REMOVE</a>) <span class="keyword">new</span> <a class="code" href="a00103.html#a4ce25fb7a9346e3d89aedd249cc6ab07">Load</a>(oper, res-&gt;<a class="code" href="a00083.html#a4bda4eb77f34c0528e176446886fcce1">getOwner</a>(), qty);
<a name="l00142"></a>00142 
<a name="l00143"></a>00143   <span class="comment">// Set a flag to make sure the level computation is triggered again</span>
<a name="l00144"></a>00144   <a class="code" href="a00084.html#a93fd169e7f2260c640cb278cac466025">HasLevel::triggerLazyRecomputation</a>();
<a name="l00145"></a>00145 }
<a name="l00146"></a>00146 
<a name="l00147"></a>00147 
<a name="l00148"></a><a class="code" href="a00103.html#a84c0739c123a504da8afdd35810dbdde">00148</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00103.html#a84c0739c123a504da8afdd35810dbdde">Load::~Load</a>()
<a name="l00149"></a>00149 {
<a name="l00150"></a>00150   <span class="comment">// Set a flag to make sure the level computation is triggered again</span>
<a name="l00151"></a>00151   <a class="code" href="a00084.html#a93fd169e7f2260c640cb278cac466025">HasLevel::triggerLazyRecomputation</a>();
<a name="l00152"></a>00152 
<a name="l00153"></a>00153   <span class="comment">// Delete existing loadplans</span>
<a name="l00154"></a>00154   <span class="keywordflow">if</span> (<a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>() &amp;&amp; <a class="code" href="a00103.html#ab929aafe9c6085a216ad3084ec23c93b">getResource</a>())
<a name="l00155"></a>00155   {
<a name="l00156"></a>00156     <span class="comment">// Loop over operationplans</span>
<a name="l00157"></a>00157     <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(<a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()); i != <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>(); ++i)
<a name="l00158"></a>00158       <span class="comment">// Loop over loadplans</span>
<a name="l00159"></a>00159       <span class="keywordflow">for</span>(<a class="code" href="a00106.html" title="An iterator class to go through all loadplans of an operationplan.">OperationPlan::LoadPlanIterator</a> j = i-&gt;beginLoadPlans(); j != i-&gt;endLoadPlans(); )
<a name="l00160"></a>00160         <span class="keywordflow">if</span> (j-&gt;getLoad() == <span class="keyword">this</span>) j.deleteLoadPlan();
<a name="l00161"></a>00161         <span class="keywordflow">else</span> ++j;
<a name="l00162"></a>00162   }
<a name="l00163"></a>00163 
<a name="l00164"></a>00164   <span class="comment">// Delete the load from the operation and resource</span>
<a name="l00165"></a>00165   <span class="keywordflow">if</span> (<a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()) <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.erase(<span class="keyword">this</span>);
<a name="l00166"></a>00166   <span class="keywordflow">if</span> (<a class="code" href="a00103.html#ab929aafe9c6085a216ad3084ec23c93b">getResource</a>()) <a class="code" href="a00103.html#ab929aafe9c6085a216ad3084ec23c93b">getResource</a>()-&gt;loads.erase(<span class="keyword">this</span>);
<a name="l00167"></a>00167 
<a name="l00168"></a>00168   <span class="comment">// Clean up alternate loads</span>
<a name="l00169"></a>00169   <span class="keywordflow">if</span> (hasAlts)
<a name="l00170"></a>00170   {
<a name="l00171"></a>00171     <span class="comment">// The load has alternates.</span>
<a name="l00172"></a>00172     <span class="comment">// Make a new load the leading one. Or if there is only one alternate</span>
<a name="l00173"></a>00173     <span class="comment">// present it is not marked as an alternate any more.</span>
<a name="l00174"></a>00174     <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> cnt = 0;
<a name="l00175"></a>00175     <span class="keywordtype">int</span> minprio = INT_MAX;
<a name="l00176"></a>00176     <a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a>* newLeader = NULL;
<a name="l00177"></a>00177     <span class="keywordflow">for</span> (Operation::loadlist::iterator i = <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>();
<a name="l00178"></a>00178       i != <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.end(); ++i)
<a name="l00179"></a>00179       <span class="keywordflow">if</span> (i-&gt;altLoad == <span class="keyword">this</span>)
<a name="l00180"></a>00180       {
<a name="l00181"></a>00181         cnt++;
<a name="l00182"></a>00182         <span class="keywordflow">if</span> (i-&gt;priority &lt; minprio)
<a name="l00183"></a>00183         {
<a name="l00184"></a>00184           newLeader = &amp;*i;
<a name="l00185"></a>00185           minprio = i-&gt;priority;
<a name="l00186"></a>00186         }
<a name="l00187"></a>00187       }
<a name="l00188"></a>00188     <span class="keywordflow">if</span> (cnt &lt; 1)
<a name="l00189"></a>00189       <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;Alternate loads update failure&quot;</span>);
<a name="l00190"></a>00190     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cnt == 1)
<a name="l00191"></a>00191       <span class="comment">// No longer an alternate any more</span>
<a name="l00192"></a>00192       newLeader-&gt;altLoad = NULL;
<a name="l00193"></a>00193     <span class="keywordflow">else</span>
<a name="l00194"></a>00194     {
<a name="l00195"></a>00195       <span class="comment">// Mark a new leader load</span>
<a name="l00196"></a>00196       newLeader-&gt;hasAlts = <span class="keyword">true</span>;
<a name="l00197"></a>00197       newLeader-&gt;altLoad = NULL;
<a name="l00198"></a>00198       <span class="keywordflow">for</span> (Operation::loadlist::iterator i = <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>();
<a name="l00199"></a>00199         i != <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.end(); ++i)
<a name="l00200"></a>00200         <span class="keywordflow">if</span> (i-&gt;altLoad == <span class="keyword">this</span>) i-&gt;altLoad = newLeader;
<a name="l00201"></a>00201     }
<a name="l00202"></a>00202   }
<a name="l00203"></a>00203   <span class="keywordflow">if</span> (altLoad)
<a name="l00204"></a>00204   {
<a name="l00205"></a>00205     <span class="comment">// The load is an alternate of another one.</span>
<a name="l00206"></a>00206     <span class="comment">// If it was the only alternate, then the hasAlts flag on the parent</span>
<a name="l00207"></a>00207     <span class="comment">// load needs to be set back to false</span>
<a name="l00208"></a>00208     <span class="keywordtype">bool</span> only_one = <span class="keyword">true</span>;
<a name="l00209"></a>00209     <span class="keywordflow">for</span> (Operation::loadlist::iterator i = <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.begin();
<a name="l00210"></a>00210       i != <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.end(); ++i)
<a name="l00211"></a>00211       <span class="keywordflow">if</span> (i-&gt;altLoad == altLoad)
<a name="l00212"></a>00212       {
<a name="l00213"></a>00213         only_one = <span class="keyword">false</span>;
<a name="l00214"></a>00214         <span class="keywordflow">break</span>;
<a name="l00215"></a>00215       }
<a name="l00216"></a>00216     <span class="keywordflow">if</span> (only_one) altLoad-&gt;hasAlts = <span class="keyword">false</span>;
<a name="l00217"></a>00217   }
<a name="l00218"></a>00218 }
<a name="l00219"></a>00219 
<a name="l00220"></a>00220 
<a name="l00221"></a><a class="code" href="a00103.html#a21bfb581059ea14921565dd86f7fb007">00221</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00103.html#a21bfb581059ea14921565dd86f7fb007">Load::setAlternate</a>(<a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a> *f)
<a name="l00222"></a>00222 {
<a name="l00223"></a>00223   <span class="comment">// Validate the argument</span>
<a name="l00224"></a>00224   <span class="keywordflow">if</span> (!f)
<a name="l00225"></a>00225     <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;Setting NULL alternate load&quot;</span>);
<a name="l00226"></a>00226   <span class="keywordflow">if</span> (hasAlts || f-&gt;altLoad)
<a name="l00227"></a>00227     <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;Nested alternate loads are not allowed&quot;</span>);
<a name="l00228"></a>00228 
<a name="l00229"></a>00229   <span class="comment">// Update both flows</span>
<a name="l00230"></a>00230   f-&gt;hasAlts = <span class="keyword">true</span>;
<a name="l00231"></a>00231   altLoad = f;
<a name="l00232"></a>00232 }
<a name="l00233"></a>00233 
<a name="l00234"></a>00234 
<a name="l00235"></a><a class="code" href="a00103.html#a403906d3bdeb89d1c2887c4c60d5b8ff">00235</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00103.html#a21bfb581059ea14921565dd86f7fb007">Load::setAlternate</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>&amp; n)
<a name="l00236"></a>00236 {
<a name="l00237"></a>00237   <span class="keywordflow">if</span> (!<a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>())
<a name="l00238"></a>00238     <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 set an alternate load before setting the operation&quot;</span>);
<a name="l00239"></a>00239   <a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a> *x = <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.find(n);
<a name="l00240"></a>00240   <span class="keywordflow">if</span> (!x) <span class="keywordflow">throw</span> <a class="code" href="a00048.html" title="An exception of this type is thrown when data errors are found.">DataException</a>(<span class="stringliteral">&quot;Can&apos;t find load with name &apos;&quot;</span> + n + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l00241"></a>00241   <a class="code" href="a00103.html#a21bfb581059ea14921565dd86f7fb007">setAlternate</a>(x);
<a name="l00242"></a>00242 }
<a name="l00243"></a>00243 
<a name="l00244"></a>00244 
<a name="l00245"></a><a class="code" href="a00103.html#a16e0939e73cd0dd9fae41145caf70931">00245</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00103.html#a16e0939e73cd0dd9fae41145caf70931">Load::setSetup</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> n)
<a name="l00246"></a>00246 {
<a name="l00247"></a>00247   setup = n;
<a name="l00248"></a>00248 
<a name="l00249"></a>00249   <span class="keywordflow">if</span> (!setup.empty())
<a name="l00250"></a>00250   {
<a name="l00251"></a>00251     <span class="comment">// Guarantuee that only a single load has a setup.</span>
<a name="l00252"></a>00252     <span class="comment">// Alternates of that load can have a setup as well.</span>
<a name="l00253"></a>00253     <span class="keywordflow">for</span> (Operation::loadlist::iterator i = <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.begin();
<a name="l00254"></a>00254       i != <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>()-&gt;loaddata.end(); ++i)
<a name="l00255"></a>00255       <span class="keywordflow">if</span> (&amp;*i != <span class="keyword">this</span> &amp;&amp; !i-&gt;setup.empty() 
<a name="l00256"></a>00256         &amp;&amp; i-&gt;getAlternate() != <span class="keyword">this</span> &amp;&amp; <a class="code" href="a00103.html#aa2c9280733f439ea3766f8b2459f9151">getAlternate</a>() != &amp;*i 
<a name="l00257"></a>00257         &amp;&amp; i-&gt;<a class="code" href="a00103.html#aa2c9280733f439ea3766f8b2459f9151">getAlternate</a>() != <a class="code" href="a00103.html#aa2c9280733f439ea3766f8b2459f9151">getAlternate</a>())
<a name="l00258"></a>00258         <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;Only a single load of an operation can specify a setup&quot;</span>);
<a name="l00259"></a>00259   }
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261 
<a name="l00262"></a>00262 
<a name="l00263"></a><a class="code" href="a00103.html#a5ea80e6ec27b0e31eec7b7e3b2baf83d">00263</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00103.html#a5ea80e6ec27b0e31eec7b7e3b2baf83d">Load::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="l00264"></a>00264 <span class="keyword"></span>{
<a name="l00265"></a>00265   <span class="comment">// If the load has already been saved, no need to repeat it again</span>
<a name="l00266"></a>00266   <span class="comment">// A &apos;reference&apos; to a load is not useful to be saved.</span>
<a name="l00267"></a>00267   <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>) <span class="keywordflow">return</span>;
<a name="l00268"></a>00268   assert(m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>);
<a name="l00269"></a>00269 
<a name="l00270"></a>00270   o-&gt;<a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(tag);
<a name="l00271"></a>00271 
<a name="l00272"></a>00272   <span class="comment">// If the load is defined inside of an operation tag, we don&apos;t need to save</span>
<a name="l00273"></a>00273   <span class="comment">// the operation. Otherwise we do save it...</span>
<a name="l00274"></a>00274   <span class="keywordflow">if</span> (!dynamic_cast&lt;Operation*&gt;(o-&gt;<a class="code" href="a00189.html#ab1c39c9ee1016cc2d29152fa95fa769d">getPreviousObject</a>()))
<a name="l00275"></a>00275     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>, <a class="code" href="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>());
<a name="l00276"></a>00276 
<a name="l00277"></a>00277   <span class="comment">// If the load is defined inside of an resource tag, we don&apos;t need to save</span>
<a name="l00278"></a>00278   <span class="comment">// the resource. Otherwise we do save it...</span>
<a name="l00279"></a>00279   <span class="keywordflow">if</span> (!dynamic_cast&lt;Resource*&gt;(o-&gt;<a class="code" href="a00189.html#ab1c39c9ee1016cc2d29152fa95fa769d">getPreviousObject</a>()))
<a name="l00280"></a>00280     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a6d26a78a470df1af466b504a120ff98f">Tags::tag_resource</a>, <a class="code" href="a00103.html#ab929aafe9c6085a216ad3084ec23c93b">getResource</a>());
<a name="l00281"></a>00281 
<a name="l00282"></a>00282   <span class="comment">// Write the quantity, priority, name and alternate</span>
<a name="l00283"></a>00283   <span class="keywordflow">if</span> (qty != 1.0) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ab99ddcbeef0f5d15a8731dcdffa0dcff">Tags::tag_quantity</a>, qty);
<a name="l00284"></a>00284   <span class="keywordflow">if</span> (<a class="code" href="a00103.html#a0d0ec833e41b3595901349ca17f66956">getPriority</a>()!=1) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>, <a class="code" href="a00103.html#a0d0ec833e41b3595901349ca17f66956">getPriority</a>());
<a name="l00285"></a>00285   <span class="keywordflow">if</span> (!<a class="code" href="a00118.html#affaaf99e62eb70939f0ccc0ddc313c57">getName</a>().empty()) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, <a class="code" href="a00118.html#affaaf99e62eb70939f0ccc0ddc313c57">getName</a>());
<a name="l00286"></a>00286   <span class="keywordflow">if</span> (<a class="code" href="a00103.html#aa2c9280733f439ea3766f8b2459f9151">getAlternate</a>())
<a name="l00287"></a>00287     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>, <a class="code" href="a00103.html#aa2c9280733f439ea3766f8b2459f9151">getAlternate</a>()-&gt;<a class="code" href="a00118.html#affaaf99e62eb70939f0ccc0ddc313c57">getName</a>());
<a name="l00288"></a>00288   <span class="keywordflow">if</span> (search != <a class="code" href="a00256.html#aa439ebf4ddfb4983ac3d44abacb9b749a20f9fef00fcbc3cd9fbd27a8a41c1d83">PRIORITY</a>)
<a name="l00289"></a>00289   {
<a name="l00290"></a>00290     ostringstream ch;
<a name="l00291"></a>00291     ch &lt;&lt; <a class="code" href="a00103.html#a71f05cf78bb1925c4af3dc8494641a57">getSearch</a>();
<a name="l00292"></a>00292     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a0364c7fc29b0d795dfa1624947efd387">Tags::tag_search</a>, ch.str());
<a name="l00293"></a>00293   }
<a name="l00294"></a>00294 
<a name="l00295"></a>00295   <span class="comment">// Write the effective daterange</span>
<a name="l00296"></a>00296   <span class="keywordflow">if</span> (<a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>() != Date::infinitePast)
<a name="l00297"></a>00297     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ae1f2e352a23d5deaddd90a377e1980cd">Tags::tag_effective_start</a>, <a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().getStart());
<a name="l00298"></a>00298   <span class="keywordflow">if</span> (<a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().getEnd() != Date::infiniteFuture)
<a name="l00299"></a>00299     o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a0bd36aad5b52bb4ec75d969fe351f583">Tags::tag_effective_end</a>, <a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().getEnd());
<a name="l00300"></a>00300 
<a name="l00301"></a>00301   <span class="comment">// Write the required setup</span>
<a name="l00302"></a>00302   <span class="keywordflow">if</span> (!setup.empty()) o-&gt;<a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a16bef223df3695e99b5e22a14ce0ef20">Tags::tag_setup</a>, setup);
<a name="l00303"></a>00303 
<a name="l00304"></a>00304   o-&gt;<a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag);
<a name="l00305"></a>00305 }
<a name="l00306"></a>00306 
<a name="l00307"></a>00307 
<a name="l00308"></a><a class="code" href="a00103.html#a2d04b2c99b6ce43cbea8a76ce06859dc">00308</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00103.html#a2d04b2c99b6ce43cbea8a76ce06859dc">Load::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="l00309"></a>00309 {
<a name="l00310"></a>00310   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#a6d26a78a470df1af466b504a120ff98f">Tags::tag_resource</a>))
<a name="l00311"></a>00311     pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>( <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">Resource::reader</a>(<a class="code" href="a00156.html#a1be825fa478f96d8d3a67d18b50eace6">Resource::metadata</a>,pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()) );
<a name="l00312"></a>00312   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>))
<a name="l00313"></a>00313     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="l00314"></a>00314 }
<a name="l00315"></a>00315 
<a name="l00316"></a>00316 
<a name="l00317"></a><a class="code" href="a00103.html#adbcb964c3c54613bb3102bfbc567c3a3">00317</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00103.html#adbcb964c3c54613bb3102bfbc567c3a3">Load::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="l00318"></a>00318 {
<a name="l00319"></a>00319   <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#a6d26a78a470df1af466b504a120ff98f">Tags::tag_resource</a>))
<a name="l00320"></a>00320   {
<a name="l00321"></a>00321     <a class="code" href="a00156.html" title="This class represents a workcentre, a physical or logical representation of capacity...">Resource</a> * r = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="a00156.html" title="This class represents a workcentre, a physical or logical representation of capacity...">Resource</a>*<span class="keyword">&gt;</span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>());
<a name="l00322"></a>00322     <span class="keywordflow">if</span> (r) <a class="code" href="a00103.html#a90023cac148b876db4f1bb3da876f21c">setResource</a>(r);
<a name="l00323"></a>00323     <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="l00324"></a>00324   }
<a name="l00325"></a>00325   <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="l00326"></a>00326   {
<a name="l00327"></a>00327     <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">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="l00328"></a>00328     <span class="keywordflow">if</span> (o) <a class="code" href="a00103.html#a5f1714647aeb77dd01095bd74c3e9830">setOperation</a>(o);
<a name="l00329"></a>00329     <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="l00330"></a>00330   }
<a name="l00331"></a>00331   <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#ab99ddcbeef0f5d15a8731dcdffa0dcff">Tags::tag_quantity</a>))
<a name="l00332"></a>00332     <a class="code" href="a00103.html#aa39839141ec642898b6b7331f61514ef">setQuantity</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>());
<a name="l00333"></a>00333   <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="l00334"></a>00334     <a class="code" href="a00103.html#a70b9905e05f59754ca0b739c98720d83">setPriority</a>(pElement.<a class="code" href="a00047.html#a0d8c973cc584400f5ea5d8acfd82ace2">getInt</a>());
<a name="l00335"></a>00335   <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#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>))
<a name="l00336"></a>00336     <a class="code" href="a00118.html#aad94a1f71b6c996f21de620a396deee8">setName</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>());
<a name="l00337"></a>00337   <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#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>))
<a name="l00338"></a>00338     <a class="code" href="a00103.html#a21bfb581059ea14921565dd86f7fb007">setAlternate</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>());
<a name="l00339"></a>00339   <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="l00340"></a>00340     <a class="code" href="a00103.html#a5190926294619bb17a441345c754d333">setSearch</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>());
<a name="l00341"></a>00341   <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#a16bef223df3695e99b5e22a14ce0ef20">Tags::tag_setup</a>))
<a name="l00342"></a>00342     <a class="code" href="a00103.html#a16e0939e73cd0dd9fae41145caf70931">setSetup</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>());
<a name="l00343"></a>00343   <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#a391c4d3fc071199c00a248d992d623dd">Tags::tag_action</a>))
<a name="l00344"></a>00344   {
<a name="l00345"></a>00345     <span class="keyword">delete</span> <span class="keyword">static_cast&lt;</span><a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a>*<span class="keyword">&gt;</span>(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>());
<a name="l00346"></a>00346     pIn.<a class="code" href="a00186.html#af76fa6f3fe40bd167a36b4ab859e0ff6">setUserArea</a>(
<a name="l00347"></a>00347       <span class="keyword">new</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a>(MetaClass::decodeAction(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>().c_str()))
<a name="l00348"></a>00348     );
<a name="l00349"></a>00349   }
<a name="l00350"></a>00350   <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="l00351"></a>00351     <a class="code" href="a00118.html#a71ec773359069c5e359e22aa51feff65">setEffectiveEnd</a>(pElement.<a class="code" href="a00047.html#abe8c2019e5f79328a6a1fa1f3bb4bbae">getDate</a>());
<a name="l00352"></a>00352   <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="l00353"></a>00353     <a class="code" href="a00118.html#a72f447f9560509a5c9ca04250e6f2981">setEffectiveStart</a>(pElement.<a class="code" href="a00047.html#abe8c2019e5f79328a6a1fa1f3bb4bbae">getDate</a>());
<a name="l00354"></a>00354   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pIn.<a class="code" href="a00186.html#a42fe5e4ae141efb84744b8a359e38bd9">isObjectEnd</a>())
<a name="l00355"></a>00355   {
<a name="l00356"></a>00356     <span class="comment">// The load data is now all read in. See if it makes sense now...</span>
<a name="l00357"></a>00357     validate(!pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>() ?
<a name="l00358"></a>00358              <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a75b4aab762127e8083e16661b4021a00">ADD_CHANGE</a> :
<a name="l00359"></a>00359              *<span class="keyword">static_cast&lt;</span><a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a>*<span class="keyword">&gt;</span>(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>())
<a name="l00360"></a>00360              );
<a name="l00361"></a>00361     <span class="keyword">delete</span> <span class="keyword">static_cast&lt;</span><a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a>*<span class="keyword">&gt;</span>(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>());
<a name="l00362"></a>00362   }
<a name="l00363"></a>00363 }
<a name="l00364"></a>00364 
<a name="l00365"></a>00365 
<a name="l00366"></a><a class="code" href="a00103.html#a9bcc4b30fb83164c39ffb294b86c2832">00366</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00103.html#a9bcc4b30fb83164c39ffb294b86c2832">Load::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="l00367"></a>00367 {
<a name="l00368"></a>00368   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a6d26a78a470df1af466b504a120ff98f">Tags::tag_resource</a>))
<a name="l00369"></a>00369     <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="a00103.html#ab929aafe9c6085a216ad3084ec23c93b">getResource</a>());
<a name="l00370"></a>00370   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>))
<a name="l00371"></a>00371     <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="a00103.html#a6cb533b9f893a9af0137bf78b07e3987">getOperation</a>());
<a name="l00372"></a>00372   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ab99ddcbeef0f5d15a8731dcdffa0dcff">Tags::tag_quantity</a>))
<a name="l00373"></a>00373     <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="a00103.html#a8def658dae973c6e51034680baf13c70">getQuantity</a>());
<a name="l00374"></a>00374   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>))
<a name="l00375"></a>00375     <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="a00103.html#a0d0ec833e41b3595901349ca17f66956">getPriority</a>());
<a name="l00376"></a>00376   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a0bd36aad5b52bb4ec75d969fe351f583">Tags::tag_effective_end</a>))
<a name="l00377"></a>00377     <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="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>());
<a name="l00378"></a>00378   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#ae1f2e352a23d5deaddd90a377e1980cd">Tags::tag_effective_start</a>))
<a name="l00379"></a>00379     <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="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>());
<a name="l00380"></a>00380   <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="l00381"></a>00381     <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="a00118.html#affaaf99e62eb70939f0ccc0ddc313c57">getName</a>());
<a name="l00382"></a>00382   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>))
<a name="l00383"></a>00383     <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="a00103.html#aa2c9280733f439ea3766f8b2459f9151">getAlternate</a>());
<a name="l00384"></a>00384   <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="l00385"></a>00385   {
<a name="l00386"></a>00386     ostringstream ch;
<a name="l00387"></a>00387     ch &lt;&lt; <a class="code" href="a00103.html#a71f05cf78bb1925c4af3dc8494641a57">getSearch</a>();
<a name="l00388"></a>00388     <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="l00389"></a>00389   }
<a name="l00390"></a>00390   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a16bef223df3695e99b5e22a14ce0ef20">Tags::tag_setup</a>))
<a name="l00391"></a>00391     <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="a00103.html#a7cab9031b62cd9d89a924ff5dcb2aa60">getSetup</a>());
<a name="l00392"></a>00392   <span class="keywordflow">return</span> NULL;
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394 
<a name="l00395"></a>00395 
<a name="l00396"></a><a class="code" href="a00103.html#af71ff01487d4c328888ff9730bc06d50">00396</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> <a class="code" href="a00103.html#af71ff01487d4c328888ff9730bc06d50">Load::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="l00397"></a>00397 {
<a name="l00398"></a>00398   <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#a6d26a78a470df1af466b504a120ff98f">Tags::tag_resource</a>))
<a name="l00399"></a>00399   {
<a name="l00400"></a>00400     <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00156.html#a1be825fa478f96d8d3a67d18b50eace6">Resource::metadata</a>))
<a name="l00401"></a>00401     {
<a name="l00402"></a>00402       PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">&quot;load resource must be of type resource&quot;</span>);
<a name="l00403"></a>00403       <span class="keywordflow">return</span> -1;
<a name="l00404"></a>00404     }
<a name="l00405"></a>00405     <a class="code" href="a00156.html" title="This class represents a workcentre, a physical or logical representation of capacity...">Resource</a>* y = <span class="keyword">static_cast&lt;</span><a class="code" href="a00156.html" title="This class represents a workcentre, a physical or logical representation of capacity...">Resource</a>*<span class="keyword">&gt;</span>(<span class="keyword">static_cast&lt;</span>PyObject*<span class="keyword">&gt;</span>(field));
<a name="l00406"></a>00406     <a class="code" href="a00103.html#a90023cac148b876db4f1bb3da876f21c">setResource</a>(y);
<a name="l00407"></a>00407   }
<a name="l00408"></a>00408   <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#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>))
<a name="l00409"></a>00409   {
<a name="l00410"></a>00410     <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>))
<a name="l00411"></a>00411     {
<a name="l00412"></a>00412       PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">&quot;load operation must be of type operation&quot;</span>);
<a name="l00413"></a>00413       <span class="keywordflow">return</span> -1;
<a name="l00414"></a>00414     }
<a name="l00415"></a>00415     <a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>* y = <span class="keyword">static_cast&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">static_cast&lt;</span>PyObject*<span class="keyword">&gt;</span>(field));
<a name="l00416"></a>00416     <a class="code" href="a00103.html#a5f1714647aeb77dd01095bd74c3e9830">setOperation</a>(y);
<a name="l00417"></a>00417   }
<a name="l00418"></a>00418   <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#ab99ddcbeef0f5d15a8731dcdffa0dcff">Tags::tag_quantity</a>))
<a name="l00419"></a>00419     <a class="code" href="a00103.html#aa39839141ec642898b6b7331f61514ef">setQuantity</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>());
<a name="l00420"></a>00420   <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#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>))
<a name="l00421"></a>00421     <a class="code" href="a00103.html#a70b9905e05f59754ca0b739c98720d83">setPriority</a>(field.<a class="code" href="a00154.html#a783ec10f02cad37886df55bc3f08ba5e">getInt</a>());
<a name="l00422"></a>00422   <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#a0bd36aad5b52bb4ec75d969fe351f583">Tags::tag_effective_end</a>))
<a name="l00423"></a>00423     <a class="code" href="a00118.html#a71ec773359069c5e359e22aa51feff65">setEffectiveEnd</a>(field.<a class="code" href="a00154.html#aa72c83cab5f89f71aff63f0bfad26bd1">getDate</a>());
<a name="l00424"></a>00424   <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#ae1f2e352a23d5deaddd90a377e1980cd">Tags::tag_effective_start</a>))
<a name="l00425"></a>00425     <a class="code" href="a00118.html#a72f447f9560509a5c9ca04250e6f2981">setEffectiveStart</a>(field.<a class="code" href="a00154.html#aa72c83cab5f89f71aff63f0bfad26bd1">getDate</a>());
<a name="l00426"></a>00426   <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#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>))
<a name="l00427"></a>00427     <a class="code" href="a00118.html#aad94a1f71b6c996f21de620a396deee8">setName</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l00428"></a>00428   <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#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>))
<a name="l00429"></a>00429   {
<a name="l00430"></a>00430     <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00103.html#a0abc6edc2b69b52286df209039c0c118">Load::metadata</a>))
<a name="l00431"></a>00431       <a class="code" href="a00103.html#a21bfb581059ea14921565dd86f7fb007">setAlternate</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l00432"></a>00432     <span class="keywordflow">else</span>
<a name="l00433"></a>00433     {
<a name="l00434"></a>00434       <a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a> *y = <span class="keyword">static_cast&lt;</span><a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a>*<span class="keyword">&gt;</span>(<span class="keyword">static_cast&lt;</span>PyObject*<span class="keyword">&gt;</span>(field));
<a name="l00435"></a>00435       <a class="code" href="a00103.html#a21bfb581059ea14921565dd86f7fb007">setAlternate</a>(y);
<a name="l00436"></a>00436     }
<a name="l00437"></a>00437   }
<a name="l00438"></a>00438   <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#a0364c7fc29b0d795dfa1624947efd387">Tags::tag_search</a>))
<a name="l00439"></a>00439     <a class="code" href="a00103.html#a5190926294619bb17a441345c754d333">setSearch</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l00440"></a>00440   <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#a16bef223df3695e99b5e22a14ce0ef20">Tags::tag_setup</a>))
<a name="l00441"></a>00441     <a class="code" href="a00103.html#a16e0939e73cd0dd9fae41145caf70931">setSetup</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>());
<a name="l00442"></a>00442   <span class="keywordflow">else</span>
<a name="l00443"></a>00443     <span class="keywordflow">return</span> -1;
<a name="l00444"></a>00444   <span class="keywordflow">return</span> 0;
<a name="l00445"></a>00445 }
<a name="l00446"></a>00446 
<a name="l00447"></a>00447 <span class="comment"></span>
<a name="l00448"></a>00448 <span class="comment">/** @todo this method implementation is not generic enough and not extendible by subclasses. */</span>
<a name="l00449"></a>00449 PyObject* Load::create(PyTypeObject* pytype, PyObject* args, PyObject* kwds)
<a name="l00450"></a>00450 {
<a name="l00451"></a>00451   <span class="keywordflow">try</span>
<a name="l00452"></a>00452   {
<a name="l00453"></a>00453     <span class="comment">// Pick up the operation</span>
<a name="l00454"></a>00454     PyObject* oper = PyDict_GetItemString(kwds,<span class="stringliteral">&quot;operation&quot;</span>);
<a name="l00455"></a>00455     <span class="keywordflow">if</span> (!PyObject_TypeCheck(oper, <a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>-&gt;pythonClass))
<a name="l00456"></a>00456       <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;load operation must be of type operation&quot;</span>);
<a name="l00457"></a>00457 
<a name="l00458"></a>00458     <span class="comment">// Pick up the resource</span>
<a name="l00459"></a>00459     PyObject* res = PyDict_GetItemString(kwds,<span class="stringliteral">&quot;resource&quot;</span>);
<a name="l00460"></a>00460     <span class="keywordflow">if</span> (!PyObject_TypeCheck(res, <a class="code" href="a00156.html#a1be825fa478f96d8d3a67d18b50eace6">Resource::metadata</a>-&gt;pythonClass))
<a name="l00461"></a>00461       <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;load resource must be of type resource&quot;</span>);
<a name="l00462"></a>00462 
<a name="l00463"></a>00463     <span class="comment">// Pick up the quantity</span>
<a name="l00464"></a>00464     PyObject* q1 = PyDict_GetItemString(kwds,<span class="stringliteral">&quot;quantity&quot;</span>);
<a name="l00465"></a>00465     <span class="keywordtype">double</span> q2 = q1 ? <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(q1).getDouble() : 1.0;
<a name="l00466"></a>00466 
<a name="l00467"></a>00467     <span class="comment">// Create the load</span>
<a name="l00468"></a>00468     <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="a00103.html#a4ce25fb7a9346e3d89aedd249cc6ab07">Load</a>(
<a name="l00469"></a>00469       static_cast&lt;Operation*&gt;(oper),
<a name="l00470"></a>00470       static_cast&lt;Resource*&gt;(res),
<a name="l00471"></a>00471       q2
<a name="l00472"></a>00472       );
<a name="l00473"></a>00473 
<a name="l00474"></a>00474     <span class="comment">// Pick up the effective start date</span>
<a name="l00475"></a>00475     PyObject* eff_start = PyDict_GetItemString(kwds,<span class="stringliteral">&quot;effective_start&quot;</span>);
<a name="l00476"></a>00476     <span class="keywordflow">if</span> (eff_start)
<a name="l00477"></a>00477     {
<a name="l00478"></a>00478       <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="l00479"></a>00479       l-&gt;<a class="code" href="a00118.html#a72f447f9560509a5c9ca04250e6f2981">setEffectiveStart</a>(d.getDate());
<a name="l00480"></a>00480     }
<a name="l00481"></a>00481 
<a name="l00482"></a>00482     <span class="comment">// Pick up the effective end date</span>
<a name="l00483"></a>00483     PyObject* eff_end = PyDict_GetItemString(kwds,<span class="stringliteral">&quot;effective_end&quot;</span>);
<a name="l00484"></a>00484     <span class="keywordflow">if</span> (eff_end)
<a name="l00485"></a>00485     {
<a name="l00486"></a>00486       <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="l00487"></a>00487       l-&gt;<a class="code" href="a00118.html#a71ec773359069c5e359e22aa51feff65">setEffectiveEnd</a>(d.getDate());
<a name="l00488"></a>00488     }
<a name="l00489"></a>00489 
<a name="l00490"></a>00490     <span class="comment">// Return the object</span>
<a name="l00491"></a>00491     Py_INCREF(l);
<a name="l00492"></a>00492     <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span>PyObject*<span class="keyword">&gt;</span>(l);
<a name="l00493"></a>00493   }
<a name="l00494"></a>00494   <span class="keywordflow">catch</span> (...)
<a name="l00495"></a>00495   {
<a name="l00496"></a>00496     PythonType::evalException();
<a name="l00497"></a>00497     <span class="keywordflow">return</span> NULL;
<a name="l00498"></a>00498   }
<a name="l00499"></a>00499 }
<a name="l00500"></a>00500 
<a name="l00501"></a>00501 
<a name="l00502"></a><a class="code" href="a00104.html#a0de90b94b9995e3d90febd7111fc711c">00502</a> <span class="keywordtype">int</span> <a class="code" href="a00104.html#a0de90b94b9995e3d90febd7111fc711c">LoadIterator::initialize</a>()
<a name="l00503"></a>00503 {
<a name="l00504"></a>00504   <span class="comment">// Initialize the type</span>
<a name="l00505"></a>00505   <a class="code" href="a00155.html" title="This class is a thin wrapper around the type information in Python.">PythonType</a>&amp; x = <a class="code" href="a00150.html#aec65c2cd811051918027ae6dc00fcfaf">PythonExtension&lt;LoadIterator&gt;::getType</a>();
<a name="l00506"></a>00506   x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(<span class="stringliteral">&quot;loadIterator&quot;</span>);
<a name="l00507"></a>00507   x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">&quot;frePPLe iterator for loads&quot;</span>);
<a name="l00508"></a>00508   x.<a class="code" href="a00155.html#a5bacf8ad021ab55b1056440880cf8760">supportiter</a>();
<a name="l00509"></a>00509   <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>();
<a name="l00510"></a>00510 }
<a name="l00511"></a>00511 
<a name="l00512"></a>00512 
<a name="l00513"></a>00513 PyObject* LoadIterator::iternext()
<a name="l00514"></a>00514 {
<a name="l00515"></a>00515   PyObject* result;
<a name="l00516"></a>00516   <span class="keywordflow">if</span> (res)
<a name="l00517"></a>00517   {
<a name="l00518"></a>00518     <span class="comment">// Iterate over loads on a resource</span>
<a name="l00519"></a>00519     <span class="keywordflow">if</span> (ir == res-&gt;getLoads().end()) <span class="keywordflow">return</span> NULL;
<a name="l00520"></a>00520     result = <span class="keyword">const_cast&lt;</span><a class="code" href="a00103.html" title="This class links a resource to a certain operation.">Load</a>*<span class="keyword">&gt;</span>(&amp;*ir);
<a name="l00521"></a>00521     ++ir;
<a name="l00522"></a>00522   }
<a name="l00523"></a>00523   <span class="keywordflow">else</span>
<a name="l00524"></a>00524   {
<a name="l00525"></a>00525     <span class="comment">// Iterate over loads on an operation</span>
<a name="l00526"></a>00526     <span class="keywordflow">if</span> (io == oper-&gt;getLoads().end()) <span class="keywordflow">return</span> NULL;
<a name="l00527"></a>00527     result = <span class="keyword">const_cast&lt;</span>Load*<span class="keyword">&gt;</span>(&amp;*io);
<a name="l00528"></a>00528     ++io;
<a name="l00529"></a>00529   }
<a name="l00530"></a>00530   Py_INCREF(result);
<a name="l00531"></a>00531   <span class="keywordflow">return</span> result;
<a name="l00532"></a>00532 }
<a name="l00533"></a>00533 
<a name="l00534"></a>00534 } <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>