Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > b4938f6e602e6d7a47abeaff7a5df581 > files > 26

sevmgr-doc-1.00.0-3.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 Use Sevmgr elements</title>
	<link rel="shortcut icon" href="favicon.ico">
	<link href="tabs.css" rel="stylesheet" type="text/css"/>
	<link href="sevmgr.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-28344140-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://sevmgr.sourceforge.net"><img height="45px" alt="SEvMgr Logo" src="sevmgr_logo.png"></a>
				  &#160;<span id="projectnumber">1.00.0</span>
				</div>
				<div id="projectbrief">C++ Simulation-Oriented Discrete Event Management Library</div>
			  </td>
			  <!-- begin SOURCEFORGE_CUSTOM-->
			  <td>
				<div id="sflogo"><a href="http://sevmgr.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('EventQueueManagementTestSuite_cpp.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>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><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 Use Sevmgr elements </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;map&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cmath&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 EventQueueManagementTest</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">#include &lt;boost/shared_ptr.hpp&gt;</span></div>
<div class="line"><span class="comment">// StdAir</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/stdair_basic_types.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/stdair_date_time_types.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/basic/BasLogParams.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/basic/BasDBParams.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/basic/BasFileMgr.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/basic/ProgressStatusSet.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/bom/EventStruct.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/bom/BookingRequestStruct.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/bom/BookingRequestTypes.hpp&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;stdair/service/Logger.hpp&gt;</span></div>
<div class="line"><span class="comment">// SEvMgr</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="SEVMGR__Service_8hpp.html">sevmgr/SEVMGR_Service.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="sevmgr-paths_8hpp.html">sevmgr/config/sevmgr-paths.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="comment">// (Boost) Unit Test XML Report</span></div>
<div class="line">std::ofstream utfReportStream (<span class="stringliteral">&quot;EventQueueManagementTestSuite_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"><span class="comment">// Specific type definitions</span></div>
<div class="line"><span class="keyword">typedef</span> std::pair&lt;stdair::Count_T, stdair::Count_T&gt; NbOfEventsPair_T;</div>
<div class="line"><span class="keyword">typedef</span> std::map&lt;<span class="keyword">const</span> stdair::DemandStreamKeyStr_T,</div>
<div class="line">                 NbOfEventsPair_T&gt; NbOfEventsByDemandStreamMap_T;</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 (sevmgr_simple_simulation_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> stdair::Filename_T lLogFilename (<span class="stringliteral">&quot;EventQueueManagementTestSuite.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">  <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 Sevmgr service object</span></div>
<div class="line">  <span class="keyword">const</span> stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile);</div>
<div class="line">  <a class="code" href="classSEVMGR_1_1SEVMGR__Service.html" title="class holding the services related to Travel Demand Generation.">SEVMGR::SEVMGR_Service</a> sevmgrService (lLogParams);</div>
<div class="line"></div>
<div class="line">  <span class="keyword">const</span> <span class="keywordtype">bool</span> isQueueDone = sevmgrService.isQueueDone();</div>
<div class="line">  BOOST_REQUIRE_MESSAGE (isQueueDone == <span class="keyword">true</span>,</div>
<div class="line">                         <span class="stringliteral">&quot;The event queue should be empty at this step. No &quot;</span></div>
<div class="line">                         &lt;&lt; <span class="stringliteral">&quot;insertion done.&quot;</span>);  </div>
<div class="line"></div>
<div class="line">  sevmgrService.buildSampleQueue (); </div>
<div class="line"></div>
<div class="line">  stdair::Count_T lNbOfEvents (sevmgrService.getQueueSize());</div>
<div class="line"></div>
<div class="line">  BOOST_REQUIRE_MESSAGE (sevmgrService.isQueueDone() == <span class="keyword">false</span>,</div>
<div class="line">                         <span class="stringliteral">&quot;The event queue should not be empty at this step. &quot;</span></div>
<div class="line">                         &lt;&lt; <span class="stringliteral">&quot;Two insertions done.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  stdair::Count_T idx = 1;</div>
<div class="line">  <span class="keywordflow">while</span> (sevmgrService.isQueueDone() == <span class="keyword">false</span>) {</div>
<div class="line">    </div>
<div class="line">    <span class="comment">// Pop the next event out of the event queue</span></div>
<div class="line">    stdair::EventStruct lEventStruct;</div>
<div class="line">    <span class="keyword">const</span> stdair::ProgressStatusSet lPPS =</div>
<div class="line">      sevmgrService.popEvent (lEventStruct);</div>
<div class="line"></div>
<div class="line">    <span class="comment">// DEBUG</span></div>
<div class="line">    STDAIR_LOG_DEBUG (<span class="stringliteral">&quot;Poped event &quot;</span>&lt;&lt; idx &lt;&lt; <span class="stringliteral">&quot;: &#39;&quot;</span></div>
<div class="line">                      &lt;&lt; lEventStruct.describe() &lt;&lt; <span class="stringliteral">&quot;&#39;.&quot;</span>);</div>
<div class="line">    STDAIR_LOG_DEBUG (<span class="stringliteral">&quot;Progresss status: &quot;</span> &lt;&lt; lPPS.describe());</div>
<div class="line">    STDAIR_LOG_DEBUG (<span class="stringliteral">&quot;Poped event: &#39;&quot;</span></div>
<div class="line">                      &lt;&lt; lEventStruct.describe() &lt;&lt; <span class="stringliteral">&quot;&#39;.&quot;</span>);</div>
<div class="line"></div>
<div class="line">    <span class="comment">// Iterate</span></div>
<div class="line">    ++idx;</div>
<div class="line">  }</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Compensate for the last iteration</span></div>
<div class="line">  --idx;</div>
<div class="line">  <span class="comment">// Compared the actual number of popped events with the expected one. </span></div>
<div class="line">  BOOST_REQUIRE_MESSAGE (idx == lNbOfEvents,</div>
<div class="line">                         <span class="stringliteral">&quot;Actual number of requests in the queue: &quot;</span></div>
<div class="line">                         &lt;&lt; idx &lt;&lt; <span class="stringliteral">&quot;. Expected value: &quot;</span> &lt;&lt; lNbOfEvents);</div>
<div class="line"></div>
<div class="line">  BOOST_REQUIRE_MESSAGE (sevmgrService.isQueueDone() == <span class="keyword">true</span>,</div>
<div class="line">                         <span class="stringliteral">&quot;The event queue should be empty at this step: &quot;</span></div>
<div class="line">                         <span class="stringliteral">&quot;the two events have been popped.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  STDAIR_LOG_DEBUG (<span class="stringliteral">&quot;Re-added the events into the queue&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Add again the four events into the queue thanks to </span></div>
<div class="line">  <span class="comment">// sevmgrService.buildSampleQueue(). </span></div>
<div class="line">  <span class="comment">// Dates of the break points: 21-JAN-2010 and 14-MAY-2011.</span></div>
<div class="line">  <span class="comment">// Dates of the booking requests: 22-JAN-2010 and 15-MAY-2011.</span></div>
<div class="line">  sevmgrService.buildSampleQueue ();</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Pop the next event out of the event queue</span></div>
<div class="line">  stdair::EventStruct lFirstEventStruct;</div>
<div class="line">  <span class="keyword">const</span> stdair::ProgressStatusSet lFirstPS =</div>
<div class="line">    sevmgrService.popEvent (lFirstEventStruct);</div>
<div class="line">  </div>
<div class="line">  <span class="comment">// Extract the corresponding date</span></div>
<div class="line">  <span class="keyword">const</span> stdair::DateTime_T&amp; lFirstEventDateTime =</div>
<div class="line">    lFirstEventStruct.getEventTime ();</div>
<div class="line">  <span class="keyword">const</span> stdair::Date_T&amp; lFirstRequestDate =</div>
<div class="line">    lFirstEventDateTime.date();</div>
<div class="line"></div>
<div class="line">  <span class="keyword">const</span> stdair::Date_T lExpectedDate (2010, boost::gregorian::Jan, 21);</div>
<div class="line">  BOOST_REQUIRE_MESSAGE (lFirstRequestDate == lExpectedDate,</div>
<div class="line">                         <span class="stringliteral">&quot;Date of the first event popped from the queue: &quot;</span></div>
<div class="line">                         &lt;&lt; lFirstRequestDate &lt;&lt; <span class="stringliteral">&quot;. Should be: &quot;</span></div>
<div class="line">                         &lt;&lt; lExpectedDate &lt;&lt; <span class="stringliteral">&quot; which is earlier in time.&quot;</span>);</div>
<div class="line">                </div>
<div class="line">  STDAIR_LOG_DEBUG (<span class="stringliteral">&quot;Reset the queue&quot;</span>);</div>
<div class="line">  sevmgrService.reset();</div>
<div class="line"></div>
<div class="line">  BOOST_REQUIRE_MESSAGE (sevmgrService.isQueueDone() == <span class="keyword">true</span>,</div>
<div class="line">                         <span class="stringliteral">&quot;The event queue has been reset: it should be empty &quot;</span></div>
<div class="line">                         &lt;&lt; <span class="stringliteral">&quot;at this step.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  STDAIR_LOG_DEBUG (<span class="stringliteral">&quot;Re-added the events into the queue one more time&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Add again the four events into the queue thanks to </span></div>
<div class="line">  <span class="comment">// sevmgrService.buildSampleQueue(). </span></div>
<div class="line">  <span class="comment">// Dates of the break points: 21-JAN-2010 and 14-MAY-2011.</span></div>
<div class="line">  <span class="comment">// Dates of the booking requests: 22-JAN-2010 and 15-MAY-2011.</span></div>
<div class="line">  sevmgrService.buildSampleQueue ();</div>
<div class="line"></div>
<div class="line">  stdair::EventStruct lBreakPointStruct;</div>
<div class="line">  sevmgrService.run(lBreakPointStruct);</div>
<div class="line">  stdair::EventType::EN_EventType lBreakPointType =</div>
<div class="line">    lBreakPointStruct.getEventType();</div>
<div class="line"></div>
<div class="line">  BOOST_REQUIRE_MESSAGE (lBreakPointType == stdair::EventType::BRK_PT,</div>
<div class="line">                         <span class="stringliteral">&quot;The last event poppped from the queue should be a &quot;</span></div>
<div class="line">                         &lt;&lt; <span class="stringliteral">&quot;break point.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  sevmgrService.run(lBreakPointStruct);</div>
<div class="line">  lBreakPointType = lBreakPointStruct.getEventType();</div>
<div class="line">  </div>
<div class="line">  BOOST_REQUIRE_MESSAGE (lBreakPointType == stdair::EventType::BRK_PT,</div>
<div class="line">                         <span class="stringliteral">&quot;The last event poppped from the queue should be a &quot;</span></div>
<div class="line">                         &lt;&lt; <span class="stringliteral">&quot;break point.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Extract the corresponding date</span></div>
<div class="line">  <span class="keyword">const</span> stdair::DateTime_T&amp; lBPDateTime =</div>
<div class="line">    lBreakPointStruct.getEventTime ();</div>
<div class="line">  <span class="keyword">const</span> stdair::Date_T&amp; lBPDate =</div>
<div class="line">    lBPDateTime.date();</div>
<div class="line"></div>
<div class="line">  <span class="keyword">const</span> stdair::Date_T lExpectedBPDate (2011, boost::gregorian::May, 14);</div>
<div class="line">  BOOST_REQUIRE_MESSAGE (lBPDate == lExpectedBPDate,</div>
<div class="line">                         <span class="stringliteral">&quot;Date of the second break point popped from the queue: &quot;</span></div>
<div class="line">                         &lt;&lt; lBPDate &lt;&lt; <span class="stringliteral">&quot;. Should be: &quot;</span></div>
<div class="line">                         &lt;&lt; lExpectedBPDate &lt;&lt; <span class="stringliteral">&quot;.&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// DEBUG</span></div>
<div class="line">  STDAIR_LOG_DEBUG (<span class="stringliteral">&quot;End of the simulation&quot;</span>);</div>
<div class="line"></div>
<div class="line">  <span class="comment">// Close the log file</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="comment">/*!</span></div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- doc-content -->
		
		<li class="footer">Generated on Wed May 22 2013 21:15:38 for SEvMgr 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/sevmgr"><img class="footer" src="http://sflogo.sourceforge.net/sflogo.php?group_id=537815&type=12&format=.png" alt="SourceForge Logo"></a>
		</li>
	  </ul>
	</div>
  </body>
</html>