Sophie

Sophie

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

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: actions.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>model/actions.cpp</h1><a href="a00192.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/actions.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="a00192.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><a class="code" href="a00256.html">00031</a> <span class="keyword">namespace </span>frepple
<a name="l00032"></a>00032 {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="comment">//</span>
<a name="l00035"></a>00035 <span class="comment">// READ XML INPUT FILE</span>
<a name="l00036"></a>00036 <span class="comment">//</span>
<a name="l00037"></a>00037 
<a name="l00038"></a><a class="code" href="a00034.html#af80b41aa35b39eccfcce566002b0d363">00038</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00034.html#af80b41aa35b39eccfcce566002b0d363">CommandReadXMLFile::execute</a>()
<a name="l00039"></a>00039 {
<a name="l00040"></a>00040   <span class="comment">// Message</span>
<a name="l00041"></a>00041   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00042"></a>00042     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Started reading model from file &apos;&quot;</span> &lt;&lt; filename
<a name="l00043"></a>00043     &lt;&lt; <span class="stringliteral">&quot;&apos; at &quot;</span> &lt;&lt; Date::now() &lt;&lt; endl;
<a name="l00044"></a>00044   <a class="code" href="a00180.html" title="This class is used to measure the processor time used by the program.">Timer</a> t;
<a name="l00045"></a>00045 
<a name="l00046"></a>00046   <span class="comment">// Note: Reading the data files can throw exceptions...</span>
<a name="l00047"></a>00047   <span class="keywordflow">if</span> (filename.empty())
<a name="l00048"></a>00048   {
<a name="l00049"></a>00049     <span class="comment">// Read from standard input</span>
<a name="l00050"></a>00050     xercesc::StdInInputSource in;
<a name="l00051"></a>00051     <span class="keywordflow">if</span> (validate_only)
<a name="l00052"></a>00052       <span class="comment">// When no root object is passed, only the input validation happens</span>
<a name="l00053"></a>00053       <a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>().parse(in, NULL, <span class="keyword">true</span>);
<a name="l00054"></a>00054     <span class="keywordflow">else</span>
<a name="l00055"></a>00055       <a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>().parse(in, &amp;<a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>(), validate);
<a name="l00056"></a>00056   }
<a name="l00057"></a>00057   <span class="keywordflow">else</span> <span class="keywordflow">if</span> (validate_only)
<a name="l00058"></a>00058     <span class="comment">// Read and validate a file</span>
<a name="l00059"></a>00059     <a class="code" href="a00187.html" title="This class reads XML data from a file system.">XMLInputFile</a>(filename).parse(NULL, <span class="keyword">true</span>);
<a name="l00060"></a>00060   <span class="keywordflow">else</span>
<a name="l00061"></a>00061     <span class="comment">// Read, execute and optionally validate a file</span>
<a name="l00062"></a>00062     <a class="code" href="a00187.html" title="This class reads XML data from a file system.">XMLInputFile</a>(filename).parse(&amp;<a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>(),validate);
<a name="l00063"></a>00063 
<a name="l00064"></a>00064   <span class="comment">// Message</span>
<a name="l00065"></a>00065   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00066"></a>00066     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Finished reading model at &quot;</span> &lt;&lt; Date::now()  &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; t &lt;&lt; endl;
<a name="l00067"></a>00067 }
<a name="l00068"></a>00068 
<a name="l00069"></a>00069 
<a name="l00070"></a><a class="code" href="a00034.html#a74255af79a52f7d1e6c033fe49a34f44">00070</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* <a class="code" href="a00034.html#a74255af79a52f7d1e6c033fe49a34f44">CommandReadXMLFile::executePython</a>(PyObject* <span class="keyword">self</span>, PyObject* args)
<a name="l00071"></a>00071 {
<a name="l00072"></a>00072   <span class="comment">// Pick up arguments</span>
<a name="l00073"></a>00073   <span class="keywordtype">char</span> *data;
<a name="l00074"></a>00074   <span class="keywordtype">int</span> i1(1), i2(0);
<a name="l00075"></a>00075   <span class="keywordtype">int</span> ok = PyArg_ParseTuple(args, <span class="stringliteral">&quot;s|ii:readXMLfile&quot;</span>, &amp;data, &amp;i1, &amp;i2);
<a name="l00076"></a>00076   <span class="keywordflow">if</span> (!ok) <span class="keywordflow">return</span> NULL;
<a name="l00077"></a>00077 
<a name="l00078"></a>00078   <span class="comment">// Execute and catch exceptions</span>
<a name="l00079"></a>00079   Py_BEGIN_ALLOW_THREADS   <span class="comment">// Free Python interpreter for other threads</span>
<a name="l00080"></a>00080   <span class="keywordflow">try</span> {
<a name="l00081"></a>00081     <a class="code" href="a00034.html#a5a8e5acdc417f02076e7779c7675592a">CommandReadXMLFile</a>(data, i1!=0, i2!=0).execute();
<a name="l00082"></a>00082   }
<a name="l00083"></a>00083   <span class="keywordflow">catch</span> (...)
<a name="l00084"></a>00084   {
<a name="l00085"></a>00085     Py_BLOCK_THREADS;
<a name="l00086"></a>00086     PythonType::evalException();
<a name="l00087"></a>00087     <span class="keywordflow">return</span> NULL;
<a name="l00088"></a>00088   }
<a name="l00089"></a>00089   Py_END_ALLOW_THREADS   <span class="comment">// Reclaim Python interpreter</span>
<a name="l00090"></a>00090   <span class="keywordflow">return</span> Py_BuildValue(<span class="stringliteral">&quot;&quot;</span>);
<a name="l00091"></a>00091 }
<a name="l00092"></a>00092 
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 <span class="comment">//</span>
<a name="l00095"></a>00095 <span class="comment">// READ XML INPUT STRING</span>
<a name="l00096"></a>00096 <span class="comment">//</span>
<a name="l00097"></a>00097 
<a name="l00098"></a><a class="code" href="a00035.html#ac97dea5e1a77a2bb508c30bd157e02b1">00098</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00035.html#ac97dea5e1a77a2bb508c30bd157e02b1">CommandReadXMLString::execute</a>()
<a name="l00099"></a>00099 {
<a name="l00100"></a>00100   <span class="comment">// Message</span>
<a name="l00101"></a>00101   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00102"></a>00102     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Started reading model from string at &quot;</span> &lt;&lt; Date::now() &lt;&lt; endl;
<a name="l00103"></a>00103   <a class="code" href="a00180.html" title="This class is used to measure the processor time used by the program.">Timer</a> t;
<a name="l00104"></a>00104 
<a name="l00105"></a>00105   <span class="comment">// Note: Reading the data can throw exceptions...</span>
<a name="l00106"></a>00106   <span class="keywordflow">if</span> (validate_only)
<a name="l00107"></a>00107     <a class="code" href="a00188.html" title="This class reads XML data from a string.">XMLInputString</a>(data).parse(NULL, <span class="keyword">true</span>);
<a name="l00108"></a>00108   <span class="keywordflow">else</span>
<a name="l00109"></a>00109     <span class="comment">// Locking the plan assures a single read command is running at any time.</span>
<a name="l00110"></a>00110     <a class="code" href="a00188.html" title="This class reads XML data from a string.">XMLInputString</a>(data).parse(&amp;<a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>(), validate);
<a name="l00111"></a>00111 
<a name="l00112"></a>00112   <span class="comment">// Message</span>
<a name="l00113"></a>00113   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00114"></a>00114     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Finished reading model at &quot;</span> &lt;&lt; Date::now()  &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; t &lt;&lt; endl;
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 
<a name="l00118"></a><a class="code" href="a00035.html#aebc0f6c60c6f91b9a0be05c613b088fc">00118</a> PyObject* <a class="code" href="a00035.html#aebc0f6c60c6f91b9a0be05c613b088fc">CommandReadXMLString::executePython</a>(PyObject *<span class="keyword">self</span>, PyObject *args)
<a name="l00119"></a>00119 {
<a name="l00120"></a>00120   <span class="comment">// Pick up arguments</span>
<a name="l00121"></a>00121   <span class="keywordtype">char</span> *data;
<a name="l00122"></a>00122   <span class="keywordtype">int</span> i1(1), i2(0);
<a name="l00123"></a>00123   <span class="keywordtype">int</span> ok = PyArg_ParseTuple(args, <span class="stringliteral">&quot;s|ii:readXMLdata&quot;</span>, &amp;data, &amp;i1, &amp;i2);
<a name="l00124"></a>00124   <span class="keywordflow">if</span> (!ok) <span class="keywordflow">return</span> NULL;
<a name="l00125"></a>00125 
<a name="l00126"></a>00126   <span class="comment">// Execute and catch exceptions</span>
<a name="l00127"></a>00127   Py_BEGIN_ALLOW_THREADS   <span class="comment">// Free Python interpreter for other threads</span>
<a name="l00128"></a>00128   <span class="keywordflow">try</span> {
<a name="l00129"></a>00129     <span class="keywordflow">if</span> (data) <a class="code" href="a00035.html#aa7f78fa60239ac41bc5496aad76e09a1">CommandReadXMLString</a>(<span class="keywordtype">string</span>(data), i1!=0, i2!=0).execute();
<a name="l00130"></a>00130   }
<a name="l00131"></a>00131   <span class="keywordflow">catch</span> (...)
<a name="l00132"></a>00132   {
<a name="l00133"></a>00133     Py_BLOCK_THREADS;
<a name="l00134"></a>00134     PythonType::evalException();
<a name="l00135"></a>00135     <span class="keywordflow">return</span> NULL;
<a name="l00136"></a>00136   }
<a name="l00137"></a>00137   Py_END_ALLOW_THREADS   <span class="comment">// Reclaim Python interpreter</span>
<a name="l00138"></a>00138   <span class="keywordflow">return</span> Py_BuildValue(<span class="stringliteral">&quot;&quot;</span>);  <span class="comment">// Safer than using Py_None, which is not</span>
<a name="l00139"></a>00139                              <span class="comment">// portable across compilers</span>
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141 
<a name="l00142"></a>00142 
<a name="l00143"></a>00143 <span class="comment">//</span>
<a name="l00144"></a>00144 <span class="comment">// SAVE MODEL TO XML</span>
<a name="l00145"></a>00145 <span class="comment">//</span>
<a name="l00146"></a>00146 
<a name="l00147"></a><a class="code" href="a00036.html#a1fd2e4735da8296f34555e2bb2598a3d">00147</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00036.html#a1fd2e4735da8296f34555e2bb2598a3d">CommandSave::execute</a>()
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149   <span class="comment">// Message</span>
<a name="l00150"></a>00150   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00151"></a>00151     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Start saving model to file &apos;&quot;</span> &lt;&lt; filename
<a name="l00152"></a>00152     &lt;&lt; <span class="stringliteral">&quot;&apos; at &quot;</span> &lt;&lt; Date::now() &lt;&lt; endl;
<a name="l00153"></a>00153   <a class="code" href="a00180.html" title="This class is used to measure the processor time used by the program.">Timer</a> t;
<a name="l00154"></a>00154 
<a name="l00155"></a>00155   <span class="comment">// Save the plan</span>
<a name="l00156"></a>00156   <a class="code" href="a00190.html" title="This class writes XML data to a flat file.">XMLOutputFile</a> o(filename);
<a name="l00157"></a>00157   <span class="keywordflow">if</span> (!headerstart.empty()) o.<a class="code" href="a00189.html#aac2228568fab29bf4f7c05670ef73aa4">setHeaderStart</a>(headerstart);
<a name="l00158"></a>00158   <span class="keywordflow">if</span> (!headeratts.empty()) o.<a class="code" href="a00189.html#a772b7fd20390647570e262bbde210771">setHeaderAtts</a>(headeratts);
<a name="l00159"></a>00159   o.<a class="code" href="a00189.html#a903eeb451e93be054c86fef18ea3e763">setContentType</a>(content);
<a name="l00160"></a>00160   o.<a class="code" href="a00189.html#a07599c1544a419f9eb7a39f1e09b687f">writeElementWithHeader</a>(<a class="code" href="a00177.html#aae03e2bacf4625bfd13e9bd9ef6585fd">Tags::tag_plan</a>, &amp;<a class="code" href="a00132.html#ab297b1f299d472a457784f8022849303">Plan::instance</a>());
<a name="l00161"></a>00161 
<a name="l00162"></a>00162   <span class="comment">// Message</span>
<a name="l00163"></a>00163   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00164"></a>00164     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Finished saving &quot;</span> &lt;&lt; o.<a class="code" href="a00189.html#a604fea0ead9b0c46de97dda3fc7e5fb3">countObjects</a>()
<a name="l00165"></a>00165     &lt;&lt; <span class="stringliteral">&quot; objects at &quot;</span> &lt;&lt; Date::now() &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; t &lt;&lt; endl;
<a name="l00166"></a>00166 }
<a name="l00167"></a>00167 
<a name="l00168"></a>00168 
<a name="l00169"></a><a class="code" href="a00036.html#ab42b5fd2bc7357ec0c1aa9296de19fd5">00169</a> PyObject* <a class="code" href="a00036.html#ab42b5fd2bc7357ec0c1aa9296de19fd5">CommandSave::executePython</a>(PyObject* <span class="keyword">self</span>, PyObject* args)
<a name="l00170"></a>00170 {
<a name="l00171"></a>00171   <span class="comment">// Pick up arguments</span>
<a name="l00172"></a>00172   <span class="keywordtype">char</span> *data;
<a name="l00173"></a>00173   <span class="keywordtype">char</span> *content = NULL;
<a name="l00174"></a>00174   <span class="keywordtype">int</span> ok = PyArg_ParseTuple(args, <span class="stringliteral">&quot;s|s:save&quot;</span>, &amp;data, &amp;content);
<a name="l00175"></a>00175   <span class="keywordflow">if</span> (!ok) <span class="keywordflow">return</span> NULL;
<a name="l00176"></a>00176 
<a name="l00177"></a>00177   <span class="comment">// Execute and catch exceptions</span>
<a name="l00178"></a>00178   Py_BEGIN_ALLOW_THREADS   <span class="comment">// Free Python interpreter for other threads</span>
<a name="l00179"></a>00179   <span class="keywordflow">try</span> {
<a name="l00180"></a>00180     <a class="code" href="a00036.html" title="This command writes the complete model to an XML-file.">CommandSave</a> cmd(data);
<a name="l00181"></a>00181     <span class="keywordflow">if</span> (content)
<a name="l00182"></a>00182     {
<a name="l00183"></a>00183       <span class="keywordflow">if</span> (!strcmp(content,<span class="stringliteral">&quot;STANDARD&quot;</span>))
<a name="l00184"></a>00184         cmd.<a class="code" href="a00036.html#acfe5e4c3e4f11a26155d82865eb0d0bb">setContent</a>(XMLOutput::STANDARD);
<a name="l00185"></a>00185       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(content,<span class="stringliteral">&quot;PLAN&quot;</span>))
<a name="l00186"></a>00186         cmd.<a class="code" href="a00036.html#acfe5e4c3e4f11a26155d82865eb0d0bb">setContent</a>(XMLOutput::PLAN);
<a name="l00187"></a>00187       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!strcmp(content,<span class="stringliteral">&quot;PLANDETAIL&quot;</span>))
<a name="l00188"></a>00188         cmd.<a class="code" href="a00036.html#acfe5e4c3e4f11a26155d82865eb0d0bb">setContent</a>(XMLOutput::PLANDETAIL);
<a name="l00189"></a>00189       <span class="keywordflow">else</span>
<a name="l00190"></a>00190         <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 content type &apos;&quot;</span> + <span class="keywordtype">string</span>(content) + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l00191"></a>00191     }
<a name="l00192"></a>00192     cmd.<a class="code" href="a00036.html#a1fd2e4735da8296f34555e2bb2598a3d">execute</a>();
<a name="l00193"></a>00193   }
<a name="l00194"></a>00194   <span class="keywordflow">catch</span> (...)
<a name="l00195"></a>00195   {
<a name="l00196"></a>00196     Py_BLOCK_THREADS;
<a name="l00197"></a>00197     PythonType::evalException();
<a name="l00198"></a>00198     <span class="keywordflow">return</span> NULL;
<a name="l00199"></a>00199   }
<a name="l00200"></a>00200   Py_END_ALLOW_THREADS   <span class="comment">// Reclaim Python interpreter</span>
<a name="l00201"></a>00201   <span class="keywordflow">return</span> Py_BuildValue(<span class="stringliteral">&quot;&quot;</span>);
<a name="l00202"></a>00202 }
<a name="l00203"></a>00203 
<a name="l00204"></a>00204 
<a name="l00205"></a>00205 <span class="comment">//</span>
<a name="l00206"></a>00206 <span class="comment">// SAVE PLAN SUMMARY TO TEXT FILE</span>
<a name="l00207"></a>00207 <span class="comment">//</span>
<a name="l00208"></a>00208 
<a name="l00209"></a><a class="code" href="a00037.html#a022fdd40b637558fcbb7ce89781a7dfe">00209</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00037.html#a022fdd40b637558fcbb7ce89781a7dfe">CommandSavePlan::execute</a>()
<a name="l00210"></a>00210 {
<a name="l00211"></a>00211   <span class="comment">// Message</span>
<a name="l00212"></a>00212   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00213"></a>00213     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Start saving plan to file &apos;&quot;</span> &lt;&lt; <a class="code" href="a00037.html#a62e986b830c994c651ede1570ea589ed">getFileName</a>()
<a name="l00214"></a>00214     &lt;&lt; <span class="stringliteral">&quot;&apos; at &quot;</span> &lt;&lt; Date::now() &lt;&lt; endl;
<a name="l00215"></a>00215   <a class="code" href="a00180.html" title="This class is used to measure the processor time used by the program.">Timer</a> t;
<a name="l00216"></a>00216 
<a name="l00217"></a>00217   <span class="comment">// Output steam</span>
<a name="l00218"></a>00218   <span class="keywordflow">if</span> (<a class="code" href="a00037.html#a62e986b830c994c651ede1570ea589ed">getFileName</a>().empty())
<a name="l00219"></a>00219     <span class="keywordflow">throw</span> <a class="code" href="a00162.html" title="An exception of this type is thrown when the library runs into problems that are...">RuntimeException</a>(<span class="stringliteral">&quot;No file specified for export&quot;</span>);
<a name="l00220"></a>00220   ofstream textoutput;
<a name="l00221"></a>00221 
<a name="l00222"></a>00222   <span class="comment">// Open the file, write to it and close it. Catch exceptions all along...</span>
<a name="l00223"></a>00223   <span class="keywordflow">try</span>
<a name="l00224"></a>00224   {
<a name="l00225"></a>00225     <span class="comment">// Open the output file</span>
<a name="l00226"></a>00226     textoutput.open(<a class="code" href="a00037.html#a62e986b830c994c651ede1570ea589ed">getFileName</a>().c_str(), ios::out);
<a name="l00227"></a>00227 
<a name="l00228"></a>00228     <span class="comment">// Write the buffer summary</span>
<a name="l00229"></a>00229     <span class="keywordflow">for</span> (Buffer::iterator gbuf = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Buffer::begin</a>();
<a name="l00230"></a>00230         gbuf != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Buffer::end</a>(); ++gbuf)
<a name="l00231"></a>00231     {
<a name="l00232"></a>00232       <span class="keywordflow">if</span> (!gbuf-&gt;getHidden())
<a name="l00233"></a>00233         <span class="keywordflow">for</span> (Buffer::flowplanlist::const_iterator
<a name="l00234"></a>00234             oo=gbuf-&gt;getFlowPlans().begin();
<a name="l00235"></a>00235             oo!=gbuf-&gt;getFlowPlans().end();
<a name="l00236"></a>00236             ++oo)
<a name="l00237"></a>00237           <span class="keywordflow">if</span> (oo-&gt;getType() == 1 &amp;&amp; oo-&gt;getQuantity() != 0.0)
<a name="l00238"></a>00238           {
<a name="l00239"></a>00239             textoutput &lt;&lt; <span class="stringliteral">&quot;BUFFER\t&quot;</span> &lt;&lt; *gbuf &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00240"></a>00240             &lt;&lt; oo-&gt;getDate() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00241"></a>00241             &lt;&lt; oo-&gt;getQuantity() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00242"></a>00242             &lt;&lt; oo-&gt;getOnhand() &lt;&lt; endl;
<a name="l00243"></a>00243           }
<a name="l00244"></a>00244     }
<a name="l00245"></a>00245 
<a name="l00246"></a>00246     <span class="comment">// Write the demand summary</span>
<a name="l00247"></a>00247     <span class="keywordflow">for</span> (Demand::iterator gdem = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Demand::begin</a>();
<a name="l00248"></a>00248         gdem != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Demand::end</a>(); ++gdem)
<a name="l00249"></a>00249     {
<a name="l00250"></a>00250       <span class="keywordflow">if</span> (!gdem-&gt;getHidden())
<a name="l00251"></a>00251       {
<a name="l00252"></a>00252         <span class="keywordflow">for</span> (Demand::OperationPlan_list::const_iterator
<a name="l00253"></a>00253             pp = gdem-&gt;getDelivery().begin();
<a name="l00254"></a>00254             pp != gdem-&gt;getDelivery().end();
<a name="l00255"></a>00255             ++pp)
<a name="l00256"></a>00256           textoutput &lt;&lt; <span class="stringliteral">&quot;DEMAND\t&quot;</span> &lt;&lt; (*gdem) &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00257"></a>00257             &lt;&lt; (*pp)-&gt;getDates().getEnd() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00258"></a>00258             &lt;&lt; (*pp)-&gt;getQuantity() &lt;&lt; endl;
<a name="l00259"></a>00259       }
<a name="l00260"></a>00260     }
<a name="l00261"></a>00261 
<a name="l00262"></a>00262     <span class="comment">// Write the resource summary</span>
<a name="l00263"></a>00263     <span class="keywordflow">for</span> (Resource::iterator gres = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Resource::begin</a>();
<a name="l00264"></a>00264         gres != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Resource::end</a>(); ++gres)
<a name="l00265"></a>00265     {
<a name="l00266"></a>00266       <span class="keywordflow">if</span> (!gres-&gt;getHidden())
<a name="l00267"></a>00267         <span class="keywordflow">for</span> (Resource::loadplanlist::const_iterator
<a name="l00268"></a>00268             qq=gres-&gt;getLoadPlans().begin();
<a name="l00269"></a>00269             qq!=gres-&gt;getLoadPlans().end();
<a name="l00270"></a>00270             ++qq)
<a name="l00271"></a>00271           <span class="keywordflow">if</span> (qq-&gt;getType() == 1 &amp;&amp; qq-&gt;getQuantity() != 0.0)
<a name="l00272"></a>00272           {
<a name="l00273"></a>00273             textoutput &lt;&lt; <span class="stringliteral">&quot;RESOURCE\t&quot;</span> &lt;&lt; *gres &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00274"></a>00274             &lt;&lt; qq-&gt;getDate() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00275"></a>00275             &lt;&lt; qq-&gt;getQuantity() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00276"></a>00276             &lt;&lt; qq-&gt;getOnhand() &lt;&lt; endl;
<a name="l00277"></a>00277           }
<a name="l00278"></a>00278     }
<a name="l00279"></a>00279 
<a name="l00280"></a>00280     <span class="comment">// Write the operationplan summary.</span>
<a name="l00281"></a>00281     <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> rr = <a class="code" href="a00125.html#a8bd5449992e056b2d637cfe65ac7da1f">OperationPlan::begin</a>();
<a name="l00282"></a>00282         rr != <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>(); ++rr)
<a name="l00283"></a>00283     {
<a name="l00284"></a>00284       <span class="keywordflow">if</span> (rr-&gt;getOperation()-&gt;getHidden()) <span class="keywordflow">continue</span>;
<a name="l00285"></a>00285       textoutput &lt;&lt; <span class="stringliteral">&quot;OPERATION\t&quot;</span> &lt;&lt; rr-&gt;getOperation() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00286"></a>00286       &lt;&lt; rr-&gt;getDates().getStart() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00287"></a>00287       &lt;&lt; rr-&gt;getDates().getEnd() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00288"></a>00288       &lt;&lt; rr-&gt;getQuantity() &lt;&lt; endl;
<a name="l00289"></a>00289     }
<a name="l00290"></a>00290 
<a name="l00291"></a>00291     <span class="comment">// Write the problem summary.</span>
<a name="l00292"></a>00292     <span class="keywordflow">for</span> (<a class="code" href="a00039.html" title="This class models an STL-like iterator that allows us to iterate over the named entities...">Problem::const_iterator</a> gprob = <a class="code" href="a00134.html#a1532b2bb7078ebcd527a8bf332ffb861">Problem::begin</a>();
<a name="l00293"></a>00293         gprob != <a class="code" href="a00134.html#ae3fc9d1129b3e956ac2c9ec6c54035d8">Problem::end</a>(); ++gprob)
<a name="l00294"></a>00294     {
<a name="l00295"></a>00295       textoutput &lt;&lt; <span class="stringliteral">&quot;PROBLEM\t&quot;</span> &lt;&lt; gprob-&gt;getType().type &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00296"></a>00296       &lt;&lt; gprob-&gt;getDescription() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00297"></a>00297       &lt;&lt; gprob-&gt;getDates() &lt;&lt; endl;
<a name="l00298"></a>00298     }
<a name="l00299"></a>00299 
<a name="l00300"></a>00300     <span class="comment">// Write the constraint summary</span>
<a name="l00301"></a>00301     <span class="keywordflow">for</span> (Demand::iterator gdem = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Demand::begin</a>();
<a name="l00302"></a>00302         gdem != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Demand::end</a>(); ++gdem)
<a name="l00303"></a>00303     {
<a name="l00304"></a>00304       <span class="keywordflow">if</span> (!gdem-&gt;getHidden())
<a name="l00305"></a>00305       {
<a name="l00306"></a>00306         <span class="keywordflow">for</span> (<a class="code" href="a00039.html" title="This class models an STL-like iterator that allows us to iterate over the named entities...">Problem::const_iterator</a> i = gdem-&gt;getConstraints().begin();
<a name="l00307"></a>00307             i != gdem-&gt;getConstraints().end();
<a name="l00308"></a>00308             ++i)
<a name="l00309"></a>00309           textoutput &lt;&lt; <span class="stringliteral">&quot;DEMAND CONSTRAINT\t&quot;</span> &lt;&lt; (*gdem) &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00310"></a>00310             &lt;&lt; i-&gt;getDescription() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span>
<a name="l00311"></a>00311             &lt;&lt; i-&gt;getDates() &lt;&lt; <span class="charliteral">&apos;\t&apos;</span> &lt;&lt; endl;
<a name="l00312"></a>00312       }
<a name="l00313"></a>00313     }
<a name="l00314"></a>00314 
<a name="l00315"></a>00315     <span class="comment">// Close the output file</span>
<a name="l00316"></a>00316     textoutput.close();
<a name="l00317"></a>00317   }
<a name="l00318"></a>00318   <span class="keywordflow">catch</span> (exception&amp; e)
<a name="l00319"></a>00319   {
<a name="l00320"></a>00320     textoutput.close();
<a name="l00321"></a>00321     <span class="keywordflow">throw</span> <a class="code" href="a00162.html" title="An exception of this type is thrown when the library runs into problems that are...">RuntimeException</a>(<span class="stringliteral">&quot;Error writing to file &apos;&quot;</span>
<a name="l00322"></a>00322         + <a class="code" href="a00037.html#a62e986b830c994c651ede1570ea589ed">getFileName</a>() + <span class="stringliteral">&quot;&apos;:\n&quot;</span> + e.what());
<a name="l00323"></a>00323   }
<a name="l00324"></a>00324   <span class="keywordflow">catch</span> (...)
<a name="l00325"></a>00325   {
<a name="l00326"></a>00326     textoutput.close();
<a name="l00327"></a>00327     <span class="keywordflow">throw</span> <a class="code" href="a00162.html" title="An exception of this type is thrown when the library runs into problems that are...">RuntimeException</a>(<span class="stringliteral">&quot;Error writing to file &apos;&quot;</span>
<a name="l00328"></a>00328         + <a class="code" href="a00037.html#a62e986b830c994c651ede1570ea589ed">getFileName</a>() + <span class="stringliteral">&quot;&apos;&quot;</span>);
<a name="l00329"></a>00329   }
<a name="l00330"></a>00330 
<a name="l00331"></a>00331   <span class="comment">// Message</span>
<a name="l00332"></a>00332   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00333"></a>00333     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Finished saving plan at &quot;</span> &lt;&lt; Date::now() &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; t &lt;&lt; endl;
<a name="l00334"></a>00334 }
<a name="l00335"></a>00335 
<a name="l00336"></a>00336 
<a name="l00337"></a><a class="code" href="a00037.html#ae94f793824fcdfd970965e19b89af69c">00337</a> PyObject* <a class="code" href="a00037.html#ae94f793824fcdfd970965e19b89af69c">CommandSavePlan::executePython</a>(PyObject* <span class="keyword">self</span>, PyObject* args)
<a name="l00338"></a>00338 {
<a name="l00339"></a>00339   <span class="comment">// Pick up arguments</span>
<a name="l00340"></a>00340   <span class="keywordtype">char</span> *data;
<a name="l00341"></a>00341   <span class="keywordtype">int</span> ok = PyArg_ParseTuple(args, <span class="stringliteral">&quot;s:saveplan&quot;</span>, &amp;data);
<a name="l00342"></a>00342   <span class="keywordflow">if</span> (!ok) <span class="keywordflow">return</span> NULL;
<a name="l00343"></a>00343 
<a name="l00344"></a>00344   <span class="comment">// Execute and catch exceptions</span>
<a name="l00345"></a>00345   Py_BEGIN_ALLOW_THREADS   <span class="comment">// Free Python interpreter for other threads</span>
<a name="l00346"></a>00346   <span class="keywordflow">try</span> {
<a name="l00347"></a>00347     <a class="code" href="a00037.html#a6789702f043c0defe3bcbdbca9847609">CommandSavePlan</a>(data).execute();
<a name="l00348"></a>00348   }
<a name="l00349"></a>00349   <span class="keywordflow">catch</span> (...)
<a name="l00350"></a>00350   {
<a name="l00351"></a>00351     Py_BLOCK_THREADS;
<a name="l00352"></a>00352     PythonType::evalException();
<a name="l00353"></a>00353     <span class="keywordflow">return</span> NULL;
<a name="l00354"></a>00354   }
<a name="l00355"></a>00355   Py_END_ALLOW_THREADS   <span class="comment">// Reclaim Python interpreter</span>
<a name="l00356"></a>00356   <span class="keywordflow">return</span> Py_BuildValue(<span class="stringliteral">&quot;&quot;</span>);
<a name="l00357"></a>00357 }
<a name="l00358"></a>00358 
<a name="l00359"></a>00359 
<a name="l00360"></a>00360 <span class="comment">//</span>
<a name="l00361"></a>00361 <span class="comment">// MOVE OPERATIONPLAN</span>
<a name="l00362"></a>00362 <span class="comment">//</span>
<a name="l00363"></a>00363                
<a name="l00364"></a>00364 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00031.html#ae3154a29d69516b1c08f27e637b64c21">CommandMoveOperationPlan::CommandMoveOperationPlan</a>
<a name="l00365"></a><a class="code" href="a00031.html#a0c856e35f463c32d26bd26327885aa40">00365</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) : opplan(o), firstCommand(NULL)
<a name="l00366"></a>00366 {
<a name="l00367"></a>00367   <span class="keywordflow">if</span> (!o) 
<a name="l00368"></a>00368   {
<a name="l00369"></a>00369     originalqty = 0;
<a name="l00370"></a>00370     <span class="keywordflow">return</span>;
<a name="l00371"></a>00371   }
<a name="l00372"></a>00372   originalqty = opplan-&gt;getQuantity();
<a name="l00373"></a>00373   originaldates = opplan-&gt;getDates();
<a name="l00374"></a>00374 
<a name="l00375"></a>00375   <span class="comment">// Construct a subcommand for all suboperationplans</span>
<a name="l00376"></a>00376   <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> x(o); x != o-&gt;<a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">end</a>(); ++x)
<a name="l00377"></a>00377     <span class="keywordflow">if</span> (x-&gt;getOperation() != <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>)
<a name="l00378"></a>00378     {
<a name="l00379"></a>00379       <a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a> *n = <span class="keyword">new</span> <a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a>(o);
<a name="l00380"></a>00380       n-&gt;owner = <span class="keyword">this</span>;
<a name="l00381"></a>00381       <span class="keywordflow">if</span> (firstCommand)
<a name="l00382"></a>00382       {
<a name="l00383"></a>00383         n-&gt;next = firstCommand;
<a name="l00384"></a>00384         firstCommand-&gt;prev = n;
<a name="l00385"></a>00385       }
<a name="l00386"></a>00386       firstCommand = n;
<a name="l00387"></a>00387     }
<a name="l00388"></a>00388 }
<a name="l00389"></a>00389 
<a name="l00390"></a>00390 
<a name="l00391"></a>00391 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00031.html#ae3154a29d69516b1c08f27e637b64c21">CommandMoveOperationPlan::CommandMoveOperationPlan</a>
<a name="l00392"></a><a class="code" href="a00031.html#ae3154a29d69516b1c08f27e637b64c21">00392</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 class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> newstart, <a class="code" href="a00049.html" title="This class represents a date and time with an accuracy of one second.">Date</a> newend, <span class="keywordtype">double</span> newQty) 
<a name="l00393"></a>00393   : opplan(o), firstCommand(NULL)
<a name="l00394"></a>00394 {
<a name="l00395"></a>00395   <span class="keywordflow">if</span> (!opplan) <span class="keywordflow">return</span>;
<a name="l00396"></a>00396 
<a name="l00397"></a>00397   <span class="comment">// Store current settings</span>
<a name="l00398"></a>00398   originalqty = opplan-&gt;getQuantity();
<a name="l00399"></a>00399   <span class="keywordflow">if</span> (newQty == -1.0) newQty = originalqty;
<a name="l00400"></a>00400   originaldates = opplan-&gt;getDates();
<a name="l00401"></a>00401 
<a name="l00402"></a>00402   <span class="comment">// Update the settings</span>
<a name="l00403"></a>00403   assert(opplan-&gt;getOperation());
<a name="l00404"></a>00404   opplan-&gt;getOperation()-&gt;setOperationPlanParameters(
<a name="l00405"></a>00405     opplan, newQty, newstart, newend
<a name="l00406"></a>00406   );
<a name="l00407"></a>00407 
<a name="l00408"></a>00408   <span class="comment">// Construct a subcommand for all suboperationplans</span>
<a name="l00409"></a>00409   <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> x(o); x != o-&gt;<a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">end</a>(); ++x)
<a name="l00410"></a>00410     <span class="keywordflow">if</span> (x-&gt;getOperation() != <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a>)
<a name="l00411"></a>00411     {
<a name="l00412"></a>00412       <a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a> *n = <span class="keyword">new</span> <a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a>(o);
<a name="l00413"></a>00413       n-&gt;owner = <span class="keyword">this</span>;
<a name="l00414"></a>00414       <span class="keywordflow">if</span> (firstCommand)
<a name="l00415"></a>00415       {
<a name="l00416"></a>00416         n-&gt;next = firstCommand;
<a name="l00417"></a>00417         firstCommand-&gt;prev = n;
<a name="l00418"></a>00418       }
<a name="l00419"></a>00419       firstCommand = n;
<a name="l00420"></a>00420     }
<a name="l00421"></a>00421 }
<a name="l00422"></a>00422 
<a name="l00423"></a>00423 
<a name="l00424"></a><a class="code" href="a00031.html#aa3f261e74bc7774cb5a8cc1348ec519e">00424</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00031.html#aa3f261e74bc7774cb5a8cc1348ec519e">CommandMoveOperationPlan::restore</a>(<span class="keywordtype">bool</span> del)
<a name="l00425"></a>00425 {
<a name="l00426"></a>00426   <span class="comment">// Restore all suboperationplans and (optionally) delete the subcommands</span>
<a name="l00427"></a>00427   <span class="keywordflow">for</span> (<a class="code" href="a00025.html" title="Abstract base class for all commands.">Command</a> *c = firstCommand; c; )
<a name="l00428"></a>00428   {
<a name="l00429"></a>00429     <a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a> *tmp = <span class="keyword">static_cast&lt;</span><a class="code" href="a00031.html" title="This class represents the command of moving an operationplan to a new date and/or...">CommandMoveOperationPlan</a>*<span class="keyword">&gt;</span>(c);
<a name="l00430"></a>00430     tmp-&gt;<a class="code" href="a00031.html#aa3f261e74bc7774cb5a8cc1348ec519e">restore</a>(del);
<a name="l00431"></a>00431     c = c-&gt;next;
<a name="l00432"></a>00432     <span class="keywordflow">if</span> (del) <span class="keyword">delete</span> tmp;
<a name="l00433"></a>00433   }
<a name="l00434"></a>00434 
<a name="l00435"></a>00435   <span class="comment">// Restore the original dates</span>
<a name="l00436"></a>00436   <span class="keywordflow">if</span> (!opplan) <span class="keywordflow">return</span>;
<a name="l00437"></a>00437   opplan-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>()-&gt;<a class="code" href="a00121.html#a744480cdd80e70a2b0a7606114e1ab73">setOperationPlanParameters</a>(
<a name="l00438"></a>00438     opplan, originalqty, originaldates.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(), originaldates.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>()
<a name="l00439"></a>00439   );
<a name="l00440"></a>00440 }
<a name="l00441"></a>00441 
<a name="l00442"></a>00442 
<a name="l00443"></a>00443 <span class="comment">//</span>
<a name="l00444"></a>00444 <span class="comment">// DELETE OPERATIONPLAN</span>
<a name="l00445"></a>00445 <span class="comment">//</span>
<a name="l00446"></a>00446 
<a name="l00447"></a>00447 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00027.html#aaf75c77ef78b3734679cbd955bdff40e">CommandDeleteOperationPlan::CommandDeleteOperationPlan</a>
<a name="l00448"></a><a class="code" href="a00027.html#aaf75c77ef78b3734679cbd955bdff40e">00448</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="l00449"></a>00449 {
<a name="l00450"></a>00450   <span class="comment">// Validate input</span>
<a name="l00451"></a>00451   <span class="keywordflow">if</span> (!o)
<a name="l00452"></a>00452   {
<a name="l00453"></a>00453     oper = NULL;
<a name="l00454"></a>00454     <span class="keywordflow">return</span>;
<a name="l00455"></a>00455   }
<a name="l00456"></a>00456 
<a name="l00457"></a>00457   <span class="comment">// Avoid deleting locked operationplans</span>
<a name="l00458"></a>00458   <span class="keywordflow">if</span> (o-&gt;<a class="code" href="a00125.html#ad76b43eab48c2587255ec1b460f91093">getLocked</a>())
<a name="l00459"></a>00459     <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 delete a locked operationplan&quot;</span>);
<a name="l00460"></a>00460 
<a name="l00461"></a>00461   <span class="comment">// Register the fields of the operationplan before deletion</span>
<a name="l00462"></a>00462   oper = o-&gt;<a class="code" href="a00125.html#a2f5ae1046cd50f98e59520ed8910c458">getOperation</a>();
<a name="l00463"></a>00463   qty = o-&gt;<a class="code" href="a00125.html#aa32661a65b2309ba7c35576940274687">getQuantity</a>();
<a name="l00464"></a>00464   dates = o-&gt;<a class="code" href="a00125.html#a9f19aec0a96f30616f2ee06e3c8f371a">getDates</a>();
<a name="l00465"></a>00465   <span class="keywordtype">id</span> = o-&gt;<a class="code" href="a00125.html#a2fc22f86c78b34f91bf535c742e2e740">getIdentifier</a>();
<a name="l00466"></a>00466   dmd = o-&gt;<a class="code" href="a00125.html#a4cd571d01df7194dd232d07f7cbba03f">getDemand</a>();
<a name="l00467"></a>00467   ow = &amp;*(o-&gt;<a class="code" href="a00125.html#a5d8b863740c3c1a948442c470e603393">getOwner</a>());
<a name="l00468"></a>00468 
<a name="l00469"></a>00469   <span class="comment">// Delete the operationplan</span>
<a name="l00470"></a>00470   <span class="keyword">delete</span> o;
<a name="l00471"></a>00471 }
<a name="l00472"></a>00472 
<a name="l00473"></a>00473 
<a name="l00474"></a><a class="code" href="a00027.html#acc2a278edbc705ac767a3d8a72681fe4">00474</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00027.html#acc2a278edbc705ac767a3d8a72681fe4">CommandDeleteOperationPlan::undo</a>()
<a name="l00475"></a>00475 {
<a name="l00476"></a>00476   <span class="comment">// Already executed, or never initialized completely</span>
<a name="l00477"></a>00477   <span class="keywordflow">if</span> (!oper) <span class="keywordflow">return</span>;
<a name="l00478"></a>00478 
<a name="l00479"></a>00479   <span class="comment">// Recreate and register the operationplan.</span>
<a name="l00480"></a>00480   <span class="comment">// Note that the recreated operationplan has the same field values as the</span>
<a name="l00481"></a>00481   <span class="comment">// original one, but has a different memory address. Any pointers to the</span>
<a name="l00482"></a>00482   <span class="comment">// original operationplan are now dangling.</span>
<a name="l00483"></a>00483   <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 = oper-&gt;<a class="code" href="a00121.html#ad183a2e72b75cdd83f9e71f6bc235424">createOperationPlan</a>(qty, dates.<a class="code" href="a00050.html#a73e574de7fbf5df8ebc4c5190e7d49c3">getStart</a>(),
<a name="l00484"></a>00484     dates.<a class="code" href="a00050.html#a165a8f748d8468e5ba8331c0e06bd3a2">getEnd</a>(), dmd, <span class="keyword">const_cast&lt;</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>*<span class="keyword">&gt;</span>(ow), <span class="keywordtype">id</span>);
<a name="l00485"></a>00485   <span class="keywordflow">if</span> (opplan) opplan-&gt;<a class="code" href="a00125.html#a13fe13cfa3f0b8dc229b9f115172c9c5">instantiate</a>();
<a name="l00486"></a>00486 
<a name="l00487"></a>00487   <span class="comment">// Avoid undoing multiple times!</span>
<a name="l00488"></a>00488   oper = NULL;
<a name="l00489"></a>00489 }
<a name="l00490"></a>00490 
<a name="l00491"></a>00491 
<a name="l00492"></a>00492 <span class="comment">//</span>
<a name="l00493"></a>00493 <span class="comment">// DELETE MODEL</span>
<a name="l00494"></a>00494 <span class="comment">//</span>
<a name="l00495"></a>00495 
<a name="l00496"></a>00496 
<a name="l00497"></a><a class="code" href="a00028.html#a9e23b520cc21ec96c78a801a14986f11">00497</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00028.html#a9e23b520cc21ec96c78a801a14986f11">CommandErase::execute</a>()
<a name="l00498"></a>00498 {
<a name="l00499"></a>00499   <span class="comment">// Starting message</span>
<a name="l00500"></a>00500   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00501"></a>00501   {
<a name="l00502"></a>00502     <span class="keywordflow">if</span> (deleteStaticModel)
<a name="l00503"></a>00503       <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Start model erase command at &quot;</span> &lt;&lt; Date::now() &lt;&lt; endl;
<a name="l00504"></a>00504     <span class="keywordflow">else</span>
<a name="l00505"></a>00505       <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Start plan erase command at &quot;</span> &lt;&lt; Date::now() &lt;&lt; endl;
<a name="l00506"></a>00506   }
<a name="l00507"></a>00507   <a class="code" href="a00180.html" title="This class is used to measure the processor time used by the program.">Timer</a> t;
<a name="l00508"></a>00508 
<a name="l00509"></a>00509   <span class="keywordflow">if</span> (deleteStaticModel)
<a name="l00510"></a>00510   {
<a name="l00511"></a>00511     <span class="comment">// Delete all entities.</span>
<a name="l00512"></a>00512     <span class="comment">// The order is chosen to minimize the work of the individual destructors.</span>
<a name="l00513"></a>00513     <span class="comment">// E.g. the destructor of the item class recurses over all demands and</span>
<a name="l00514"></a>00514     <span class="comment">// all buffers. It is much faster if there are none already.</span>
<a name="l00515"></a>00515     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Demand::clear</a>();
<a name="l00516"></a>00516     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Operation::clear</a>();  
<a name="l00517"></a>00517     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Buffer::clear</a>();     
<a name="l00518"></a>00518     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Resource::clear</a>();
<a name="l00519"></a>00519     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">SetupMatrix::clear</a>();
<a name="l00520"></a>00520     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Location::clear</a>();
<a name="l00521"></a>00521     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Customer::clear</a>();
<a name="l00522"></a>00522     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Calendar::clear</a>();
<a name="l00523"></a>00523     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Solver::clear</a>();
<a name="l00524"></a>00524     <a class="code" href="a00085.html#a73371df3a83f5d8dcec7392f5e1aa83b">Item::clear</a>();
<a name="l00525"></a>00525     <span class="comment">// The setup operation is a static singleton and should always be around</span>
<a name="l00526"></a>00526     <a class="code" href="a00129.html#add35ebccc253401c86cc40dc2fed3f04">OperationSetup::setupoperation</a> = <a class="code" href="a00085.html#a63b0e8c75aecc6fde9f4053ece52fde0">Operation::add</a>(<span class="keyword">new</span> <a class="code" href="a00129.html" title="Models an operation to convert a setup on a resource.">OperationSetup</a>(<span class="stringliteral">&quot;setup operation&quot;</span>));
<a name="l00527"></a>00527   }
<a name="l00528"></a>00528   <span class="keywordflow">else</span>
<a name="l00529"></a>00529     <span class="comment">// Delete the operationplans only</span>
<a name="l00530"></a>00530     <span class="keywordflow">for</span> (Operation::iterator gop = <a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">Operation::begin</a>();
<a name="l00531"></a>00531         gop != <a class="code" href="a00085.html#abb9d04973550ac71037718511358f2ff">Operation::end</a>(); ++gop)
<a name="l00532"></a>00532       gop-&gt;deleteOperationPlans();
<a name="l00533"></a>00533 
<a name="l00534"></a>00534   <span class="comment">// Ending message</span>
<a name="l00535"></a>00535   <span class="keywordflow">if</span> (<a class="code" href="a00025.html#a78c1d8e342cd245457d2cdde4e471f42">getVerbose</a>())
<a name="l00536"></a>00536     <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> &lt;&lt; <span class="stringliteral">&quot;Finished erase command at &quot;</span> &lt;&lt; Date::now()
<a name="l00537"></a>00537     &lt;&lt; <span class="stringliteral">&quot; : &quot;</span> &lt;&lt; t &lt;&lt; endl;
<a name="l00538"></a>00538 }
<a name="l00539"></a>00539 
<a name="l00540"></a>00540 
<a name="l00541"></a><a class="code" href="a00028.html#ab28c6d6f3d9731c878e25069069f7b36">00541</a> PyObject* <a class="code" href="a00028.html#ab28c6d6f3d9731c878e25069069f7b36">CommandErase::executePython</a>(PyObject* <span class="keyword">self</span>, PyObject* args)
<a name="l00542"></a>00542 {
<a name="l00543"></a>00543   <span class="comment">// Pick up arguments</span>
<a name="l00544"></a>00544   PyObject *obj = NULL;
<a name="l00545"></a>00545   <span class="keywordtype">int</span> ok = PyArg_ParseTuple(args, <span class="stringliteral">&quot;|O:erase&quot;</span>, &amp;obj);
<a name="l00546"></a>00546   <span class="keywordflow">if</span> (!ok) <span class="keywordflow">return</span> NULL;
<a name="l00547"></a>00547 
<a name="l00548"></a>00548   <span class="comment">// Validate the argument</span>
<a name="l00549"></a>00549   <span class="keywordtype">bool</span> staticalso = <span class="keyword">false</span>;
<a name="l00550"></a>00550   <span class="keywordflow">if</span> (obj) staticalso = <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>(obj).getBool();
<a name="l00551"></a>00551 
<a name="l00552"></a>00552   <span class="comment">// Execute and catch exceptions</span>
<a name="l00553"></a>00553   Py_BEGIN_ALLOW_THREADS   <span class="comment">// Free Python interpreter for other threads</span>
<a name="l00554"></a>00554   <span class="keywordflow">try</span> {
<a name="l00555"></a>00555     <a class="code" href="a00028.html#a54ecb1e1e40986dd30d9936fb791b570">CommandErase</a>(staticalso).execute();
<a name="l00556"></a>00556   }
<a name="l00557"></a>00557   <span class="keywordflow">catch</span> (...)
<a name="l00558"></a>00558   {
<a name="l00559"></a>00559     Py_BLOCK_THREADS;
<a name="l00560"></a>00560     PythonType::evalException();
<a name="l00561"></a>00561     <span class="keywordflow">return</span> NULL;
<a name="l00562"></a>00562   }
<a name="l00563"></a>00563   Py_END_ALLOW_THREADS   <span class="comment">// Reclaim Python interpreter</span>
<a name="l00564"></a>00564   <span class="keywordflow">return</span> Py_BuildValue(<span class="stringliteral">&quot;&quot;</span>);
<a name="l00565"></a>00565 }
<a name="l00566"></a>00566 
<a name="l00567"></a>00567 } <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>