<!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: flow.cpp Source File</title> <link href="doxygen.css" rel="stylesheet" type="text/css"> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="../styles.css" rel="stylesheet" type="text/css"> </head> <body> <div id="container"> <div id="menubar"> <div id="logo" align="center"> <br/><img src='../frepple.bmp' alt="frepple" /><br/> <a href='http://www.frepple.com/'> <strong>a Free<br/>Production Planning<br/>Library</strong> </a> </div> <div id="menu"> <br/> <h3><a href='../Main/HomePage.html'>Main</a></h3> <h3><a href='../UI/Main.html'>User Manual</a></h3> <h3><a href='../Tutorial/Main.html'>Tutorial</a></h3> <h3><a href='../Frepple/Main.html'>Reference Manual</a></h3> <h3><a href='../Main/FAQ.html'>FAQ</a></h3> <h3><a href='index.html'>C++ API</a></h3> <br/> </div> </div> <div id="content"> <br/> <!-- Generated by Doxygen 1.6.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li><a href="dirs.html"><span>Directories</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="navpath"><a class="el" href="dir_88117dff2735251a69c8eb9084477714.html">src</a> » <a class="el" href="dir_25032d30b6d615a661c02e2ac1394b01.html">model</a> </div> </div> <div class="contents"> <h1>flow.cpp</h1><a href="a00201.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/flow.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="a00201.html#a342983a479ae7a921be5face83fdb029">00028</a> <span class="preprocessor">#define FREPPLE_CORE</span> <a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="a00218.html">frepple/model.h</a>"</span> <a name="l00030"></a>00030 <span class="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="a00065.html#a57cd1a48af0ab914b78bb411711c447a">Flow::metadata</a>; <a name="l00034"></a>00034 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keyword">const</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>* <a class="code" href="a00071.html#a76c55c461c57c05fee361b0acaa71fd0">FlowStart::metadata</a>, <a name="l00035"></a>00035 *<a class="code" href="a00066.html#a9f2203732db979d868deaa981d229836">FlowEnd::metadata</a>; <a name="l00036"></a>00036 <a name="l00037"></a>00037 <a name="l00038"></a><a class="code" href="a00065.html#aa9a892bf7301ba668c3871f17830780f">00038</a> <span class="keywordtype">int</span> <a class="code" href="a00065.html#aa9a892bf7301ba668c3871f17830780f">Flow::initialize</a>() <a name="l00039"></a>00039 { <a name="l00040"></a>00040 <span class="comment">// Initialize the metadata</span> <a name="l00041"></a>00041 <a class="code" href="a00065.html#a57cd1a48af0ab914b78bb411711c447a">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="l00042"></a>00042 (<span class="stringliteral">"flow"</span>, <span class="stringliteral">"flows"</span>, MetaCategory::ControllerDefault, <a class="code" href="a00065.html#a308ad9c0fd39b78a25ab6b59558d62f7">writer</a>); <a name="l00043"></a>00043 <a class="code" href="a00071.html#a76c55c461c57c05fee361b0acaa71fd0">FlowStart::metadata</a> = <span class="keyword">new</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>(<span class="stringliteral">"flow"</span>, <span class="stringliteral">"flow_start"</span>, <a name="l00044"></a>00044 Object::createDefault<FlowStart>, <span class="keyword">true</span>); <a name="l00045"></a>00045 <a class="code" href="a00066.html#a9f2203732db979d868deaa981d229836">FlowEnd::metadata</a> = <span class="keyword">new</span> <a class="code" href="a00115.html" title="This class stores metadata about the classes in the library. The stored information...">MetaClass</a>(<span class="stringliteral">"flow"</span>, <span class="stringliteral">"flow_end"</span>, <a name="l00046"></a>00046 Object::createDefault<FlowEnd>); <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="comment">// Initialize the type</span> <a name="l00049"></a>00049 <a class="code" href="a00155.html" title="This class is a thin wrapper around the type information in Python.">PythonType</a>& x = <a class="code" href="a00065.html#a3f717a5154e2bea5a644444b57c9cff6">FreppleCategory<Flow>::getType</a>(); <a name="l00050"></a>00050 x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(<span class="stringliteral">"flow"</span>); <a name="l00051"></a>00051 x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">"frePPLe flow"</span>); <a name="l00052"></a>00052 x.<a class="code" href="a00155.html#a8d3f24e0357f41ac3bc0be78bd2ab268">supportgetattro</a>(); <a name="l00053"></a>00053 x.<a class="code" href="a00155.html#a83866bef191c69cf8506426fe38b8d19">supportsetattro</a>(); <a name="l00054"></a>00054 x.<a class="code" href="a00155.html#a001dc53b2dd832c001aee4d21bc7bf09">supportcreate</a>(create); <a name="l00055"></a>00055 x.<a class="code" href="a00155.html#ab5950f891179f3ae7d31f4977580cb1d">addMethod</a>(<span class="stringliteral">"toXML"</span>, <a class="code" href="a00120.html#a936a4ac5b81ba4f9c9cbe54b9aeeda13">toXML</a>, METH_VARARGS, <span class="stringliteral">"return a XML representation"</span>); <a name="l00056"></a>00056 <span class="keyword">const_cast<</span><a class="code" href="a00114.html" title="A MetaCategory instance represents metadata for a category of object.">MetaCategory</a>*<span class="keyword">></span>(<a class="code" href="a00065.html#a57cd1a48af0ab914b78bb411711c447a">metadata</a>)->pythonClass = x.<a class="code" href="a00155.html#aed0915f1cc32c0c1e12e209abfedf615">type_object</a>(); <a name="l00057"></a>00057 <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>(); <a name="l00058"></a>00058 } <a name="l00059"></a>00059 <a name="l00060"></a>00060 <a name="l00061"></a><a class="code" href="a00065.html#a308ad9c0fd39b78a25ab6b59558d62f7">00061</a> <span class="keywordtype">void</span> <a class="code" href="a00065.html#a308ad9c0fd39b78a25ab6b59558d62f7">Flow::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="l00062"></a>00062 { <a name="l00063"></a>00063 <span class="keywordtype">bool</span> firstflow = <span class="keyword">true</span>; <a name="l00064"></a>00064 <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="l00065"></a>00065 <span class="keywordflow">for</span> (<a class="code" href="a00040.html" title="An iterator over the associated objects.">Operation::flowlist::const_iterator</a> j = i->getFlows().begin(); j != i->getFlows().end(); ++j) <a name="l00066"></a>00066 { <a name="l00067"></a>00067 <span class="keywordflow">if</span> (firstflow) <a name="l00068"></a>00068 { <a name="l00069"></a>00069 o-><a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(<a class="code" href="a00177.html#a945bcc90195696e5059467e3e7e78cce">Tags::tag_flows</a>); <a name="l00070"></a>00070 firstflow = <span class="keyword">false</span>; <a name="l00071"></a>00071 } <a name="l00072"></a>00072 <span class="comment">// We use the FULL mode, to force the flows being written regardless</span> <a name="l00073"></a>00073 <span class="comment">// of the depth in the XML tree.</span> <a name="l00074"></a>00074 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a2b7f55f8d34c873afe442d0eca79c122">Tags::tag_flow</a>, &*j, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398ae6f8960699e19b8d77b093b7e2c48619">FULL</a>); <a name="l00075"></a>00075 } <a name="l00076"></a>00076 <span class="keywordflow">if</span> (!firstflow) o-><a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(<a class="code" href="a00177.html#a945bcc90195696e5059467e3e7e78cce">Tags::tag_flows</a>); <a name="l00077"></a>00077 } <a name="l00078"></a>00078 <a name="l00079"></a>00079 <a name="l00080"></a>00080 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> Flow::validate(<a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a> action) <a name="l00081"></a>00081 { <a name="l00082"></a>00082 <span class="comment">// Catch null operation and buffer pointers</span> <a name="l00083"></a>00083 <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="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>(); <a name="l00084"></a>00084 <a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">Buffer</a>* buf = <a class="code" href="a00065.html#a3034ea6d121f86338faeab26ec7464d4">getBuffer</a>(); <a name="l00085"></a>00085 <span class="keywordflow">if</span> (!oper || !buf) <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <span class="comment">// This flow is not a valid one since it misses essential information</span> <a name="l00088"></a>00088 <span class="keyword">delete</span> <span class="keyword">this</span>; <a name="l00089"></a>00089 <span class="keywordflow">if</span> (!oper && !buf) <a name="l00090"></a>00090 <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">"Missing operation and buffer on a flow"</span>); <a name="l00091"></a>00091 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (!oper) <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">"Missing operation on a flow with buffer '"</span> <a name="l00093"></a>00093 + buf-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"'"</span>); <a name="l00094"></a>00094 <span class="keywordflow">else</span> <a name="l00095"></a>00095 <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">"Missing buffer on a flow with operation '"</span> <a name="l00096"></a>00096 + oper-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"'"</span>); <a name="l00097"></a>00097 } <a name="l00098"></a>00098 <a name="l00099"></a>00099 <span class="comment">// Check if a flow with 1) identical buffer, 2) identical operation and</span> <a name="l00100"></a>00100 <span class="comment">// 3) overlapping effectivity dates already exists</span> <a name="l00101"></a>00101 Operation::flowlist::const_iterator i = oper-><a class="code" href="a00121.html#ac6b2f299c5939e2c61b2724ac58a2326">getFlows</a>().begin(); <a name="l00102"></a>00102 <span class="keywordflow">for</span> (; i != oper-><a class="code" href="a00121.html#ac6b2f299c5939e2c61b2724ac58a2326">getFlows</a>().end(); ++i) <a name="l00103"></a>00103 <span class="keywordflow">if</span> (i->getBuffer() == buf <a name="l00104"></a>00104 && i->getEffective().overlap(<a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>()) <a name="l00105"></a>00105 && &*i != <span class="keyword">this</span>) <a name="l00106"></a>00106 <span class="keywordflow">break</span>; <a name="l00107"></a>00107 <a name="l00108"></a>00108 <span class="comment">// Apply the appropriate action</span> <a name="l00109"></a>00109 <span class="keywordflow">switch</span> (action) <a name="l00110"></a>00110 { <a name="l00111"></a>00111 <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a8f6183fcf54ca6985ff2b5ef80673a25">ADD</a>: <a name="l00112"></a>00112 <span class="keywordflow">if</span> (i != oper-><a class="code" href="a00121.html#ac6b2f299c5939e2c61b2724ac58a2326">getFlows</a>().end()) <a name="l00113"></a>00113 { <a name="l00114"></a>00114 <span class="keyword">delete</span> <span class="keyword">this</span>; <a name="l00115"></a>00115 <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">"Flow of '"</span> + oper-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"' and '"</span> + <a name="l00116"></a>00116 buf-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"' already exists"</span>); <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <span class="keywordflow">break</span>; <a name="l00119"></a>00119 <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a1b9888c025bb8f78e322471fd5e14423">CHANGE</a>: <a name="l00120"></a>00120 <span class="keyword">delete</span> <span class="keyword">this</span>; <a name="l00121"></a>00121 <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">"Can't update a flow"</span>); <a name="l00122"></a>00122 <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a75b4aab762127e8083e16661b4021a00">ADD_CHANGE</a>: <a name="l00123"></a>00123 <span class="comment">// ADD is handled in the code after the switch statement</span> <a name="l00124"></a>00124 <span class="keywordflow">if</span> (i == oper-><a class="code" href="a00121.html#ac6b2f299c5939e2c61b2724ac58a2326">getFlows</a>().end()) <span class="keywordflow">break</span>; <a name="l00125"></a>00125 <span class="keyword">delete</span> <span class="keyword">this</span>; <a name="l00126"></a>00126 <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">"Can't update a flow"</span>); <a name="l00127"></a>00127 <span class="keywordflow">case</span> <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a6b9fb19e9a6595385dec31b63e0054e1">REMOVE</a>: <a name="l00128"></a>00128 <span class="comment">// Delete the temporary flow object</span> <a name="l00129"></a>00129 <span class="keyword">delete</span> <span class="keyword">this</span>; <a name="l00130"></a>00130 <span class="comment">// Nothing to delete</span> <a name="l00131"></a>00131 <span class="keywordflow">if</span> (i == oper-><a class="code" href="a00121.html#ac6b2f299c5939e2c61b2724ac58a2326">getFlows</a>().end()) <a name="l00132"></a>00132 <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">"Can't remove nonexistent flow of '"</span> <a name="l00133"></a>00133 + oper-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"' and '"</span> + buf-><a class="code" href="a00182.html#a7416ca220c55147bc1276becc5b9de01">getName</a>() + <span class="stringliteral">"'"</span>); <a name="l00134"></a>00134 <span class="comment">// Delete</span> <a name="l00135"></a>00135 <span class="keyword">delete</span> &*i; <a name="l00136"></a>00136 } <a name="l00137"></a>00137 <a name="l00138"></a>00138 <span class="comment">// Attach to buffers higher up in the hierarchy</span> <a name="l00139"></a>00139 <span class="comment">// Note that the owner can create more loads if it has an owner too.</span> <a name="l00140"></a>00140 <span class="keywordflow">if</span> (buf-><a class="code" href="a00083.html#a82647634fd837064ba411d51495cfbbd">hasOwner</a>() && action!=<a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a6b9fb19e9a6595385dec31b63e0054e1">REMOVE</a>) <span class="keyword">new</span> <a class="code" href="a00065.html#ace1ec37bd417fc3a199eeb45fc5c8d28">Flow</a>(oper, buf-><a class="code" href="a00083.html#a4bda4eb77f34c0528e176446886fcce1">getOwner</a>(), quantity); <a name="l00141"></a>00141 <a name="l00142"></a>00142 <span class="comment">// Set a flag to make sure the level computation is triggered again</span> <a name="l00143"></a>00143 <a class="code" href="a00084.html#a93fd169e7f2260c640cb278cac466025">HasLevel::triggerLazyRecomputation</a>(); <a name="l00144"></a>00144 } <a name="l00145"></a>00145 <a name="l00146"></a>00146 <a name="l00147"></a><a class="code" href="a00065.html#a9cbc31e4846e1d798306661735c08068">00147</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <a class="code" href="a00065.html#a9cbc31e4846e1d798306661735c08068">Flow::~Flow</a>() <a name="l00148"></a>00148 { <a name="l00149"></a>00149 <span class="comment">// Set a flag to make sure the level computation is triggered again</span> <a name="l00150"></a>00150 <a class="code" href="a00084.html#a93fd169e7f2260c640cb278cac466025">HasLevel::triggerLazyRecomputation</a>(); <a name="l00151"></a>00151 <a name="l00152"></a>00152 <span class="comment">// Delete existing flowplans</span> <a name="l00153"></a>00153 <span class="keywordflow">if</span> (<a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>() && <a class="code" href="a00065.html#a3034ea6d121f86338faeab26ec7464d4">getBuffer</a>()) <a name="l00154"></a>00154 { <a name="l00155"></a>00155 <span class="comment">// Loop over operationplans</span> <a name="l00156"></a>00156 <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="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()); i != <a class="code" href="a00125.html#a0f9f6ba7d4fe7e20e9b88c765fe24f25">OperationPlan::end</a>(); ++i) <a name="l00157"></a>00157 <span class="comment">// Loop over flowplans</span> <a name="l00158"></a>00158 <span class="keywordflow">for</span>(<a class="code" href="a00069.html" title="An iterator class to go through all flowplans of an operationplan.">OperationPlan::FlowPlanIterator</a> j = i->beginFlowPlans(); j != i->endFlowPlans(); ) <a name="l00159"></a>00159 <span class="keywordflow">if</span> (j->getFlow() == <span class="keyword">this</span>) j.deleteFlowPlan(); <a name="l00160"></a>00160 <span class="keywordflow">else</span> ++j; <a name="l00161"></a>00161 } <a name="l00162"></a>00162 <a name="l00163"></a>00163 <span class="comment">// Delete the flow from the operation and the buffer</span> <a name="l00164"></a>00164 <span class="keywordflow">if</span> (<a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()) <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.erase(<span class="keyword">this</span>); <a name="l00165"></a>00165 <span class="keywordflow">if</span> (<a class="code" href="a00065.html#a3034ea6d121f86338faeab26ec7464d4">getBuffer</a>()) <a class="code" href="a00065.html#a3034ea6d121f86338faeab26ec7464d4">getBuffer</a>()->flows.erase(<span class="keyword">this</span>); <a name="l00166"></a>00166 <a name="l00167"></a>00167 <span class="comment">// Clean up alternate flows</span> <a name="l00168"></a>00168 <span class="keywordflow">if</span> (hasAlts) <a name="l00169"></a>00169 { <a name="l00170"></a>00170 <span class="comment">// The flow has alternates.</span> <a name="l00171"></a>00171 <span class="comment">// Make a new flow the leading one. Or if there is only one alternate</span> <a name="l00172"></a>00172 <span class="comment">// present it is not marked as an alternate any more.</span> <a name="l00173"></a>00173 <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> cnt = 0; <a name="l00174"></a>00174 <span class="keywordtype">int</span> minprio = INT_MAX; <a name="l00175"></a>00175 <a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a>* newLeader = NULL; <a name="l00176"></a>00176 <span class="keywordflow">for</span> (<a class="code" href="a00091.html" title="An iterator over the associated objects.">Operation::flowlist::iterator</a> i = <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>(); <a name="l00177"></a>00177 i != <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.end(); ++i) <a name="l00178"></a>00178 <span class="keywordflow">if</span> (i->altFlow == <span class="keyword">this</span>) <a name="l00179"></a>00179 { <a name="l00180"></a>00180 cnt++; <a name="l00181"></a>00181 <span class="keywordflow">if</span> (i->priority < minprio) <a name="l00182"></a>00182 { <a name="l00183"></a>00183 newLeader = &*i; <a name="l00184"></a>00184 minprio = i->priority; <a name="l00185"></a>00185 } <a name="l00186"></a>00186 } <a name="l00187"></a>00187 <span class="keywordflow">if</span> (cnt < 1) <a name="l00188"></a>00188 <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">"Alternate flows update failure"</span>); <a name="l00189"></a>00189 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cnt == 1) <a name="l00190"></a>00190 <span class="comment">// No longer an alternate any more</span> <a name="l00191"></a>00191 newLeader->altFlow = NULL; <a name="l00192"></a>00192 <span class="keywordflow">else</span> <a name="l00193"></a>00193 { <a name="l00194"></a>00194 <span class="comment">// Mark a new leader flow</span> <a name="l00195"></a>00195 newLeader->hasAlts = <span class="keyword">true</span>; <a name="l00196"></a>00196 newLeader->altFlow = NULL; <a name="l00197"></a>00197 <span class="keywordflow">for</span> (<a class="code" href="a00091.html" title="An iterator over the associated objects.">Operation::flowlist::iterator</a> i = <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.<a class="code" href="a00085.html#a1926a798edd9c04bc37e596936003cd6">begin</a>(); <a name="l00198"></a>00198 i != <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.end(); ++i) <a name="l00199"></a>00199 <span class="keywordflow">if</span> (i->altFlow == <span class="keyword">this</span>) i->altFlow = newLeader; <a name="l00200"></a>00200 } <a name="l00201"></a>00201 } <a name="l00202"></a>00202 <span class="keywordflow">if</span> (altFlow) <a name="l00203"></a>00203 { <a name="l00204"></a>00204 <span class="comment">// The flow is an alternate of another one.</span> <a name="l00205"></a>00205 <span class="comment">// If it was the only alternate, then the hasAlts flag on the parent</span> <a name="l00206"></a>00206 <span class="comment">// flow needs to be set back to false</span> <a name="l00207"></a>00207 <span class="keywordtype">bool</span> only_one = <span class="keyword">true</span>; <a name="l00208"></a>00208 <span class="keywordflow">for</span> (<a class="code" href="a00091.html" title="An iterator over the associated objects.">Operation::flowlist::iterator</a> i = <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.begin(); <a name="l00209"></a>00209 i != <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.end(); ++i) <a name="l00210"></a>00210 <span class="keywordflow">if</span> (i->altFlow == altFlow) <a name="l00211"></a>00211 { <a name="l00212"></a>00212 only_one = <span class="keyword">false</span>; <a name="l00213"></a>00213 <span class="keywordflow">break</span>; <a name="l00214"></a>00214 } <a name="l00215"></a>00215 <span class="keywordflow">if</span> (only_one) altFlow->hasAlts = <span class="keyword">false</span>; <a name="l00216"></a>00216 } <a name="l00217"></a>00217 } <a name="l00218"></a>00218 <a name="l00219"></a>00219 <a name="l00220"></a><a class="code" href="a00065.html#a15ed015585168ab76a66da36447f9483">00220</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00065.html#a15ed015585168ab76a66da36447f9483">Flow::setAlternate</a>(<a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a> *f) <a name="l00221"></a>00221 { <a name="l00222"></a>00222 <span class="comment">// Validate the argument</span> <a name="l00223"></a>00223 <span class="keywordflow">if</span> (!f) <a name="l00224"></a>00224 <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">"Setting NULL alternate flow"</span>); <a name="l00225"></a>00225 <span class="keywordflow">if</span> (hasAlts || f->altFlow) <a name="l00226"></a>00226 <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">"Nested alternate flows are not allowed"</span>); <a name="l00227"></a>00227 <span class="keywordflow">if</span> (!f-><a class="code" href="a00065.html#a306253a0c51478215c2709d9f36e096a">isConsumer</a>() || !<a class="code" href="a00065.html#a306253a0c51478215c2709d9f36e096a">isConsumer</a>()) <a name="l00228"></a>00228 <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">"Only consuming alternate flows are supported"</span>); <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="comment">// Update both flows</span> <a name="l00231"></a>00231 f->hasAlts = <span class="keyword">true</span>; <a name="l00232"></a>00232 altFlow = f; <a name="l00233"></a>00233 } <a name="l00234"></a>00234 <a name="l00235"></a>00235 <a name="l00236"></a><a class="code" href="a00065.html#ae2f035507f2ba15c6958c63df01c496d">00236</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00065.html#a15ed015585168ab76a66da36447f9483">Flow::setAlternate</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& n) <a name="l00237"></a>00237 { <a name="l00238"></a>00238 <span class="keywordflow">if</span> (!<a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()) <a name="l00239"></a>00239 <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">"Can't set an alternate flow before setting the operation"</span>); <a name="l00240"></a>00240 <a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a> *x = <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()->flowdata.find(n); <a name="l00241"></a>00241 <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">"Can't find flow with name '"</span> + n + <span class="stringliteral">"'"</span>); <a name="l00242"></a>00242 <a class="code" href="a00065.html#a15ed015585168ab76a66da36447f9483">setAlternate</a>(x); <a name="l00243"></a>00243 } <a name="l00244"></a>00244 <a name="l00245"></a>00245 <a name="l00246"></a><a class="code" href="a00065.html#a5dfbe11d919a0028ceeea0a7de2da8df">00246</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00065.html#a5dfbe11d919a0028ceeea0a7de2da8df">Flow::writeElement</a> (<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>& tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m)<span class="keyword"> const</span> <a name="l00247"></a>00247 <span class="keyword"></span>{ <a name="l00248"></a>00248 <span class="comment">// If the flow has already been saved, no need to repeat it again</span> <a name="l00249"></a>00249 <span class="comment">// A 'reference' to a flow is not useful to be saved.</span> <a name="l00250"></a>00250 <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>) <span class="keywordflow">return</span>; <a name="l00251"></a>00251 assert(m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>); <a name="l00252"></a>00252 <a name="l00253"></a>00253 <span class="comment">// Write the header</span> <a name="l00254"></a>00254 o-><a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(tag, <a class="code" href="a00177.html#a6745112e0237e378e2b0cbe41aa5926a">Tags::tag_type</a>, <a class="code" href="a00065.html#a3f717a5154e2bea5a644444b57c9cff6">getType</a>().type); <a name="l00255"></a>00255 <a name="l00256"></a>00256 <span class="comment">// If the flow is defined inside of an operation tag, we don't need to save</span> <a name="l00257"></a>00257 <span class="comment">// the operation. Otherwise we do save it...</span> <a name="l00258"></a>00258 <span class="keywordflow">if</span> (!dynamic_cast<Operation*>(o-><a class="code" href="a00189.html#ab1c39c9ee1016cc2d29152fa95fa769d">getPreviousObject</a>())) <a name="l00259"></a>00259 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>, <a class="code" href="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()); <a name="l00260"></a>00260 <a name="l00261"></a>00261 <span class="comment">// If the flow is defined inside of an buffer tag, we don't need to save</span> <a name="l00262"></a>00262 <span class="comment">// the buffer. Otherwise we do save it...</span> <a name="l00263"></a>00263 <span class="keywordflow">if</span> (!dynamic_cast<Buffer*>(o-><a class="code" href="a00189.html#ab1c39c9ee1016cc2d29152fa95fa769d">getPreviousObject</a>())) <a name="l00264"></a>00264 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#abbb33739cafd28ff9a14d3e96d41b8c4">Tags::tag_buffer</a>, <a class="code" href="a00065.html#a3034ea6d121f86338faeab26ec7464d4">getBuffer</a>()); <a name="l00265"></a>00265 <a name="l00266"></a>00266 <span class="comment">// Write the quantity, priority, name and alternate</span> <a name="l00267"></a>00267 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ab99ddcbeef0f5d15a8731dcdffa0dcff">Tags::tag_quantity</a>, <a class="code" href="a00065.html#a29332e8619e350ec887efbdead1c1b11">getQuantity</a>()); <a name="l00268"></a>00268 <span class="keywordflow">if</span> (<a class="code" href="a00065.html#a8cac1ed580a00c11f797bf0eae77330e">getPriority</a>()!=1) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>, <a class="code" href="a00065.html#a8cac1ed580a00c11f797bf0eae77330e">getPriority</a>()); <a name="l00269"></a>00269 <span class="keywordflow">if</span> (!<a class="code" href="a00118.html#affaaf99e62eb70939f0ccc0ddc313c57">getName</a>().empty()) o-><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="l00270"></a>00270 <span class="keywordflow">if</span> (<a class="code" href="a00065.html#a24a2afc7eb0ad57edf20f87e9ce2de96">getAlternate</a>()) <a name="l00271"></a>00271 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>, <a class="code" href="a00065.html#a24a2afc7eb0ad57edf20f87e9ce2de96">getAlternate</a>()-><a class="code" href="a00118.html#affaaf99e62eb70939f0ccc0ddc313c57">getName</a>()); <a name="l00272"></a>00272 <a name="l00273"></a>00273 <span class="comment">// Write the effective daterange</span> <a name="l00274"></a>00274 <span class="keywordflow">if</span> (<a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().getStart() != Date::infinitePast) <a name="l00275"></a>00275 o-><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="l00276"></a>00276 <span class="keywordflow">if</span> (<a class="code" href="a00118.html#a3056abd641cadca725336059b9e91b1b">getEffective</a>().getEnd() != Date::infiniteFuture) <a name="l00277"></a>00277 o-><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="l00278"></a>00278 <a name="l00279"></a>00279 <span class="comment">// End of flow object</span> <a name="l00280"></a>00280 o-><a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag); <a name="l00281"></a>00281 } <a name="l00282"></a>00282 <a name="l00283"></a>00283 <a name="l00284"></a><a class="code" href="a00065.html#a1caf73b47d83e6a5a27b183500b56474">00284</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00065.html#a1caf73b47d83e6a5a27b183500b56474">Flow::beginElement</a>(<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>& pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& pAttr) <a name="l00285"></a>00285 { <a name="l00286"></a>00286 <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#abbb33739cafd28ff9a14d3e96d41b8c4">Tags::tag_buffer</a>)) <a name="l00287"></a>00287 pIn.<a class="code" href="a00186.html#a88dd6be5af6fc605d2d420fbcb397b18">readto</a>( <a class="code" href="a00085.html#ac14340cc8781e6f2b7235d50a1d17914">Buffer::reader</a>(<a class="code" href="a00008.html#ac768b16e2c57bb8a8d028d17b8565543">Buffer::metadata</a>,pIn.<a class="code" href="a00186.html#adcc4751961526c0103536acd194d32a0">getAttributes</a>()) ); <a name="l00288"></a>00288 <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="l00289"></a>00289 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="l00290"></a>00290 } <a name="l00291"></a>00291 <a name="l00292"></a>00292 <a name="l00293"></a><a class="code" href="a00065.html#a9cfcb370887357ac10be5b051ff158e5">00293</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00065.html#a9cfcb370887357ac10be5b051ff158e5">Flow::endElement</a> (<a class="code" href="a00186.html" title="This class will read in an XML-file and call the appropriate handler functions of...">XMLInput</a>& pIn, <span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& pAttr, <span class="keyword">const</span> <a class="code" href="a00047.html" title="This abstract class represents a attribute and value pair for updating objects in...">DataElement</a>& pElement) <a name="l00294"></a>00294 { <a name="l00295"></a>00295 <span class="keywordflow">if</span> (pAttr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a> (<a class="code" href="a00177.html#abbb33739cafd28ff9a14d3e96d41b8c4">Tags::tag_buffer</a>)) <a name="l00296"></a>00296 { <a name="l00297"></a>00297 <a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">Buffer</a> * b = <span class="keyword">dynamic_cast<</span><a class="code" href="a00008.html" title="A buffer represents a combination of a item and location. It is the entity for keeping...">Buffer</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00298"></a>00298 <span class="keywordflow">if</span> (b) <a class="code" href="a00065.html#a40617c135538c6efd90cd515d7026032">setBuffer</a>(b); <a name="l00299"></a>00299 <span class="keywordflow">else</span> <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">"Incorrect object type during read operation"</span>); <a name="l00300"></a>00300 } <a name="l00301"></a>00301 <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="l00302"></a>00302 { <a name="l00303"></a>00303 <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<</span><a class="code" href="a00121.html" title="An operation represents an activity: these consume and produce material, take time...">Operation</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a98008d76b6971b2592ee5ae6f0f03d4c">getPreviousObject</a>()); <a name="l00304"></a>00304 <span class="keywordflow">if</span> (o) <a class="code" href="a00065.html#a6d954f1d4e61bd68fcb4cafb8a30d24a">setOperation</a>(o); <a name="l00305"></a>00305 <span class="keywordflow">else</span> <span class="keywordflow">throw</span> <a class="code" href="a00111.html" title="An exception of this type is thrown when the library gets in an inconsistent state...">LogicException</a>(<span class="stringliteral">"Incorrect object type during read operation"</span>); <a name="l00306"></a>00306 } <a name="l00307"></a>00307 <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="l00308"></a>00308 <a class="code" href="a00065.html#a96f7a635f0f33ff70455c4eabb7b3c19">setQuantity</a>(pElement.<a class="code" href="a00047.html#a88f1178689f984215c4bef4eb5a0d5d9">getDouble</a>()); <a name="l00309"></a>00309 <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="l00310"></a>00310 <a class="code" href="a00065.html#a4d95731a9a9abe9ccf2544905f420913">setPriority</a>(pElement.<a class="code" href="a00047.html#a0d8c973cc584400f5ea5d8acfd82ace2">getInt</a>()); <a name="l00311"></a>00311 <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="l00312"></a>00312 <a class="code" href="a00118.html#aad94a1f71b6c996f21de620a396deee8">setName</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>()); <a name="l00313"></a>00313 <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="l00314"></a>00314 <a class="code" href="a00065.html#a15ed015585168ab76a66da36447f9483">setAlternate</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>()); <a name="l00315"></a>00315 <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="l00316"></a>00316 <a class="code" href="a00065.html#a86dca007409391d08d3640c3eb1161b0">setSearch</a>(pElement.<a class="code" href="a00047.html#a053aa4cde35b21a399f26bca0132ab3f">getString</a>()); <a name="l00317"></a>00317 <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="l00318"></a>00318 { <a name="l00319"></a>00319 <span class="keyword">delete</span> <span class="keyword">static_cast<</span><a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>()); <a name="l00320"></a>00320 pIn.<a class="code" href="a00186.html#af76fa6f3fe40bd167a36b4ab859e0ff6">setUserArea</a>( <a name="l00321"></a>00321 <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="l00322"></a>00322 ); <a name="l00323"></a>00323 } <a name="l00324"></a>00324 <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="l00325"></a>00325 <a class="code" href="a00118.html#a71ec773359069c5e359e22aa51feff65">setEffectiveEnd</a>(pElement.<a class="code" href="a00047.html#abe8c2019e5f79328a6a1fa1f3bb4bbae">getDate</a>()); <a name="l00326"></a>00326 <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="l00327"></a>00327 <a class="code" href="a00118.html#a72f447f9560509a5c9ca04250e6f2981">setEffectiveStart</a>(pElement.<a class="code" href="a00047.html#abe8c2019e5f79328a6a1fa1f3bb4bbae">getDate</a>()); <a name="l00328"></a>00328 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pIn.<a class="code" href="a00186.html#a42fe5e4ae141efb84744b8a359e38bd9">isObjectEnd</a>()) <a name="l00329"></a>00329 { <a name="l00330"></a>00330 <span class="comment">// The flow data are now all read in. See if it makes sense now...</span> <a name="l00331"></a>00331 <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a> a = pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>() ? <a name="l00332"></a>00332 *<span class="keyword">static_cast<</span><a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>()) : <a name="l00333"></a>00333 <a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4a75b4aab762127e8083e16661b4021a00">ADD_CHANGE</a>; <a name="l00334"></a>00334 <span class="keyword">delete</span> <span class="keyword">static_cast<</span><a class="code" href="a00257.html#a07f97ddf3e649a4d2aa13cb900b5dcf4">Action</a>*<span class="keyword">></span>(pIn.<a class="code" href="a00186.html#a656f44229f4251a26773decd010caaaf">getUserArea</a>()); <a name="l00335"></a>00335 validate(a); <a name="l00336"></a>00336 } <a name="l00337"></a>00337 } <a name="l00338"></a>00338 <a name="l00339"></a>00339 <a name="l00340"></a>00340 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">void</span> <a class="code" href="a00066.html#aff668cf48e9f1c26f917b64a238ae78b">FlowEnd::writeElement</a> <a name="l00341"></a><a class="code" href="a00066.html#aff668cf48e9f1c26f917b64a238ae78b">00341</a> (<a class="code" href="a00189.html" title="Base class for writing XML formatted data to an output stream.">XMLOutput</a> *o, <span class="keyword">const</span> <a class="code" href="a00096.html" title="This class defines a keyword for the frePPLe data model.">Keyword</a>& tag, <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398">mode</a> m) <span class="keyword">const</span> <a name="l00342"></a>00342 { <a name="l00343"></a>00343 <span class="comment">// If the flow has already been saved, no need to repeat it again</span> <a name="l00344"></a>00344 <span class="comment">// A 'reference' to a flow is not useful to be saved.</span> <a name="l00345"></a>00345 <span class="keywordflow">if</span> (m == <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a874240ada53cc5b608466064d86d91ae">REFERENCE</a>) <span class="keywordflow">return</span>; <a name="l00346"></a>00346 assert(m != <a class="code" href="a00257.html#a20c2c7e4c6b668e71c154ae3eb18f398a2ad5e75fe119e297630882d182832243">NOHEADER</a>); <a name="l00347"></a>00347 <a name="l00348"></a>00348 <span class="comment">// Write the header</span> <a name="l00349"></a>00349 o-><a class="code" href="a00189.html#a5c1811dae2e3eae344ad366f6441a8a5">BeginObject</a>(tag, <a class="code" href="a00177.html#a6745112e0237e378e2b0cbe41aa5926a">Tags::tag_type</a>, getType().type); <a name="l00350"></a>00350 <a name="l00351"></a>00351 <span class="comment">// If the flow is defined inside of an operation tag, we don't need to save</span> <a name="l00352"></a>00352 <span class="comment">// the operation. Otherwise we do save it...</span> <a name="l00353"></a>00353 <span class="keywordflow">if</span> (!dynamic_cast<Operation*>(o-><a class="code" href="a00189.html#ab1c39c9ee1016cc2d29152fa95fa769d">getPreviousObject</a>())) <a name="l00354"></a>00354 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ad70b79a1c1f3f6d13539207da4f19609">Tags::tag_operation</a>, getOperation()); <a name="l00355"></a>00355 <a name="l00356"></a>00356 <span class="comment">// If the flow is defined inside of an buffer tag, we don't need to save</span> <a name="l00357"></a>00357 <span class="comment">// the buffer. Otherwise we do save it...</span> <a name="l00358"></a>00358 <span class="keywordflow">if</span> (!dynamic_cast<Buffer*>(o-><a class="code" href="a00189.html#ab1c39c9ee1016cc2d29152fa95fa769d">getPreviousObject</a>())) <a name="l00359"></a>00359 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#abbb33739cafd28ff9a14d3e96d41b8c4">Tags::tag_buffer</a>, getBuffer()); <a name="l00360"></a>00360 <a name="l00361"></a>00361 <span class="comment">// Write the quantity, priority name and alternate</span> <a name="l00362"></a>00362 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ab99ddcbeef0f5d15a8731dcdffa0dcff">Tags::tag_quantity</a>, getQuantity()); <a name="l00363"></a>00363 <span class="keywordflow">if</span> (getPriority()!=1) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#af594a7455ab0f7ee255eab14acb44229">Tags::tag_priority</a>, getPriority()); <a name="l00364"></a>00364 <span class="keywordflow">if</span> (!getName().empty()) o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#aeb3841a93774dfc303e3df16304b5af2">Tags::tag_name</a>, getName()); <a name="l00365"></a>00365 <span class="keywordflow">if</span> (getAlternate()) <a name="l00366"></a>00366 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a4064419889249bb11c00e841a6b64044">Tags::tag_alternate</a>, getAlternate()->getName()); <a name="l00367"></a>00367 <a name="l00368"></a>00368 <span class="comment">// Write the effective daterange</span> <a name="l00369"></a>00369 <span class="keywordflow">if</span> (getEffective().getStart() != Date::infinitePast) <a name="l00370"></a>00370 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#ae1f2e352a23d5deaddd90a377e1980cd">Tags::tag_effective_start</a>, getEffective().getStart()); <a name="l00371"></a>00371 <span class="keywordflow">if</span> (getEffective().getEnd() != Date::infiniteFuture) <a name="l00372"></a>00372 o-><a class="code" href="a00189.html#a711922eea4cfe3c33b97e4188dacc7d2">writeElement</a>(<a class="code" href="a00177.html#a0bd36aad5b52bb4ec75d969fe351f583">Tags::tag_effective_end</a>, getEffective().getEnd()); <a name="l00373"></a>00373 <a name="l00374"></a>00374 <span class="comment">// End of flow object</span> <a name="l00375"></a>00375 o-><a class="code" href="a00189.html#a05375aa593bb0514020b035411c8983c">EndObject</a>(tag); <a name="l00376"></a>00376 } <a name="l00377"></a>00377 <a name="l00378"></a>00378 <a name="l00379"></a>00379 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> PyObject* Flow::getattro(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& attr) <a name="l00380"></a>00380 { <a name="l00381"></a>00381 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#abbb33739cafd28ff9a14d3e96d41b8c4">Tags::tag_buffer</a>)) <a name="l00382"></a>00382 <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="a00065.html#a3034ea6d121f86338faeab26ec7464d4">getBuffer</a>()); <a name="l00383"></a>00383 <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="l00384"></a>00384 <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="a00065.html#af7649182aaa0020e9684ccd337a357ad">getOperation</a>()); <a name="l00385"></a>00385 <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="l00386"></a>00386 <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="a00065.html#a29332e8619e350ec887efbdead1c1b11">getQuantity</a>()); <a name="l00387"></a>00387 <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="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>(<a class="code" href="a00065.html#a8cac1ed580a00c11f797bf0eae77330e">getPriority</a>()); <a name="l00389"></a>00389 <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="l00390"></a>00390 <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="l00391"></a>00391 <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="l00392"></a>00392 <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="l00393"></a>00393 <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="l00394"></a>00394 <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="l00395"></a>00395 <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="l00396"></a>00396 <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="a00065.html#a24a2afc7eb0ad57edf20f87e9ce2de96">getAlternate</a>()); <a name="l00397"></a>00397 <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="l00398"></a>00398 { <a name="l00399"></a>00399 ostringstream ch; <a name="l00400"></a>00400 ch << <a class="code" href="a00065.html#a05fe56fbc1e8ee1712ead3b6cb554584">getSearch</a>(); <a name="l00401"></a>00401 <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="l00402"></a>00402 } <a name="l00403"></a>00403 <span class="keywordflow">return</span> NULL; <a name="l00404"></a>00404 } <a name="l00405"></a>00405 <a name="l00406"></a>00406 <a name="l00407"></a>00407 <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a> <span class="keywordtype">int</span> Flow::setattro(<span class="keyword">const</span> <a class="code" href="a00002.html" title="A class to model keyword instances.">Attribute</a>& attr, <span class="keyword">const</span> <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a>& field) <a name="l00408"></a>00408 { <a name="l00409"></a>00409 <span class="keywordflow">if</span> (attr.<a class="code" href="a00002.html#aebffce6c4fcf1696ca34f63f2b6ee091">isA</a>(<a class="code" href="a00177.html#abbb33739cafd28ff9a14d3e96d41b8c4">Tags::tag_buffer</a>)) <a name="l00410"></a>00410 { <a name="l00411"></a>00411 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00008.html#ac768b16e2c57bb8a8d028d17b8565543">Buffer::metadata</a>)) <a name="l00412"></a>00412 { <a name="l00413"></a>00413 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"flow buffer must be of type buffer"</span>); <a name="l00414"></a>00414 <span class="keywordflow">return</span> -1; <a name="l00415"></a>00415 } <a name="l00416"></a>00416 Buffer* y = <span class="keyword">static_cast<</span>Buffer*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00417"></a>00417 <a class="code" href="a00065.html#a40617c135538c6efd90cd515d7026032">setBuffer</a>(y); <a name="l00418"></a>00418 } <a name="l00419"></a>00419 <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="l00420"></a>00420 { <a name="l00421"></a>00421 <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="l00422"></a>00422 { <a name="l00423"></a>00423 PyErr_SetString(<a class="code" href="a00257.html#a75c689d2dca4282e2ca0dad79dab1063" title="Python exception class matching with frepple::DataException.">PythonDataException</a>, <span class="stringliteral">"flow operation must be of type operation"</span>); <a name="l00424"></a>00424 <span class="keywordflow">return</span> -1; <a name="l00425"></a>00425 } <a name="l00426"></a>00426 Operation* y = <span class="keyword">static_cast<</span>Operation*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00427"></a>00427 <a class="code" href="a00065.html#a6d954f1d4e61bd68fcb4cafb8a30d24a">setOperation</a>(y); <a name="l00428"></a>00428 } <a name="l00429"></a>00429 <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="l00430"></a>00430 <a class="code" href="a00065.html#a96f7a635f0f33ff70455c4eabb7b3c19">setQuantity</a>(field.<a class="code" href="a00154.html#ad292e9b75b65eef65ff8701939ab348a">getDouble</a>()); <a name="l00431"></a>00431 <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="l00432"></a>00432 <a class="code" href="a00065.html#a4d95731a9a9abe9ccf2544905f420913">setPriority</a>(field.<a class="code" href="a00154.html#a783ec10f02cad37886df55bc3f08ba5e">getInt</a>()); <a name="l00433"></a>00433 <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="l00434"></a>00434 <a class="code" href="a00118.html#a71ec773359069c5e359e22aa51feff65">setEffectiveEnd</a>(field.<a class="code" href="a00154.html#aa72c83cab5f89f71aff63f0bfad26bd1">getDate</a>()); <a name="l00435"></a>00435 <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="l00436"></a>00436 <a class="code" href="a00118.html#a72f447f9560509a5c9ca04250e6f2981">setEffectiveStart</a>(field.<a class="code" href="a00154.html#aa72c83cab5f89f71aff63f0bfad26bd1">getDate</a>()); <a name="l00437"></a>00437 <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="l00438"></a>00438 <a class="code" href="a00118.html#aad94a1f71b6c996f21de620a396deee8">setName</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>()); <a name="l00439"></a>00439 <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="l00440"></a>00440 { <a name="l00441"></a>00441 <span class="keywordflow">if</span> (!field.<a class="code" href="a00154.html#aa5f7a25056671e8df629cd42b0061b28">check</a>(<a class="code" href="a00065.html#a57cd1a48af0ab914b78bb411711c447a">Flow::metadata</a>)) <a name="l00442"></a>00442 <a class="code" href="a00065.html#a15ed015585168ab76a66da36447f9483">setAlternate</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>()); <a name="l00443"></a>00443 <span class="keywordflow">else</span> <a name="l00444"></a>00444 { <a name="l00445"></a>00445 <a class="code" href="a00065.html#ace1ec37bd417fc3a199eeb45fc5c8d28">Flow</a> *y = <span class="keyword">static_cast<</span><a class="code" href="a00065.html#ace1ec37bd417fc3a199eeb45fc5c8d28">Flow</a>*<span class="keyword">></span>(<span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(field)); <a name="l00446"></a>00446 <a class="code" href="a00065.html#a15ed015585168ab76a66da36447f9483">setAlternate</a>(y); <a name="l00447"></a>00447 } <a name="l00448"></a>00448 } <a name="l00449"></a>00449 <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="l00450"></a>00450 <a class="code" href="a00065.html#a86dca007409391d08d3640c3eb1161b0">setSearch</a>(field.<a class="code" href="a00154.html#a471bd4797fe735e12a1f485e05fc5940">getString</a>()); <a name="l00451"></a>00451 <span class="keywordflow">else</span> <a name="l00452"></a>00452 <span class="keywordflow">return</span> -1; <a name="l00453"></a>00453 <span class="keywordflow">return</span> 0; <a name="l00454"></a>00454 } <a name="l00455"></a>00455 <a name="l00456"></a>00456 <span class="comment"></span> <a name="l00457"></a>00457 <span class="comment">/** @todo method implementation not generic and doesn't support clean subclassing. */</span> <a name="l00458"></a>00458 PyObject* Flow::create(PyTypeObject* pytype, PyObject* args, PyObject* kwds) <a name="l00459"></a>00459 { <a name="l00460"></a>00460 <span class="keywordflow">try</span> <a name="l00461"></a>00461 { <a name="l00462"></a>00462 <span class="comment">// Pick up the operation</span> <a name="l00463"></a>00463 PyObject* oper = PyDict_GetItemString(kwds,<span class="stringliteral">"operation"</span>); <a name="l00464"></a>00464 <span class="keywordflow">if</span> (!PyObject_TypeCheck(oper, <a class="code" href="a00121.html#afcc9adf1a9c37fd168af778368601978">Operation::metadata</a>->pythonClass)) <a name="l00465"></a>00465 <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">"flow operation must be of type operation"</span>); <a name="l00466"></a>00466 <a name="l00467"></a>00467 <span class="comment">// Pick up the resource</span> <a name="l00468"></a>00468 PyObject* buf = PyDict_GetItemString(kwds,<span class="stringliteral">"buffer"</span>); <a name="l00469"></a>00469 <span class="keywordflow">if</span> (!PyObject_TypeCheck(buf, <a class="code" href="a00008.html#ac768b16e2c57bb8a8d028d17b8565543">Buffer::metadata</a>->pythonClass)) <a name="l00470"></a>00470 <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">"flow buffer must be of type buffer"</span>); <a name="l00471"></a>00471 <a name="l00472"></a>00472 <span class="comment">// Pick up the quantity</span> <a name="l00473"></a>00473 PyObject* q1 = PyDict_GetItemString(kwds,<span class="stringliteral">"quantity"</span>); <a name="l00474"></a>00474 <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="l00475"></a>00475 <a name="l00476"></a>00476 <span class="comment">// Pick up the type and create the flow</span> <a name="l00477"></a>00477 <a class="code" href="a00065.html#ace1ec37bd417fc3a199eeb45fc5c8d28">Flow</a> *l; <a name="l00478"></a>00478 PyObject* t = PyDict_GetItemString(kwds,<span class="stringliteral">"type"</span>); <a name="l00479"></a>00479 <span class="keywordflow">if</span> (t) <a name="l00480"></a>00480 { <a name="l00481"></a>00481 <a class="code" href="a00154.html" title="This class handles two-way translation between the data types in C++ and Python.">PythonObject</a> d(t); <a name="l00482"></a>00482 <span class="keywordflow">if</span> (d.getString() == <span class="stringliteral">"flow_end"</span>) <a name="l00483"></a>00483 l = <span class="keyword">new</span> FlowEnd( <a name="l00484"></a>00484 static_cast<Operation*>(oper), <a name="l00485"></a>00485 <span class="keyword">static_cast<</span>Buffer*<span class="keyword">></span>(buf), <a name="l00486"></a>00486 q2 <a name="l00487"></a>00487 ); <a name="l00488"></a>00488 <span class="keywordflow">else</span> <a name="l00489"></a>00489 l = <span class="keyword">new</span> FlowStart( <a name="l00490"></a>00490 static_cast<Operation*>(oper), <a name="l00491"></a>00491 static_cast<Buffer*>(buf), <a name="l00492"></a>00492 q2 <a name="l00493"></a>00493 ); <a name="l00494"></a>00494 } <a name="l00495"></a>00495 <span class="keywordflow">else</span> <a name="l00496"></a>00496 l = <span class="keyword">new</span> FlowStart( <a name="l00497"></a>00497 static_cast<Operation*>(oper), <a name="l00498"></a>00498 static_cast<Buffer*>(buf), <a name="l00499"></a>00499 q2 <a name="l00500"></a>00500 ); <a name="l00501"></a>00501 <a name="l00502"></a>00502 <span class="comment">// Pick up the effective start date</span> <a name="l00503"></a>00503 PyObject* eff_start = PyDict_GetItemString(kwds,<span class="stringliteral">"effective_start"</span>); <a name="l00504"></a>00504 <span class="keywordflow">if</span> (eff_start) <a name="l00505"></a>00505 { <a name="l00506"></a>00506 <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="l00507"></a>00507 l->setEffectiveStart(d.getDate()); <a name="l00508"></a>00508 } <a name="l00509"></a>00509 <a name="l00510"></a>00510 <span class="comment">// Pick up the effective end date</span> <a name="l00511"></a>00511 PyObject* eff_end = PyDict_GetItemString(kwds,<span class="stringliteral">"effective_end"</span>); <a name="l00512"></a>00512 <span class="keywordflow">if</span> (eff_end) <a name="l00513"></a>00513 { <a name="l00514"></a>00514 <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="l00515"></a>00515 l->setEffectiveEnd(d.getDate()); <a name="l00516"></a>00516 } <a name="l00517"></a>00517 <a name="l00518"></a>00518 <span class="comment">// Return the object</span> <a name="l00519"></a>00519 Py_INCREF(l); <a name="l00520"></a>00520 <span class="keywordflow">return</span> <span class="keyword">static_cast<</span>PyObject*<span class="keyword">></span>(l); <a name="l00521"></a>00521 } <a name="l00522"></a>00522 <span class="keywordflow">catch</span> (...) <a name="l00523"></a>00523 { <a name="l00524"></a>00524 PythonType::evalException(); <a name="l00525"></a>00525 <span class="keywordflow">return</span> NULL; <a name="l00526"></a>00526 } <a name="l00527"></a>00527 } <a name="l00528"></a>00528 <a name="l00529"></a>00529 <a name="l00530"></a><a class="code" href="a00067.html#a5a34fc248d4cfd7addeccca070a60c20">00530</a> <span class="keywordtype">int</span> <a class="code" href="a00067.html#a5a34fc248d4cfd7addeccca070a60c20">FlowIterator::initialize</a>() <a name="l00531"></a>00531 { <a name="l00532"></a>00532 <span class="comment">// Initialize the type</span> <a name="l00533"></a>00533 <a class="code" href="a00155.html" title="This class is a thin wrapper around the type information in Python.">PythonType</a>& x = <a class="code" href="a00150.html#aec65c2cd811051918027ae6dc00fcfaf">PythonExtension<FlowIterator>::getType</a>(); <a name="l00534"></a>00534 x.<a class="code" href="a00155.html#af9217b67c7c60e8e87c703066d6970d5">setName</a>(<span class="stringliteral">"flowIterator"</span>); <a name="l00535"></a>00535 x.<a class="code" href="a00155.html#aaafe003660694b2cf497a89815d7fe49">setDoc</a>(<span class="stringliteral">"frePPLe iterator for flows"</span>); <a name="l00536"></a>00536 x.<a class="code" href="a00155.html#a5bacf8ad021ab55b1056440880cf8760">supportiter</a>(); <a name="l00537"></a>00537 <span class="keywordflow">return</span> x.<a class="code" href="a00155.html#a5b2be5d75982b077b2d694c269d43778">typeReady</a>(); <a name="l00538"></a>00538 } <a name="l00539"></a>00539 <a name="l00540"></a>00540 <a name="l00541"></a>00541 PyObject* FlowIterator::iternext() <a name="l00542"></a>00542 { <a name="l00543"></a>00543 PyObject* result; <a name="l00544"></a>00544 <span class="keywordflow">if</span> (buf) <a name="l00545"></a>00545 { <a name="l00546"></a>00546 <span class="comment">// Iterate over flows on a buffer</span> <a name="l00547"></a>00547 <span class="keywordflow">if</span> (ib == buf->getFlows().end()) <span class="keywordflow">return</span> NULL; <a name="l00548"></a>00548 result = <span class="keyword">const_cast<</span><a class="code" href="a00065.html" title="This class defines a material flow to/from a buffer, linked with an operation. This...">Flow</a>*<span class="keyword">></span>(&*ib); <a name="l00549"></a>00549 ++ib; <a name="l00550"></a>00550 } <a name="l00551"></a>00551 <span class="keywordflow">else</span> <a name="l00552"></a>00552 { <a name="l00553"></a>00553 <span class="comment">// Iterate over flows on an operation</span> <a name="l00554"></a>00554 <span class="keywordflow">if</span> (io == oper->getFlows().end()) <span class="keywordflow">return</span> NULL; <a name="l00555"></a>00555 result = <span class="keyword">const_cast<</span>Flow*<span class="keyword">></span>(&*io); <a name="l00556"></a>00556 ++io; <a name="l00557"></a>00557 } <a name="l00558"></a>00558 Py_INCREF(result); <a name="l00559"></a>00559 <span class="keywordflow">return</span> result; <a name="l00560"></a>00560 } <a name="l00561"></a>00561 <a name="l00562"></a>00562 } <span class="comment">// end namespace</span> </pre></div></div> <hr size="1"/><address style="align: right;"><small>Documentation generated for frePPLe by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"/></a></small></address> </div> </div> </body> </html>