<!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: dllmain.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> </div> </div> <div class="contents"> <h1>dllmain.cpp</h1><a href="a00200.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/dllmain.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="a00200.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="a00206.html" title="Public header file for C++.">frepple.h</a>"</span> <a name="l00030"></a>00030 <span class="preprocessor">#include "<a class="code" href="a00207.html" title="Public header file for C and C++.">freppleinterface.h</a>"</span> <a name="l00031"></a>00031 <span class="keyword">using namespace </span>frepple; <a name="l00032"></a>00032 <span class="preprocessor">#include <sys/stat.h></span> <a name="l00033"></a>00033 <a name="l00034"></a>00034 <a name="l00035"></a><a class="code" href="a00207.html#a597067b13c71006d886fb8c124a1d003">00035</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>*) <a class="code" href="a00200.html#a597067b13c71006d886fb8c124a1d003">FreppleVersion</a>() <a name="l00036"></a>00036 { <a name="l00037"></a>00037 <span class="keywordflow">return</span> <a class="code" href="a00252.html#aa326a05d5e30f9e9a4bb0b4469d5d0c0">PACKAGE_VERSION</a>; <a name="l00038"></a>00038 } <a name="l00039"></a>00039 <a name="l00040"></a>00040 <a name="l00041"></a><a class="code" href="a00207.html#a13335a18ae6783b5c2aa79a73c0947f9">00041</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">void</span>) <a class="code" href="a00200.html#a13335a18ae6783b5c2aa79a73c0947f9">FreppleInitialize</a>() <a name="l00042"></a>00042 { <a name="l00043"></a>00043 <span class="comment">// Initialize only once</span> <a name="l00044"></a>00044 <span class="keyword">static</span> <span class="keywordtype">bool</span> initialized = <span class="keyword">false</span>; <a name="l00045"></a>00045 <span class="keywordflow">if</span> (initialized) <span class="keywordflow">return</span>; <a name="l00046"></a>00046 initialized = <span class="keyword">true</span>; <a name="l00047"></a>00047 <a name="l00048"></a>00048 <span class="comment">// Initialize the libraries</span> <a name="l00049"></a>00049 <a class="code" href="a00258.html#ab6da5933e0f8c7727413e2ec5d45654a">LibraryModel::initialize</a>(); <span class="comment">// also initializes the utils library</span> <a name="l00050"></a>00050 <a class="code" href="a00258.html#ab6da5933e0f8c7727413e2ec5d45654a">LibrarySolver::initialize</a>(); <a name="l00051"></a>00051 <a name="l00052"></a>00052 <span class="comment">// Search for the initialization PY file</span> <a name="l00053"></a>00053 <span class="keywordtype">string</span> init = Environment::searchFile(<span class="stringliteral">"init.py"</span>); <a name="l00054"></a>00054 <span class="keywordflow">if</span> (!init.empty()) <a name="l00055"></a>00055 { <a name="l00056"></a>00056 <span class="comment">// Execute the commands in the file</span> <a name="l00057"></a>00057 <span class="keywordflow">try</span> <a name="l00058"></a>00058 { <a name="l00059"></a>00059 <a class="code" href="a00033.html" title="This command executes Python code in the embedded interpreter.">CommandPython</a> cmd; <a name="l00060"></a>00060 cmd.<a class="code" href="a00033.html#a53c31e4ba70e41711844e645f40dd2dc">setFileName</a>(init); <a name="l00061"></a>00061 cmd.<a class="code" href="a00033.html#a3a7108daca9313128fac9864dd63b332">execute</a>(); <a name="l00062"></a>00062 } <a name="l00063"></a>00063 <span class="keywordflow">catch</span> (...) <a name="l00064"></a>00064 { <a name="l00065"></a>00065 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> << <span class="stringliteral">"Exception caught during execution of 'init.py'"</span> << endl; <a name="l00066"></a>00066 <span class="keywordflow">throw</span>; <a name="l00067"></a>00067 } <a name="l00068"></a>00068 } <a name="l00069"></a>00069 <a name="l00070"></a>00070 <span class="comment">// Search for the initialization XML file</span> <a name="l00071"></a>00071 init = Environment::searchFile(<span class="stringliteral">"init.xml"</span>); <a name="l00072"></a>00072 <span class="keywordflow">if</span> (!init.empty()) <a name="l00073"></a>00073 { <a name="l00074"></a>00074 <span class="comment">// Execute the commands in the file</span> <a name="l00075"></a>00075 <span class="keywordflow">try</span> {<a class="code" href="a00034.html" title="This command is used for reading XML input. The input comes either from a flatfile...">CommandReadXMLFile</a>(init).execute();} <a name="l00076"></a>00076 <span class="keywordflow">catch</span> (...) <a name="l00077"></a>00077 { <a name="l00078"></a>00078 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> << <span class="stringliteral">"Exception caught during execution of 'init.xml'"</span> << endl; <a name="l00079"></a>00079 <span class="keywordflow">throw</span>; <a name="l00080"></a>00080 } <a name="l00081"></a>00081 } <a name="l00082"></a>00082 } <a name="l00083"></a>00083 <a name="l00084"></a>00084 <a name="l00085"></a><a class="code" href="a00207.html#a3fc208638127f40dfaec2fd24984925e">00085</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">void</span>) <a class="code" href="a00200.html#a9e1390a1382e0138ffd22c9056d26242">FreppleReadXMLData</a> (const <span class="keywordtype">char</span>* x, <span class="keywordtype">bool</span> validate, <span class="keywordtype">bool</span> validateonly) <a name="l00086"></a>00086 { <a name="l00087"></a>00087 <span class="keywordflow">if</span> (x) <a class="code" href="a00035.html" title="This command is used for reading XML input from a certain string.">CommandReadXMLString</a>(<span class="keywordtype">string</span>(x), validate, validateonly).execute(); <a name="l00088"></a>00088 } <a name="l00089"></a>00089 <a name="l00090"></a>00090 <a name="l00091"></a><a class="code" href="a00207.html#a6a4fbbd910c5658eedfcb7afdc6afba9">00091</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">void</span>) <a class="code" href="a00200.html#aa13cb0cd869ffbb251070cbfd8710e00">FreppleReadXMLFile</a> (const <span class="keywordtype">char</span>* x, <span class="keywordtype">bool</span> validate, <span class="keywordtype">bool</span> validateonly) <a name="l00092"></a>00092 { <a name="l00093"></a>00093 <a class="code" href="a00034.html" title="This command is used for reading XML input. The input comes either from a flatfile...">CommandReadXMLFile</a>(x, validate, validateonly).execute(); <a name="l00094"></a>00094 } <a name="l00095"></a>00095 <a name="l00096"></a>00096 <a name="l00097"></a><a class="code" href="a00207.html#a3f0d1ee84b42c07bdd98c4305682da2d">00097</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">void</span>) <a class="code" href="a00200.html#a99fada28bea93e9dbb8bbb4ebce40a35">FreppleSaveFile</a>(const <span class="keywordtype">char</span>* x) <a name="l00098"></a>00098 { <a name="l00099"></a>00099 <a class="code" href="a00036.html" title="This command writes the complete model to an XML-file.">CommandSave</a>(x).execute(); <a name="l00100"></a>00100 } <a name="l00101"></a>00101 <a name="l00102"></a>00102 <span class="comment"></span> <a name="l00103"></a>00103 <span class="comment">/** Closing any resources still used by frePPle.<br></span> <a name="l00104"></a>00104 <span class="comment"> * Allocated memory is not freed up with this call - for performance</span> <a name="l00105"></a>00105 <span class="comment"> * reasons it is easier to "leak" the memory. The memory is freed when</span> <a name="l00106"></a>00106 <span class="comment"> * the process exits.</span> <a name="l00107"></a>00107 <span class="comment"> */</span> <a name="l00108"></a><a class="code" href="a00207.html#a343ef9b72a0d751e081c33e680cf53ac">00108</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">void</span>) <a class="code" href="a00200.html#a343ef9b72a0d751e081c33e680cf53ac">FreppleExit</a>() <a name="l00109"></a>00109 { <a name="l00110"></a>00110 <span class="comment">// Close the log file</span> <a name="l00111"></a>00111 Environment::setLogFile(<span class="stringliteral">""</span>); <a name="l00112"></a>00112 } <a name="l00113"></a>00113 <a name="l00114"></a>00114 <a name="l00115"></a><a class="code" href="a00207.html#a646e2a594a659e0388e4e16260ad4c12">00115</a> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">void</span>) <a class="code" href="a00200.html#a3e027e800aff06e2e732bb7c2b38e92c">FreppleLog</a>(const <span class="keywordtype">string</span>& msg) <a name="l00116"></a>00116 { <a name="l00117"></a>00117 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> << msg << endl; <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <a name="l00120"></a>00120 <a name="l00121"></a><a class="code" href="a00207.html#a0e7b2ba82edeeb9e457e0c792c56f36d">00121</a> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">void</span>) <a class="code" href="a00200.html#a3e027e800aff06e2e732bb7c2b38e92c">FreppleLog</a>(const <span class="keywordtype">char</span>* msg) <a name="l00122"></a>00122 { <a name="l00123"></a>00123 <a class="code" href="a00257.html#a4af9f241e955122820c5e81ceb33edb5">logger</a> << msg << endl; <a name="l00124"></a>00124 } <a name="l00125"></a>00125 <a name="l00126"></a>00126 <a name="l00127"></a><a class="code" href="a00207.html#aa09bdb80ef8c0b142611cfa6f480e5e2">00127</a> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">int</span>) <a class="code" href="a00200.html#aa09bdb80ef8c0b142611cfa6f480e5e2">FreppleWrapperInitialize</a>() <a name="l00128"></a>00128 { <a name="l00129"></a>00129 <span class="keywordflow">try</span> {<a class="code" href="a00200.html#a13335a18ae6783b5c2aa79a73c0947f9">FreppleInitialize</a>();} <a name="l00130"></a>00130 <span class="keywordflow">catch</span> (...) {<span class="keywordflow">return</span> EXIT_FAILURE;} <a name="l00131"></a>00131 <span class="keywordflow">return</span> EXIT_SUCCESS; <a name="l00132"></a>00132 } <a name="l00133"></a>00133 <a name="l00134"></a>00134 <a name="l00135"></a><a class="code" href="a00207.html#acd3b85ebffd167d066bca0876156b576">00135</a> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">int</span>) <a class="code" href="a00200.html#aac06c22403aeeb727b35a504aacb62e2">FreppleWrapperReadXMLData</a>(<span class="keywordtype">char</span>* d, <span class="keywordtype">bool</span> v, <span class="keywordtype">bool</span> c) <a name="l00136"></a>00136 { <a name="l00137"></a>00137 <span class="keywordflow">try</span> {<a class="code" href="a00200.html#a9e1390a1382e0138ffd22c9056d26242">FreppleReadXMLData</a>(d, v, c);} <a name="l00138"></a>00138 <span class="keywordflow">catch</span> (...) {<span class="keywordflow">return</span> EXIT_FAILURE;} <a name="l00139"></a>00139 <span class="keywordflow">return</span> EXIT_SUCCESS; <a name="l00140"></a>00140 } <a name="l00141"></a>00141 <a name="l00142"></a>00142 <a name="l00143"></a><a class="code" href="a00207.html#a121d614a823d805d5bf6fce3d321375c">00143</a> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">int</span>) <a class="code" href="a00200.html#a4474c6f0eb3bde669fb851a49ea9b14b">FreppleWrapperReadXMLFile</a>(const <span class="keywordtype">char</span>* f, <span class="keywordtype">bool</span> v, <span class="keywordtype">bool</span> c) <a name="l00144"></a>00144 { <a name="l00145"></a>00145 <span class="keywordflow">try</span> {<a class="code" href="a00200.html#aa13cb0cd869ffbb251070cbfd8710e00">FreppleReadXMLFile</a>(f, v, c);} <a name="l00146"></a>00146 <span class="keywordflow">catch</span> (...) {<span class="keywordflow">return</span> EXIT_FAILURE;} <a name="l00147"></a>00147 <span class="keywordflow">return</span> EXIT_SUCCESS; <a name="l00148"></a>00148 } <a name="l00149"></a>00149 <a name="l00150"></a>00150 <a name="l00151"></a><a class="code" href="a00207.html#ab11e4ac6a671f0b7a34c1a177e45689e">00151</a> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">int</span>) <a class="code" href="a00200.html#ae66d8a62a506de031731142c6b7ebe7a">FreppleWrapperSaveFile</a>(<span class="keywordtype">char</span>* f) <a name="l00152"></a>00152 { <a name="l00153"></a>00153 <span class="keywordflow">try</span> {<a class="code" href="a00200.html#a99fada28bea93e9dbb8bbb4ebce40a35">FreppleSaveFile</a>(f);} <a name="l00154"></a>00154 <span class="keywordflow">catch</span> (...) {<span class="keywordflow">return</span> EXIT_FAILURE;} <a name="l00155"></a>00155 <span class="keywordflow">return</span> EXIT_SUCCESS; <a name="l00156"></a>00156 } <a name="l00157"></a>00157 <a name="l00158"></a>00158 <a name="l00159"></a><a class="code" href="a00207.html#abfef211e8bc738a30a69e5584573182e">00159</a> <span class="keyword">extern</span> <span class="stringliteral">"C"</span> <a class="code" href="a00252.html#a99b94ab8c2f2a32277559c7b2b0a054c">DECLARE_EXPORT</a>(<span class="keywordtype">int</span>) <a class="code" href="a00200.html#abfef211e8bc738a30a69e5584573182e">FreppleWrapperExit</a>() <a name="l00160"></a>00160 { <a name="l00161"></a>00161 <span class="keywordflow">try</span> {<a class="code" href="a00200.html#a343ef9b72a0d751e081c33e680cf53ac">FreppleExit</a>();} <a name="l00162"></a>00162 <span class="keywordflow">catch</span> (...) {<span class="keywordflow">return</span> EXIT_FAILURE;} <a name="l00163"></a>00163 <span class="keywordflow">return</span> EXIT_SUCCESS; <a name="l00164"></a>00164 } <a name="l00165"></a>00165 </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>