Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > 0551a44115f6e0f4237e274e52a253d8 > files > 28

stdair-doc-1.00.1-4.fc18.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
		  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta name="robots" content="index,follow"/>
	<title>Command-Line Test to Demonstrate How To Extend StdAir BOM</title>
	<link rel="shortcut icon" href="favicon.ico">
	<link href="tabs.css" rel="stylesheet" type="text/css"/>
	<link href="stdair.css" rel="stylesheet" type="text/css"/>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
	<script type="text/javascript">
	  var _gaq = _gaq || [];
	  _gaq.push(['_setAccount', 'UA-24867310-1']);
	  _gaq.push(['_setDomainName', 'none']);
	  _gaq.push(['_setAllowLinker', true]);
	  _gaq.push(['_trackPageview']);
	  (function() {
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	  })();
	</script>
	<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
  </head>
  <body>
	<div id="top"><!-- do not remove this div! -->
	  <div id="titlearea">
		<table width="100%">
		  <tbody>
			<tr style="height: 56px;">
			  <td style="padding-left: 0.5em;">
				<div id="projectname"><a href="http://stdair.sourceforge.net"><img height="45px" alt="StdAir Logo" src="stdair_logo.png"></a>
				  &#160;<span id="projectnumber">1.00.1</span>
				</div>
				<div id="projectbrief">C++ Standard Airline IT Object Library</div>
			  </td>
			  <!-- begin SOURCEFORGE_CUSTOM-->
			  <td>
				<div id="sflogo"><a href="http://stdair.sourceforge.net"><img height="45px" alt="SourceForge Logo" src="sfx_logo.png"></a></div>
			  </td>
			  <!-- end SOURCEFORGE_CUSTOM-->
			</tr>
		  </tbody>
		</table>
	  </div>
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;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><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('a00025.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(11)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Command-Line Test to Demonstrate How To Extend StdAir BOM </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><div class="fragment"><div class="line"> */</div>
<div class="line"><span class="comment">// //////////////////////////////////////////////////////////////////////</span></div>
<div class="line"><span class="comment">// Import section</span></div>
<div class="line"><span class="comment">// //////////////////////////////////////////////////////////////////////</span></div>
<div class="line"><span class="comment">// STL</span></div>
<div class="line"><span class="preprocessor">#include &lt;sstream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;fstream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="comment">// Boost MPL</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/mpl/push_back.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/mpl/vector.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/mpl/at.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/mpl/assert.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/type_traits/is_same.hpp&gt;</span></div>
<div class="line"><span class="comment">// Boost Unit Test Framework (UTF)</span></div>
<div class="line"><span class="preprocessor">#define BOOST_TEST_DYN_LINK</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define BOOST_TEST_MAIN</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#define BOOST_TEST_MODULE StdAirTest</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#if BOOST_VERSION &gt;= 103900</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include &lt;boost/test/unit_test.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#else  // BOOST_VERSION &gt;= 103900</span></div>
<div class="line"><span class="preprocessor"></span><span class="preprocessor">#include &lt;boost/test/test_tools.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/test/results_reporter.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/test/unit_test_suite.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/test/output_test_stream.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/test/unit_test_log.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/test/framework.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/test/detail/unit_test_parameters.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#endif // BOOST_VERSION &gt;= 103900</span></div>
<div class="line"><span class="preprocessor"></span><span class="comment">// Boost Serialisation</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/archive/text_oarchive.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;boost/archive/text_iarchive.hpp&gt;</span></div>
<div class="line"><span class="comment">// StdAir</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00513.html">stdair/stdair_inventory_types.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00499.html">stdair/service/Logger.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00518.html">stdair/STDAIR_Service.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00241.html">stdair/basic/float_utils.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00293.html">stdair/bom/BomDisplay.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00311.html">stdair/bom/BomRoot.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00307.html">stdair/bom/BomManager.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00486.html">stdair/factory/FacBom.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00488.html">stdair/factory/FacBomManager.hpp</a>&gt;</span></div>
<div class="line"><span class="comment">// StdAir Test Suite</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00528.html">test/stdair/StdairTestLib.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="a00526.html">test/stdair/MPInventory.hpp</a>&gt;</span></div>
<div class="line"></div>
<div class="line"><span class="keyword">namespace </span>boost_utf = boost::unit_test;</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#if BOOST_VERSION &gt;= 103900</span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line"><span class="comment">// (Boost) Unit Test XML Report</span></div>
<div class="line">std::ofstream utfReportStream (<span class="stringliteral">&quot;StandardAirlineITTestSuite_utfresults.xml&quot;</span>);</div>
<div class="line"></div>
<div class="line"><span class="keyword">struct </span>UnitTestConfig {</div>
<div class="line">  UnitTestConfig() {</div>
<div class="line">    boost_utf::unit_test_log.set_stream (utfReportStream);</div>
<div class="line">    boost_utf::unit_test_log.set_format (boost_utf::XML);</div>
<div class="line">    boost_utf::unit_test_log.set_threshold_level (boost_utf::log_test_units);</div>
<div class="line">    <span class="comment">// boost_utf::unit_test_log.set_threshold_level (boost_utf::log_successful_tests);</span></div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  ~UnitTestConfig() {</div>
<div class="line">  }</div>
<div class="line">};</div>
<div class="line"></div>
<div class="line"></div>
<div class="line"><span class="comment">// /////////////// Main: Unit Test Suite //////////////</span></div>
<div class="line"></div>
<div class="line"><span class="comment">// Set the UTF configuration (re-direct the output to a specific file)</span></div>
<div class="line">BOOST_GLOBAL_FIXTURE (UnitTestConfig);</div>
<div class="line"></div>
<div class="line"><span class="comment">// Start the test suite</span></div>
<div class="line">BOOST_AUTO_TEST_SUITE (master_test_suite)</div>
<div class="line"></div>
<div class="line"></div>
<div class="line">BOOST_AUTO_TEST_CASE (float_comparison_test) {</div>
<div class="line">  <span class="keywordtype">float</span> a = 0.2f;</div>
<div class="line">  a = 5*a;</div>
<div class="line">  <span class="keyword">const</span> <span class="keywordtype">float</span> b = 1.0f;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Test the Boost way</span></div>
<div class="line">  BOOST_CHECK_MESSAGE (a == b, <span class="stringliteral">&quot;The two floats (&quot;</span> &lt;&lt; a &lt;&lt; <span class="stringliteral">&quot; and &quot;</span> &lt;&lt; b</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;) should be equal, but are not&quot;</span>);</div>
<div class="line">  BOOST_CHECK_CLOSE (a, b, 0.0001);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Test the Google way</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00107.html">FloatingPoint&lt;float&gt;</a> lhs (a), rhs (b);</div>
<div class="line">  BOOST_CHECK_MESSAGE (lhs.AlmostEquals (rhs),</div>
<div class="line">                       <span class="stringliteral">&quot;The two floats (&quot;</span> &lt;&lt; a &lt;&lt; <span class="stringliteral">&quot; and &quot;</span> &lt;&lt; b</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;) should be equal, but are not&quot;</span>);</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">BOOST_AUTO_TEST_CASE (mpl_structure_test) {</div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00535.html#a2333a1276804180fe52c77f099005054">stdair::ClassCode_T</a> lBookingClassCodeA (<span class="stringliteral">&quot;A&quot;</span>);</div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00051.html">stdair_test::BookingClass</a> lA (lBookingClassCodeA);</div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00059.html">stdair_test::Cabin</a> lCabin (lA);</div>
<div class="line"></div>
<div class="line">  BOOST_CHECK_EQUAL (lCabin.toString(), lBookingClassCodeA);</div>
<div class="line">  BOOST_CHECK_MESSAGE (lCabin.toString() == lBookingClassCodeA,</div>
<div class="line">                       <span class="stringliteral">&quot;The cabin key, &#39;&quot;</span> &lt;&lt; lCabin.toString()</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39; is not equal to &#39;&quot;</span> &lt;&lt; lBookingClassCodeA &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// MPL</span></div>
<div class="line">  <span class="keyword">typedef</span> boost::mpl::vector&lt;stdair_test::BookingClass&gt; MPL_BookingClass;</div>
<div class="line">  <span class="keyword">typedef</span> boost::mpl::push_back&lt;MPL_BookingClass,</div>
<div class="line">                                <a class="code" href="a00059.html">stdair_test::Cabin</a>&gt;::type types;</div>
<div class="line">  </div>
<div class="line">  <span class="keywordflow">if</span> (boost::is_same&lt;<a class="code" href="a00051.html">stdair_test::BookingClass</a>,</div>
<div class="line">                     <a class="code" href="a00051.html">stdair_test::Cabin::child</a>&gt;::value == <span class="keyword">false</span>) {</div>
<div class="line">    BOOST_ERROR (<span class="stringliteral">&quot;The two types mut be equal, but are not&quot;</span>);</div>
<div class="line">  }</div>
<div class="line">  </div>
<div class="line">  <span class="keywordflow">if</span> (boost::is_same&lt;boost::mpl::at_c&lt;types, 1&gt;::type,</div>
<div class="line">                     <a class="code" href="a00059.html">stdair_test::Cabin</a>&gt;::value == <span class="keyword">false</span>) {</div>
<div class="line">    BOOST_ERROR (<span class="stringliteral">&quot;The type must be stdair_test::Cabin, but is not&quot;</span>);</div>
<div class="line">  }</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">BOOST_AUTO_TEST_CASE (stdair_service_initialisation_test) {</div>
<div class="line">  <span class="comment">// Output log File</span></div>
<div class="line">  <span class="keyword">const</span> std::string lLogFilename (<span class="stringliteral">&quot;StandardAirlineITTestSuite_init.log&quot;</span>);</div>
<div class="line">    </div>
<div class="line">  <span class="comment">// Set the log parameters</span></div>
<div class="line">  std::ofstream logOutputFile;</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Open and clean the log outputfile</span></div>
<div class="line">  logOutputFile.open (lLogFilename.c_str());</div>
<div class="line">  logOutputFile.clear();</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Initialise the stdair BOM</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00036.html" title="Structure holding parameters for logging.">stdair::BasLogParams</a> lLogParams (<a class="code" href="a00536.html#a0e942800c20ab8c1dc913408f555112daf8480a95ba3662dd03cd956546bf951b">stdair::LOG::DEBUG</a>, logOutputFile);</div>
<div class="line">  <a class="code" href="a00179.html" title="Interface for the STDAIR Services.">stdair::STDAIR_Service</a> stdairService (lLogParams);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve (a reference on) the top of the persistent BOM tree</span></div>
<div class="line">  <a class="code" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a>&amp; lPersistentBomRoot = stdairService.getPersistentBomRoot();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve the BomRoot key, and compare it to the expected one</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lBomRootKeyStr = lPersistentBomRoot.<a class="code" href="a00049.html#a2e5ffe8887b014acb18c858e44c6d21c">describeKey</a>();</div>
<div class="line">  <span class="keyword">const</span> std::string lBomRootString (<span class="stringliteral">&quot; -- ROOT -- &quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG</span></div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;The BOM root key is &#39;&quot;</span> &lt;&lt; lBomRootKeyStr</div>
<div class="line">                    &lt;&lt; <span class="stringliteral">&quot;&#39;. It should be equal to &#39;&quot;</span> &lt;&lt; lBomRootString &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span>);</div>
<div class="line">  </div>
<div class="line">  BOOST_CHECK_EQUAL (lBomRootKeyStr, lBomRootString);</div>
<div class="line">  BOOST_CHECK_MESSAGE (lBomRootKeyStr == lBomRootString,</div>
<div class="line">                       <span class="stringliteral">&quot;The BOM root key, &#39;&quot;</span> &lt;&lt; lBomRootKeyStr</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, should be equal to &#39;&quot;</span> &lt;&lt; lBomRootString</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, but is not.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Build a sample BOM tree</span></div>
<div class="line">  stdairService.buildSampleBom();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG: Display the whole BOM tree</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lCSVDump = stdairService.csvDisplay ();</div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (lCSVDump);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Close the Log outputFile</span></div>
<div class="line">  logOutputFile.close();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">BOOST_AUTO_TEST_CASE (bom_structure_instantiation_test) {</div>
<div class="line">  <span class="comment">// Step 0.0: initialisation</span></div>
<div class="line">  <span class="comment">// Create the root of a Bom tree (i.e., a BomRoot object)</span></div>
<div class="line">  <a class="code" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a>&amp; lBomRoot =</div>
<div class="line">    <a class="code" href="a00089.html#af10a87fcdeb32af553c6994ba724016a">stdair::FacBom&lt;stdair::BomRoot&gt;::instance</a>().<a class="code" href="a00089.html#af06dd266824e0ec2ea9a15994f56fd75">create</a>();</div>
<div class="line">        </div>
<div class="line">  <span class="comment">// Step 0.1: Inventory level</span></div>
<div class="line">  <span class="comment">// Create an Inventory (BA)</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00535.html#ac0ab9f765621de3140cc27d6472f5581">stdair::AirlineCode_T</a> lBAAirlineCode (<span class="stringliteral">&quot;BA&quot;</span>);</div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00113.html" title="Key of a given inventory, made of the airline code.">stdair::InventoryKey</a> lBAKey (lBAAirlineCode);</div>
<div class="line">  myprovider::Inventory&amp; lBAInv =</div>
<div class="line">    <a class="code" href="a00089.html#af10a87fcdeb32af553c6994ba724016a">stdair::FacBom&lt;myprovider::Inventory&gt;::instance</a>().<a class="code" href="a00089.html#af06dd266824e0ec2ea9a15994f56fd75">create</a> (lBAKey);</div>
<div class="line">  <a class="code" href="a00090.html#a732e7152a1bcb27b2b7e88e38f9fa535">stdair::FacBomManager::addToList</a> (lBomRoot, lBAInv);</div>
<div class="line"></div>
<div class="line">  BOOST_CHECK_EQUAL (lBAInv.describeKey(), lBAAirlineCode);</div>
<div class="line">  BOOST_CHECK_MESSAGE (lBAInv.describeKey() == lBAAirlineCode,</div>
<div class="line">                       <span class="stringliteral">&quot;The inventory key, &#39;&quot;</span> &lt;&lt; lBAInv.describeKey()</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, should be equal to &#39;&quot;</span> &lt;&lt; lBAAirlineCode</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, but is not&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Create an Inventory for AF</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00535.html#ac0ab9f765621de3140cc27d6472f5581">stdair::AirlineCode_T</a> lAFAirlineCode (<span class="stringliteral">&quot;AF&quot;</span>);</div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00113.html" title="Key of a given inventory, made of the airline code.">stdair::InventoryKey</a> lAFKey (lAFAirlineCode);</div>
<div class="line">  myprovider::Inventory&amp; lAFInv =</div>
<div class="line">    <a class="code" href="a00089.html#af10a87fcdeb32af553c6994ba724016a">stdair::FacBom&lt;myprovider::Inventory&gt;::instance</a>().<a class="code" href="a00089.html#af06dd266824e0ec2ea9a15994f56fd75">create</a> (lAFKey);</div>
<div class="line">  <a class="code" href="a00090.html#a732e7152a1bcb27b2b7e88e38f9fa535">stdair::FacBomManager::addToList</a> (lBomRoot, lAFInv);</div>
<div class="line"></div>
<div class="line">  BOOST_CHECK_EQUAL (lAFInv.describeKey(), lAFAirlineCode);</div>
<div class="line">  BOOST_CHECK_MESSAGE (lAFInv.describeKey() == lAFAirlineCode,</div>
<div class="line">                       <span class="stringliteral">&quot;The inventory key, &#39;&quot;</span> &lt;&lt; lAFInv.describeKey()</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, should be equal to &#39;&quot;</span> &lt;&lt; lAFAirlineCode</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, but is not&quot;</span>);</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Browse the inventories</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00535.html#aa2443c204cfcb7ce31e90308b9a63d71">myprovider::InventoryList_T</a>&amp; lInventoryList =</div>
<div class="line">      stdair::BomManager::getList&lt;myprovider::Inventory&gt; (lBomRoot);</div>
<div class="line">  <span class="keyword">const</span> std::string lInventoryKeyArray[2] = {lBAAirlineCode, lAFAirlineCode};</div>
<div class="line">  <span class="keywordtype">short</span> idx = 0;</div>
<div class="line">  <span class="keywordflow">for</span> (myprovider::InventoryList_T::const_iterator itInv =</div>
<div class="line">         lInventoryList.begin(); itInv != lInventoryList.end();</div>
<div class="line">       ++itInv, ++idx) {</div>
<div class="line">    <span class="keyword">const</span> myprovider::Inventory* lInv_ptr = *itInv;</div>
<div class="line">    BOOST_REQUIRE (lInv_ptr != NULL);</div>
<div class="line">    </div>
<div class="line">    BOOST_CHECK_EQUAL (lInventoryKeyArray[idx], lInv_ptr-&gt;describeKey());</div>
<div class="line">    BOOST_CHECK_MESSAGE (lInventoryKeyArray[idx] == lInv_ptr-&gt;describeKey(),</div>
<div class="line">                         <span class="stringliteral">&quot;They inventory key, &#39;&quot;</span> &lt;&lt; lInventoryKeyArray[idx]</div>
<div class="line">                         &lt;&lt; <span class="stringliteral">&quot;&#39;, does not match that of the Inventory object: &#39;&quot;</span></div>
<div class="line">                         &lt;&lt; lInv_ptr-&gt;describeKey() &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span>);</div>
<div class="line">  }</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">BOOST_AUTO_TEST_CASE (bom_structure_serialisation_test) {</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Backup (thanks to Boost.Serialisation) file</span></div>
<div class="line">  <span class="keyword">const</span> std::string lBackupFilename = <span class="stringliteral">&quot;StandardAirlineITTestSuite_serial.txt&quot;</span>;</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Output log File</span></div>
<div class="line">  <span class="keyword">const</span> std::string lLogFilename (<span class="stringliteral">&quot;StandardAirlineITTestSuite_serial.log&quot;</span>);</div>
<div class="line">    </div>
<div class="line">  <span class="comment">// Set the log parameters</span></div>
<div class="line">  std::ofstream logOutputFile;</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Open and clean the log outputfile</span></div>
<div class="line">  logOutputFile.open (lLogFilename.c_str());</div>
<div class="line">  logOutputFile.clear();</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Initialise the stdair BOM</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00036.html" title="Structure holding parameters for logging.">stdair::BasLogParams</a> lLogParams (<a class="code" href="a00536.html#a0e942800c20ab8c1dc913408f555112daf8480a95ba3662dd03cd956546bf951b">stdair::LOG::DEBUG</a>, logOutputFile);</div>
<div class="line">  <a class="code" href="a00179.html" title="Interface for the STDAIR Services.">stdair::STDAIR_Service</a> stdairService (lLogParams);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Build a sample BOM tree</span></div>
<div class="line">  stdairService.buildSampleBom();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve (a reference on) the top of the persistent BOM tree</span></div>
<div class="line">  <a class="code" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a>&amp; lPersistentBomRoot = stdairService.getPersistentBomRoot();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG: Display the whole BOM tree</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lCSVDump = stdairService.csvDisplay ();</div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (lCSVDump);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Clone the persistent BOM</span></div>
<div class="line">  stdairService.clonePersistentBom ();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve the BomRoot key, and compare it to the expected one</span></div>
<div class="line">  <span class="keyword">const</span> std::string lBAInvKeyStr (<span class="stringliteral">&quot;BA&quot;</span>);</div>
<div class="line">  <a class="code" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a>* lBAInv_ptr = </div>
<div class="line">    lPersistentBomRoot.<a class="code" href="a00049.html#a73c84237e4a7308bd009bc436d498a18">getInventory</a> (lBAInvKeyStr);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG</span></div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;There should be an Inventory object corresponding to the &#39;&quot;</span></div>
<div class="line">                    &lt;&lt; lBAInvKeyStr &lt;&lt; <span class="stringliteral">&quot;&#39; key.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  BOOST_REQUIRE_MESSAGE (lBAInv_ptr != NULL,</div>
<div class="line">                         <span class="stringliteral">&quot;An Inventory object should exist with the key, &#39;&quot;</span></div>
<div class="line">                         &lt;&lt; lBAInvKeyStr &lt;&lt; <span class="stringliteral">&quot;&#39;.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// create and open a character archive for output</span></div>
<div class="line">  std::ofstream ofs (lBackupFilename.c_str());</div>
<div class="line"></div>
<div class="line">  <span class="comment">// save data to archive</span></div>
<div class="line">  {</div>
<div class="line">    boost::archive::text_oarchive oa (ofs);</div>
<div class="line">    <span class="comment">// write class instance to archive</span></div>
<div class="line">    oa &lt;&lt; lPersistentBomRoot;</div>
<div class="line">    <span class="comment">// archive and stream closed when destructors are called</span></div>
<div class="line">  }</div>
<div class="line"></div>
<div class="line">  <span class="comment">// ... some time later restore the class instance to its orginal state</span></div>
<div class="line">  <a class="code" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a>&amp; lRestoredBomRoot =</div>
<div class="line">    <a class="code" href="a00089.html#af10a87fcdeb32af553c6994ba724016a">stdair::FacBom&lt;stdair::BomRoot&gt;::instance</a>().<a class="code" href="a00089.html#af06dd266824e0ec2ea9a15994f56fd75">create</a>();</div>
<div class="line">  {</div>
<div class="line">    <span class="comment">// create and open an archive for input</span></div>
<div class="line">    std::ifstream ifs (lBackupFilename.c_str());</div>
<div class="line">    boost::archive::text_iarchive ia(ifs);</div>
<div class="line">    <span class="comment">// read class state from archive</span></div>
<div class="line">    ia &gt;&gt; lRestoredBomRoot;</div>
<div class="line">    <span class="comment">// archive and stream closed when destructors are called</span></div>
<div class="line">  }</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// DEBUG: Display the whole restored BOM tree</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lRestoredCSVDump = </div>
<div class="line">    stdairService.csvDisplay(lRestoredBomRoot);</div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (lRestoredCSVDump);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve the BomRoot key, and compare it to the expected one</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lBomRootKeyStr = lRestoredBomRoot.<a class="code" href="a00049.html#a2e5ffe8887b014acb18c858e44c6d21c">describeKey</a>();</div>
<div class="line">  <span class="keyword">const</span> std::string lBomRootString (<span class="stringliteral">&quot; -- ROOT -- &quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG</span></div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;The BOM root key is &#39;&quot;</span> &lt;&lt; lBomRootKeyStr</div>
<div class="line">                    &lt;&lt; <span class="stringliteral">&quot;&#39;. It should be equal to &#39;&quot;</span> &lt;&lt; lBomRootString &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span>);</div>
<div class="line">  </div>
<div class="line">  BOOST_CHECK_EQUAL (lBomRootKeyStr, lBomRootString);</div>
<div class="line">  BOOST_CHECK_MESSAGE (lBomRootKeyStr == lBomRootString,</div>
<div class="line">                       <span class="stringliteral">&quot;The BOM root key, &#39;&quot;</span> &lt;&lt; lBomRootKeyStr</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, should be equal to &#39;&quot;</span> &lt;&lt; lBomRootString</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, but is not.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve the Inventory</span></div>
<div class="line">  <a class="code" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a>* lRestoredBAInv_ptr =</div>
<div class="line">    lRestoredBomRoot.<a class="code" href="a00049.html#a73c84237e4a7308bd009bc436d498a18">getInventory</a> (lBAInvKeyStr);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG</span></div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;There should be an Inventory object corresponding to the &#39;&quot;</span></div>
<div class="line">                    &lt;&lt; lBAInvKeyStr &lt;&lt; <span class="stringliteral">&quot;&#39; key in the restored BOM root.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  BOOST_CHECK_MESSAGE (lRestoredBAInv_ptr != NULL,</div>
<div class="line">                       <span class="stringliteral">&quot;An Inventory object should exist with the key, &#39;&quot;</span></div>
<div class="line">                       &lt;&lt; lBAInvKeyStr &lt;&lt; <span class="stringliteral">&quot;&#39; in the restored BOM root.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Close the Log outputFile</span></div>
<div class="line">  logOutputFile.close();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line">BOOST_AUTO_TEST_CASE (bom_structure_clone_test) {  </div>
<div class="line"></div>
<div class="line">  <span class="comment">// Output log File</span></div>
<div class="line">  <span class="keyword">const</span> std::string lLogFilename (<span class="stringliteral">&quot;StandardAirlineITTestSuite_clone.log&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Set the log parameters</span></div>
<div class="line">  std::ofstream logOutputFile;</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Open and clean the log outputfile</span></div>
<div class="line">  logOutputFile.open (lLogFilename.c_str());</div>
<div class="line">  logOutputFile.clear();</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Initialise the stdair BOM</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00036.html" title="Structure holding parameters for logging.">stdair::BasLogParams</a> lLogParams (<a class="code" href="a00536.html#a0e942800c20ab8c1dc913408f555112daf8480a95ba3662dd03cd956546bf951b">stdair::LOG::DEBUG</a>, logOutputFile);</div>
<div class="line">  <a class="code" href="a00179.html" title="Interface for the STDAIR Services.">stdair::STDAIR_Service</a> stdairService (lLogParams);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Build a sample BOM tree</span></div>
<div class="line">  stdairService.buildSampleBom();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve (a constant reference on) the top of the persistent BOM tree</span></div>
<div class="line">  <span class="keyword">const</span> <a class="code" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a>&amp; lPersistentBomRoot =</div>
<div class="line">    stdairService.getPersistentBomRoot();  </div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG: Display the whole persistent BOM tree</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lCSVDump = stdairService.csvDisplay (); </div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;Display the persistent BOM tree.&quot;</span>);</div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (lCSVDump); </div>
<div class="line"></div>
<div class="line">  <span class="comment">// Clone the persistent BOM</span></div>
<div class="line">  stdairService.clonePersistentBom (); </div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve (a reference on) the top of the clone BOM tree</span></div>
<div class="line">  <a class="code" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a>&amp; lCloneBomRoot = stdairService.getBomRoot();   </div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG: Display the clone BOM tree after the clone process.</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lAfterCloneCSVDump = </div>
<div class="line">    stdairService.csvDisplay(lCloneBomRoot); </div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;Display the clone BOM tree after the clone process.&quot;</span>);</div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (lAfterCloneCSVDump);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve the clone BomRoot key, and compare it to the persistent BomRoot </span></div>
<div class="line">  <span class="comment">// key.</span></div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lCloneBomRootKeyStr = lCloneBomRoot.<a class="code" href="a00049.html#a2e5ffe8887b014acb18c858e44c6d21c">describeKey</a>();</div>
<div class="line">  <span class="keyword">const</span> std::string&amp; lPersistentBomRootKeyStr = </div>
<div class="line">    lPersistentBomRoot.<a class="code" href="a00049.html#a2e5ffe8887b014acb18c858e44c6d21c">describeKey</a>();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG</span></div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;The clone BOM root key is &#39;&quot;</span> &lt;&lt; lCloneBomRootKeyStr</div>
<div class="line">                    &lt;&lt; <span class="stringliteral">&quot;&#39;. It should be equal to &#39;&quot;</span> </div>
<div class="line">                    &lt;&lt; lPersistentBomRootKeyStr &lt;&lt; <span class="stringliteral">&quot;&#39;&quot;</span>);</div>
<div class="line">  </div>
<div class="line">  BOOST_CHECK_EQUAL (lCloneBomRootKeyStr, lPersistentBomRootKeyStr);</div>
<div class="line">  BOOST_CHECK_MESSAGE (lCloneBomRootKeyStr == lPersistentBomRootKeyStr,</div>
<div class="line">                       <span class="stringliteral">&quot;The clone BOM root key, &#39;&quot;</span> &lt;&lt; lCloneBomRootKeyStr</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, should be equal to &#39;&quot;</span> &lt;&lt; lPersistentBomRootKeyStr</div>
<div class="line">                       &lt;&lt; <span class="stringliteral">&quot;&#39;, but is not.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Retrieve the BA inventory in the clone BOM root</span></div>
<div class="line">  <span class="keyword">const</span> std::string lBAInvKeyStr (<span class="stringliteral">&quot;BA&quot;</span>);</div>
<div class="line">  <a class="code" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a>* lCloneBAInv_ptr =</div>
<div class="line">    lCloneBomRoot.<a class="code" href="a00049.html#a73c84237e4a7308bd009bc436d498a18">getInventory</a> (lBAInvKeyStr); </div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG</span></div>
<div class="line">  <a class="code" href="a00499.html#a24f87ac1961418818b267ed4d02ff487">STDAIR_LOG_DEBUG</a> (<span class="stringliteral">&quot;There should be an Inventory object corresponding to the &#39;&quot;</span></div>
<div class="line">                    &lt;&lt; lBAInvKeyStr &lt;&lt; <span class="stringliteral">&quot;&#39; key in the clone BOM root.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  BOOST_CHECK_MESSAGE (lCloneBAInv_ptr != NULL,</div>
<div class="line">                       <span class="stringliteral">&quot;An Inventory object should exist with the key, &#39;&quot;</span></div>
<div class="line">                       &lt;&lt; lBAInvKeyStr &lt;&lt; <span class="stringliteral">&quot;&#39; in the clone BOM root.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Close the Log outputFile</span></div>
<div class="line">  logOutputFile.close();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="comment">// End the test suite</span></div>
<div class="line">BOOST_AUTO_TEST_SUITE_END()</div>
<div class="line"></div>
<div class="line"><span class="preprocessor">#else // BOOST_VERSION &gt;= 103900</span></div>
<div class="line"><span class="preprocessor"></span>boost_utf::test_suite* init_unit_test_suite (<span class="keywordtype">int</span>, <span class="keywordtype">char</span>* []) {</div>
<div class="line">  boost_utf::test_suite* test = BOOST_TEST_SUITE (<span class="stringliteral">&quot;Unit test example 1&quot;</span>);</div>
<div class="line">  <span class="keywordflow">return</span> test;</div>
<div class="line">}</div>
<div class="line"><span class="preprocessor">#endif // BOOST_VERSION &gt;= 103900</span></div>
<div class="line"><span class="preprocessor"></span></div>
<div class="line"><span class="comment">/*!</span></div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- doc-content -->
		
		<li class="footer">Generated on Wed May 22 2013 10:52:00 for StdAir by
		  <a href="http://www.doxygen.org/index.html">
			<img class="footer" src="doxygen.png" alt="doxygen"/></a> 
		  1.8.3.1
		</li>
		<li class="footer">
		  <a href="http://sourceforge.net/projects/stdair"><img class="footer" src="http://sflogo.sourceforge.net/sflogo.php?group_id=267760&type=12&format=.png" alt="SourceForge Logo"></a>
		</li>
	  </ul>
	</div>
  </body>
</html>