<!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>Tutorials</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>  <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 Page</span></a></li> <li class="current"><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><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('a00019.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"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(11)"><span class="SelectionMark"> </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">Tutorials </div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><h1><a class="anchor" id="tut_toc"></a> Table of Contents</h1> <ul> <li><a class="el" href="a00019.html#tut_introduction">Introduction</a><ul> <li><a class="el" href="a00019.html#tut_intro_configuration">Preparing the StdAir Project for Development</a></li> </ul> </li> <li><a class="el" href="a00019.html#tut_build_bom_tree">Build a Predefined BOM Tree</a><ul> <li><a class="el" href="a00019.html#tut_build_bom_root">Instanciate the BOM Root Object</a></li> <li><a class="el" href="a00019.html#tut_build_inventory">Instanciate the (Airline) Inventory Object</a></li> <li><a class="el" href="a00019.html#tut_build_link">Link the Inventory Object with the BOM Root</a></li> <li><a class="el" href="a00019.html#tut_build_inventory_another">Build Another Airline Inventory</a></li> <li><a class="el" href="a00019.html#tut_dump_bom_tree">Dump The BOM Tree Content</a></li> <li><a class="el" href="a00019.html#tut_result_output">Result of the Tutorial Program</a></li> </ul> </li> <li><a class="el" href="a00019.html#tut_extend_bom_tree">Extend the Pre-Defined BOM Tree</a><ul> <li><a class="el" href="a00019.html#tut_extend_inventory">Extend an Airline Inventory Object</a></li> <li><a class="el" href="a00019.html#tut_extend_build">Build the Specific BOM Objects</a></li> <li><a class="el" href="a00019.html#tut_extend_result_output">Result of the Tutorial Program</a></li> </ul> </li> </ul> <h1><a class="anchor" id="tut_introduction"></a> Introduction</h1> <p>This page contains some tutorial examples that will help you getting started using StdAir. Most examples show how to construct some simple business objects, i.e., instances of the so-named Business Object Model (BOM).</p> <h2><a class="anchor" id="tut_intro_configuration"></a> Preparing the StdAir Project for Development</h2> <p>The source code for these examples can be found in the <code>batches</code> and <code>test/stdair</code> directories. They are compiled along with the rest of the <code>StdAir</code> project. See the User Guide (<a class="el" href="a00016.html">Users Guide</a>) for more details on how to build the <code>StdAir</code> project.</p> <h1><a class="anchor" id="tut_build_bom_tree"></a> Build a Predefined BOM Tree</h1> <p>A few steps:</p> <ul> <li><a class="el" href="a00019.html#tut_build_bom_root">Instanciate the BOM Root Object</a></li> <li><a class="el" href="a00019.html#tut_build_inventory">Instanciate the (Airline) Inventory Object</a></li> <li><a class="el" href="a00019.html#tut_build_link">Link the Inventory Object with the BOM Root</a></li> </ul> <h2><a class="anchor" id="tut_build_bom_root"></a> Instanciate the BOM Root Object</h2> <p>First, a BOM root object (i.e., a root for all the classes in the project) is instantiated by the <code><a class="el" href="a00180.html" title="Class holding the context of the Stdair services.">stdair::STDAIR_ServiceContext</a></code> context object, when the <code><a class="el" href="a00179.html" title="Interface for the STDAIR Services.">stdair::STDAIR_Service</a></code> is itself instantiated. The corresponding <code>StdAir</code> type (class) is <code><a class="el" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a></code>.</p> <p>In the following sample, that object is named <code>ioBomRoot</code>, and is given as input/output parameter of the <code>stdair::CmdBomManager::buildSampleBom()</code> method:</p> <p><div class="fragment"><div class="line"> <span class="keywordtype">void</span> CmdBomManager::buildSampleBom (BomRoot& ioBomRoot) {</div> </div><!-- fragment --></p> <h2><a class="anchor" id="tut_build_inventory"></a> Instanciate the (Airline) Inventory Object</h2> <p>An airline inventory object can then be instantiated. Let us give it the "BA" airline code (corresponding to <a href="http://www.ba.com">British Airways</a>) as the object key. That is, an object (let us name it <code>lBAKey</code>) of type (class) <code><a class="el" href="a00113.html" title="Key of a given inventory, made of the airline code.">stdair::InventoryKey</a></code> has first to be instantiated.</p> <p><div class="fragment"><div class="line"> <span class="keyword">const</span> InventoryKey lBAKey (lAirlineCodeBA);</div> </div><!-- fragment --></p> <p>Thanks to that key, an airline inventory object, i.e. of type (class) <code><a class="el" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a></code>, can be instantiated. Let us name that airline inventory object <code>lBAInv</code>.</p> <p><div class="fragment"><div class="line"> Inventory& lBAInv = FacBom<Inventory>::instance().create (lBAKey);</div> </div><!-- fragment --></p> <h2><a class="anchor" id="tut_build_link"></a> Link the Inventory Object with the BOM Root</h2> <p>Then, both objects have to be linked: the airline inventory object (<code><a class="el" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a></code>) has to be linked with the root of the BOM tree (<code><a class="el" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a></code>). That operation is as simple as using the <code><a class="el" href="a00090.html#a02632e67fb9c9f0a74bbb1fbc65f6d77">stdair::FacBomManager::addToListAndMap()</a></code> method:</p> <p><div class="fragment"><div class="line"> FacBomManager::addToListAndMap (ioBomRoot, lBAInv);</div> <div class="line"> FacBomManager::linkWithParent (ioBomRoot, lBAInv);</div> </div><!-- fragment --></p> <h2><a class="anchor" id="tut_build_inventory_another"></a> Build Another Airline Inventory</h2> <p>Another airline inventory object, corresponding to the Air France (<a href="http://www.airfrance.com">Air France</a>) company, is instantiated the same way:</p> <p><div class="fragment"><div class="line"> <span class="keyword">const</span> InventoryKey lAFKey (lAirlineCodeAF);</div> <div class="line"> Inventory& lAFInv = FacBom<Inventory>::instance().create (lAFKey);</div> <div class="line"> FacBomManager::addToListAndMap (ioBomRoot, lAFInv);</div> <div class="line"> FacBomManager::linkWithParent (ioBomRoot, lAFInv);</div> </div><!-- fragment --></p> <p>See the corresponding full program (<a class="el" href="a00004.html">C++ Class Building Sample StdAir BOM Trees</a>) for more details.</p> <h2><a class="anchor" id="tut_dump_bom_tree"></a> Dump The BOM Tree Content</h2> <p>From the <code>BomRoot</code> (of type <code><a class="el" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a></code>) object instance, the list of airline inventories (of type <code><a class="el" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a></code>) can then be retrieved...</p> <p><div class="fragment"><div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#aa2443c204cfcb7ce31e90308b9a63d71">InventoryList_T</a>& lInventoryList =</div> <div class="line"> BomManager::getList<Inventory> (iBomRoot);</div> </div><!-- fragment --></p> <p>... and browsed: <div class="fragment"><div class="line"> <span class="keywordflow">for</span> (InventoryList_T::const_iterator itInv = lInventoryList.begin();</div> <div class="line"> itInv != lInventoryList.end(); ++itInv, ++invIdx) {</div> <div class="line"> <span class="keyword">const</span> Inventory* lInv_ptr = *itInv;</div> <div class="line"> assert (lInv_ptr != NULL);</div> <div class="line"></div> <div class="line"> <span class="comment">// Retrieve the inventory key (airline code)</span></div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#ac0ab9f765621de3140cc27d6472f5581">AirlineCode_T</a>& lAirlineCode = lInv_ptr->getAirlineCode();</div> <div class="line"></div> <div class="line"> <span class="comment">// Display only the requested inventories</span></div> <div class="line"> <span class="keywordflow">if</span> (iAirlineCode == <span class="stringliteral">"all"</span> || iAirlineCode == lAirlineCode) {</div> <div class="line"> <span class="comment">// Get the list of flight-dates for that inventory</span></div> <div class="line"> list (oStream, *lInv_ptr, invIdx, iFlightNumber);</div> <div class="line"> }</div> <div class="line"> }</div> <div class="line"> }</div> <div class="line"></div> <div class="line"> <span class="comment">// ////////////////////////////////////////////////////////////////////</span></div> <div class="line"> <span class="keywordtype">void</span> BomDisplay::list (std::ostream& oStream, <span class="keyword">const</span> Inventory& iInventory,</div> <div class="line"> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> iInventoryIndex,</div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#abb24a0796f29fe921b6dbe3ba0fa638e">FlightNumber_T</a>& iFlightNumber) {</div> <div class="line"> <span class="comment">// Save the formatting flags for the given STL output stream</span></div> <div class="line"> FlagSaver flagSaver (oStream);</div> <div class="line"></div> <div class="line"> <span class="comment">// Check whether there are FlightDate objects</span></div> <div class="line"> <span class="keywordflow">if</span> (BomManager::hasMap<FlightDate> (iInventory) == <span class="keyword">false</span>) {</div> <div class="line"> <span class="keywordflow">return</span>;</div> <div class="line"> }</div> <div class="line"> </div> <div class="line"> <span class="comment">//</span></div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#ac0ab9f765621de3140cc27d6472f5581">AirlineCode_T</a>& lAirlineCode = iInventory.getAirlineCode();</div> <div class="line"> oStream << iInventoryIndex << <span class="stringliteral">". "</span> << lAirlineCode << std::endl;</div> <div class="line"></div> <div class="line"> <span class="comment">// Browse the flight-dates</span></div> <div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> lCurrentFlightNumber = 0;</div> <div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> flightNumberIdx = 0;</div> <div class="line"> <span class="keywordtype">unsigned</span> <span class="keywordtype">short</span> departureDateIdx = 1;</div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#a161cab8007596da006451289628a1137">FlightDateMap_T</a>& lFlightDateList =</div> <div class="line"> BomManager::getMap<FlightDate> (iInventory);</div> <div class="line"> <span class="keywordflow">for</span> (FlightDateMap_T::const_iterator itFD = lFlightDateList.begin();</div> <div class="line"> itFD != lFlightDateList.end(); ++itFD, ++departureDateIdx) {</div> <div class="line"> <span class="keyword">const</span> FlightDate* lFD_ptr = itFD->second;</div> <div class="line"> assert (lFD_ptr != NULL);</div> <div class="line"> </div> <div class="line"> <span class="comment">// Retrieve the key of the flight-date</span></div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#abb24a0796f29fe921b6dbe3ba0fa638e">FlightNumber_T</a>& lFlightNumber = lFD_ptr->getFlightNumber();</div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#a049eb52315b4e9bb21a411f8b9d9012e">Date_T</a>& lFlightDateDate = lFD_ptr->getDepartureDate();</div> <div class="line"></div> <div class="line"> <span class="comment">// Display only the requested flight number</span></div> <div class="line"> <span class="keywordflow">if</span> (iFlightNumber == 0 || iFlightNumber == lFlightNumber) {</div> <div class="line"> <span class="comment">//</span></div> <div class="line"> <span class="keywordflow">if</span> (lCurrentFlightNumber != lFlightNumber) {</div> <div class="line"> lCurrentFlightNumber = lFlightNumber;</div> <div class="line"> ++flightNumberIdx; departureDateIdx = 1;</div> <div class="line"> oStream << <span class="stringliteral">" "</span> << iInventoryIndex << <span class="stringliteral">"."</span> << flightNumberIdx << <span class="stringliteral">". "</span></div> <div class="line"> << lAirlineCode << lFlightNumber << std::endl;</div> <div class="line"> }</div> <div class="line"> </div> <div class="line"> oStream << <span class="stringliteral">" "</span> << iInventoryIndex << <span class="stringliteral">"."</span> << flightNumberIdx</div> <div class="line"> << <span class="stringliteral">"."</span> << departureDateIdx << <span class="stringliteral">". "</span></div> <div class="line"> << lAirlineCode << lFlightNumber << <span class="stringliteral">" / "</span> << lFlightDateDate</div> <div class="line"> << std::endl;</div> <div class="line"> }</div> <div class="line"> } </div> <div class="line"> }</div> <div class="line"></div> <div class="line"> <span class="comment">// ////////////////////////////////////////////////////////////////////</span></div> <div class="line"> <span class="keywordtype">void</span> BomDisplay::listAirportPairDateRange (std::ostream& oStream,</div> <div class="line"> <span class="keyword">const</span> BomRoot& iBomRoot) {</div> <div class="line"> <span class="comment">// Save the formatting flags for the given STL output stream</span></div> <div class="line"> FlagSaver flagSaver (oStream);</div> <div class="line"></div> <div class="line"> <span class="comment">// Check whether there are AirportPair objects</span></div> <div class="line"> <span class="keywordflow">if</span> (BomManager::hasList<AirportPair> (iBomRoot) == <span class="keyword">false</span>) {</div> <div class="line"> <span class="keywordflow">return</span>;</div> <div class="line"> }</div> <div class="line"></div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#a3910e03bffd66a6d8bef3d20c98bd0eb">AirportPairList_T</a>& lAirportPairList =</div> <div class="line"> BomManager::getList<AirportPair> (iBomRoot);</div> <div class="line"> <span class="keywordflow">for</span> (AirportPairList_T::const_iterator itAir = lAirportPairList.begin();</div> <div class="line"> itAir != lAirportPairList.end(); ++itAir ) {</div> <div class="line"> <span class="keyword">const</span> AirportPair* lAir_ptr = *itAir; </div> <div class="line"> assert (lAir_ptr != NULL);</div> <div class="line"></div> <div class="line"> <span class="comment">// Check whether there are date-period objects</span></div> <div class="line"> assert (BomManager::hasList<DatePeriod> (*lAir_ptr) == <span class="keyword">true</span>);</div> <div class="line"></div> <div class="line"> <span class="comment">// Browse the date-period objects</span></div> <div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#a0cb61b0f5151e050d83c5574f0f55cd0">DatePeriodList_T</a>& lDatePeriodList =</div> <div class="line"> BomManager::getList<DatePeriod> (*lAir_ptr);</div> <div class="line"> </div> <div class="line"> <span class="keywordflow">for</span> (DatePeriodList_T::const_iterator itDP = lDatePeriodList.begin();</div> <div class="line"> itDP != lDatePeriodList.end(); ++itDP) {</div> <div class="line"> <span class="keyword">const</span> DatePeriod* lDP_ptr = *itDP;</div> <div class="line"> assert (lDP_ptr != NULL);</div> <div class="line"> </div> <div class="line"> <span class="comment">// Display the date-period object</span></div> <div class="line"> oStream << lAir_ptr->describeKey()</div> <div class="line"> <<<span class="stringliteral">" / "</span> << lDP_ptr->describeKey() << std::endl;</div> <div class="line"> } </div> <div class="line"></div> <div class="line"> } </div> <div class="line"> }</div> <div class="line"> </div> <div class="line"> <span class="comment">// ////////////////////////////////////////////////////////////////////</span></div> <div class="line"> <span class="keywordtype">void</span> BomDisplay::csvDisplay (std::ostream& oStream,</div> </div><!-- fragment --></p> <p>See the corresponding full program (<a class="el" href="a00002.html">C++ Utility Class Browsing and Dumping the StdAir BOM Tree</a>) for more details.</p> <h2><a class="anchor" id="tut_result_output"></a> Result of the Tutorial Program</h2> <p>When the <code><a class="el" href="a00196.html">stdair.cpp</a></code> program is run (with the <code>-b</code> option), the output should look like:</p> <div class="fragment"><div class="line">[D]../../batches/stdair.cpp:243: Welcome to stdair</div> <div class="line">[D]../../../stdair/command/CmdBomManager.cpp:41: StdAir will build the BOM tree from built-in specifications.</div> <div class="line">[D]../../batches/stdair.cpp:286: </div> <div class="line">===============================================================</div> <div class="line">BomRoot: -- ROOT -- </div> <div class="line">===============================================================</div> <div class="line">+++++++++++++++++++++++++++++++++++++++++++++++++</div> <div class="line">Inventory: BA</div> <div class="line">+++++++++++++++++++++++++++++++++++++++++++++++++</div> <div class="line">******************************************</div> <div class="line">FlightDate: BA9, 2011-Jun-10</div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">Leg-Dates:</div> <div class="line">----------</div> <div class="line">Flight, Leg, BoardDate, BoardTime, OffDate, OffTime, Date Offset, Time Offset, Elapsed, Distance, Capacity, </div> <div class="line">BA9 2011-Jun-10, LHR-BKK, 2011-Jun-10, 21:45:00, 2011-Jun-11, 15:40:00, 11:05:00, 1, 06:50:00, 9900, 0, </div> <div class="line">BA9 2011-Jun-10, BKK-SYD, 2011-Jun-11, 17:05:00, 2011-Jun-12, 15:40:00, 09:05:00, 1, 13:30:00, 8100, 0, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">LegCabins:</div> <div class="line">----------</div> <div class="line">Flight, Leg, Cabin, OffedCAP, PhyCAP, RgdADJ, AU, UPR, SS, Staff, WL, Group, CommSpace, AvPool, Avl, NAV, GAV, ACP, ETB, BidPrice, </div> <div class="line">BA9 2011-Jun-10, LHR-BKK 2011-Jun-10, Y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 3.52965e-319, 0, 0, </div> <div class="line">BA9 2011-Jun-10, BKK-SYD 2011-Jun-11, Y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">Buckets:</div> <div class="line">--------</div> <div class="line">Flight, Leg, Cabin, Yield, AU/SI, SS, AV, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">SegmentCabins:</div> <div class="line">--------------</div> <div class="line">Flight, Segment, Cabin, FF, Bkgs, MIN, UPR, CommSpace, AvPool, BP, </div> <div class="line">BA9 2011-Jun-10, LHR-SYD 2011-Jun-10, Y, EcoSaver, 0, 0, 0, 0, 9, 0, </div> <div class="line">BA9 2011-Jun-10, LHR-BKK 2011-Jun-10, Y, EcoSaver, 0, 0, 0, 0, 9, 0, </div> <div class="line">BA9 2011-Jun-10, BKK-SYD 2011-Jun-11, Y, EcoSaver, 0, 0, 0, 0, 9, 0, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">Subclasses:</div> <div class="line">-----------</div> <div class="line">Flight, Segment, Cabin, FF, Subclass, MIN/AU (Prot), Nego, NS%, OB%, Bkgs, GrpBks (pdg), StfBkgs, WLBkgs, ETB, ClassAvl, RevAvl, SegAvl, </div> <div class="line">BA9 2011-Jun-10, LHR-SYD 2011-Jun-10, Y, EcoSaver, Q, 0 (0), 0, 0, 0, 0, 0 (0), 0, 0, 0, 0, 0, 0, </div> <div class="line">+++++++++++++++++++++++++++++++++++++++++++++++++</div> <div class="line">Inventory: AF</div> <div class="line">+++++++++++++++++++++++++++++++++++++++++++++++++</div> <div class="line">******************************************</div> <div class="line">FlightDate: AF84, 2011-Mar-20</div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">Leg-Dates:</div> <div class="line">----------</div> <div class="line">Flight, Leg, BoardDate, BoardTime, OffDate, OffTime, Date Offset, Time Offset, Elapsed, Distance, Capacity, </div> <div class="line">AF84 2011-Mar-20, CDG-SFO, 2011-Mar-20, 10:40:00, 2011-Mar-20, 12:50:00, 11:10:00, 0, -09:00:00, 9900, 0, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">LegCabins:</div> <div class="line">----------</div> <div class="line">Flight, Leg, Cabin, OffedCAP, PhyCAP, RgdADJ, AU, UPR, SS, Staff, WL, Group, CommSpace, AvPool, Avl, NAV, GAV, ACP, ETB, BidPrice, </div> <div class="line">AF84 2011-Mar-20, CDG-SFO 2011-Mar-20, Y, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 0, 0, 0, 0, 0, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">Buckets:</div> <div class="line">--------</div> <div class="line">Flight, Leg, Cabin, Yield, AU/SI, SS, AV, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">SegmentCabins:</div> <div class="line">--------------</div> <div class="line">Flight, Segment, Cabin, FF, Bkgs, MIN, UPR, CommSpace, AvPool, BP, </div> <div class="line">AF84 2011-Mar-20, CDG-SFO 2011-Mar-20, Y, EcoSaver, 0, 0, 0, 0, 9, 0, </div> <div class="line">******************************************</div> <div class="line">******************************************</div> <div class="line">Subclasses:</div> <div class="line">-----------</div> <div class="line">Flight, Segment, Cabin, FF, Subclass, MIN/AU (Prot), Nego, NS%, OB%, Bkgs, GrpBks (pdg), StfBkgs, WLBkgs, ETB, ClassAvl, RevAvl, SegAvl, </div> <div class="line">AF84 2011-Mar-20, CDG-SFO 2011-Mar-20, Y, EcoSaver, Q, 0 (0), 0, 0, 0, 0, 0 (0), 0, 0, 0, 0, 0, 0, </div> <div class="line"></div> </div><!-- fragment --><p>See the corresponding full program (<a class="el" href="a00020.html">Command-Line Utility to Demonstrate Typical StdAir Usage</a>) for more details.</p> <h1><a class="anchor" id="tut_extend_bom_tree"></a> Extend the Pre-Defined BOM Tree</h1> <p>Now that we master how to instantiate the pre-defined StdAir classes, let us see how to extend that BOM.</p> <h2><a class="anchor" id="tut_extend_inventory"></a> Extend an Airline Inventory Object</h2> <p>For instance, let us assume that some (IT) provider (e.g., you) would like to have a specific implementation of the <code>Inventory</code> object. The corresponding class has just to extend the <code><a class="el" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a></code> class:</p> <p><div class="fragment"><div class="line"><span class="keyword">namespace </span>myprovider {</div> <div class="line"> <span class="keyword">class </span>Inventory : <span class="keyword">public</span> <a class="code" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a> {</div> </div><!-- fragment --></p> <p>The STL containers have to be defined accordingly too:</p> <p><div class="fragment"><div class="line"> <span class="keyword">typedef</span> std::list<Inventory*> <a class="code" href="a00535.html#aa2443c204cfcb7ce31e90308b9a63d71">InventoryList_T</a>;</div> </div><!-- fragment --></p> <p>See the full class definition (<a class="el" href="a00024.html">Specific Implementation of an Airline Inventory</a>) and implementation (<a class="el" href="a00023.html">Specific Implementation of an Airline Inventory</a>) for more details.</p> <h2><a class="anchor" id="tut_extend_build"></a> Build the Specific BOM Objects</h2> <p>The BOM root object (<code><a class="el" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a></code>) is instantiated the classical way:</p> <p><div class="fragment"><div class="line"> <span class="keyword">const</span> std::string& lBomRootKeyStr = lPersistentBomRoot.describeKey();</div> </div><!-- fragment --></p> <p>Then, the specific implementation of the airline inventory object (<code>myprovider::Inventory</code>) can be instantiated the same way as a standard Inventory (<code><a class="el" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a></code>) would be:</p> <p><div class="fragment"><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& lBAInv =</div> <div class="line"> <a class="code" href="a00089.html#af10a87fcdeb32af553c6994ba724016a">stdair::FacBom<myprovider::Inventory>::instance</a>().<a class="code" href="a00089.html#af06dd266824e0ec2ea9a15994f56fd75">create</a> (lBAKey);</div> </div><!-- fragment --></p> <p>Then, the specific implementation of the airline inventory object (<code>myprovider::Inventory</code>) is linked to the root of the BOM tree (<code><a class="el" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a></code>) the same way as the standard Inventory (<code><a class="el" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a></code>) would be:</p> <p><div class="fragment"><div class="line"> <a class="code" href="a00090.html#a732e7152a1bcb27b2b7e88e38f9fa535">stdair::FacBomManager::addToList</a> (lBomRoot, lBAInv);</div> </div><!-- fragment --></p> <p>Another specific airline inventory object is instantiated the same way:</p> <p><div class="fragment"><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& lAFInv =</div> <div class="line"> <a class="code" href="a00089.html#af10a87fcdeb32af553c6994ba724016a">stdair::FacBom<myprovider::Inventory>::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><!-- fragment --></p> <p>From the <code>BomRoot</code> (of type <code><a class="el" href="a00049.html" title="Class representing the actual attributes for the Bom root.">stdair::BomRoot</a></code>) object instance, the list of specific airline inventories (of type <code><a class="el" href="a00112.html" title="Class representing the actual attributes for an airline inventory.">stdair::Inventory</a></code>) can then be retrieved...</p> <p><div class="fragment"><div class="line"> <span class="keyword">const</span> <a class="code" href="a00535.html#aa2443c204cfcb7ce31e90308b9a63d71">myprovider::InventoryList_T</a>& lInventoryList =</div> <div class="line"> stdair::BomManager::getList<myprovider::Inventory> (lBomRoot);</div> </div><!-- fragment --></p> <p>... and browsed: <div class="fragment"><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->describeKey());</div> <div class="line"> BOOST_CHECK_MESSAGE (lInventoryKeyArray[idx] == lInv_ptr->describeKey(),</div> <div class="line"> <span class="stringliteral">"They inventory key, '"</span> << lInventoryKeyArray[idx]</div> <div class="line"> << <span class="stringliteral">"', does not match that of the Inventory object: '"</span></div> <div class="line"> << lInv_ptr->describeKey() << <span class="stringliteral">"'"</span>);</div> <div class="line"> }</div> </div><!-- fragment --></p> <h2><a class="anchor" id="tut_extend_result_output"></a> Result of the Tutorial Program</h2> <p>When this program is run, the output should look like:</p> <div class="fragment"><div class="line">Inventory: BA</div> <div class="line">Inventory: AF</div> </div><!-- fragment --><p>See the corresponding full program (<a class="el" href="a00025.html">Command-Line Test to Demonstrate How To Extend StdAir BOM</a>) for more details. </p> </div></div><!-- contents --> </div><!-- doc-content --> <li class="footer">Generated on Wed May 22 2013 10:51:59 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>