TraDemGen Logo  0.2.2
C++ Simulated Travel Demand Generation Library
TRADEMGEN_Service.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // Boost
00008 #include <boost/make_shared.hpp>
00009 #if defined(SOCI_HEADERS_BURIED)
00010 #include <soci/core/soci.h>
00011 #else // SOCI_HEADERS_BURIED
00012 #include <soci/soci.h>
00013 #endif // SOCI_HEADERS_BURIED
00014 // StdAir
00015 #include <stdair/basic/BasChronometer.hpp>
00016 #include <stdair/basic/BasConst_General.hpp>
00017 #include <stdair/bom/BomRoot.hpp>
00018 #include <stdair/bom/BookingRequestStruct.hpp>
00019 #include <stdair/bom/AirlineStruct.hpp>
00020 #include <stdair/bom/EventStruct.hpp>
00021 #include <stdair/bom/EventQueue.hpp>
00022 #include <stdair/command/DBManagerForAirlines.hpp>
00023 #include <stdair/service/Logger.hpp>
00024 #include <stdair/service/DBSessionManager.hpp>
00025 #include <stdair/STDAIR_Service.hpp>
00026 // TraDemGen
00027 #include <trademgen/basic/BasConst_TRADEMGEN_Service.hpp>
00028 #include <trademgen/bom/BomDisplay.hpp>
00029 #include <trademgen/bom/DemandStreamKey.hpp>
00030 #include <trademgen/factory/FacTRADEMGENServiceContext.hpp>
00031 #include <trademgen/command/DemandParser.hpp>
00032 #include <trademgen/command/DemandManager.hpp>
00033 #include <trademgen/service/TRADEMGEN_ServiceContext.hpp>
00034 #include <trademgen/TRADEMGEN_Service.hpp>
00035 
00036 namespace TRADEMGEN {
00037 
00038   // //////////////////////////////////////////////////////////////////////
00039   TRADEMGEN_Service::TRADEMGEN_Service() : _trademgenServiceContext (NULL) {
00040     assert (false);
00041   }
00042 
00043   // //////////////////////////////////////////////////////////////////////
00044   TRADEMGEN_Service::TRADEMGEN_Service (const TRADEMGEN_Service& iService) 
00045     : _trademgenServiceContext (NULL) {
00046     assert (false);
00047   }
00048 
00049   // //////////////////////////////////////////////////////////////////////
00050   TRADEMGEN_Service::TRADEMGEN_Service (const stdair::BasLogParams& iLogParams,
00051                                         const stdair::RandomSeed_T& iRandomSeed)
00052     : _trademgenServiceContext (NULL) {
00053     
00054     // Initialise the STDAIR service handler
00055     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00056       initStdAirService (iLogParams);
00057     
00058     // Initialise the service context
00059     initServiceContext (iRandomSeed);
00060 
00061     // Add the StdAir service context to the TRADEMGEN service context
00062     // \note TRADEMGEN owns the STDAIR service resources here.
00063     const bool ownStdairService = true;
00064     addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00065 
00066     // Initialise the (remaining of the) context
00067     initTrademgenService();
00068   }
00069 
00070   // //////////////////////////////////////////////////////////////////////
00071   TRADEMGEN_Service::TRADEMGEN_Service (const stdair::BasLogParams& iLogParams,
00072                                         const stdair::BasDBParams& iDBParams,
00073                                         const stdair::RandomSeed_T& iRandomSeed)
00074     : _trademgenServiceContext (NULL) {
00075     
00076     // Initialise the STDAIR service handler
00077     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00078       initStdAirService (iLogParams, iDBParams);
00079     
00080     // Initialise the service context
00081     initServiceContext (iRandomSeed);
00082 
00083     // Add the StdAir service context to the TRADEMGEN service context
00084     // \note TRADEMGEN owns the STDAIR service resources here.
00085     const bool ownStdairService = true;
00086     addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00087 
00088     // Initialise the (remaining of the) context
00089     initTrademgenService();
00090   }
00091 
00092   // ////////////////////////////////////////////////////////////////////
00093   TRADEMGEN_Service::
00094   TRADEMGEN_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
00095                      const stdair::RandomSeed_T& iRandomSeed)
00096     : _trademgenServiceContext (NULL) {
00097 
00098     // Initialise the service context
00099     initServiceContext (iRandomSeed);
00100 
00101     // Add the StdAir service context to the TRADEMGEN service context
00102     // \note TraDemGen does not own the STDAIR service resources here.
00103     const bool doesNotOwnStdairService = false;
00104     addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
00105 
00106     // Initialise the context
00107     initTrademgenService();
00108   }
00109 
00110   // //////////////////////////////////////////////////////////////////////
00111   TRADEMGEN_Service::~TRADEMGEN_Service() {
00112     // Delete/Clean all the objects from memory
00113     finalise();
00114   }
00115 
00116   // ////////////////////////////////////////////////////////////////////
00117   void TRADEMGEN_Service::finalise() {
00118     assert (_trademgenServiceContext != NULL);
00119     // Reset the (Boost.)Smart pointer pointing on the STDAIR_Service object.
00120     _trademgenServiceContext->reset();
00121   }
00122 
00123   // //////////////////////////////////////////////////////////////////////
00124   void TRADEMGEN_Service::
00125   initServiceContext (const stdair::RandomSeed_T& iRandomSeed) {
00126     // Initialise the service context
00127     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext = 
00128       FacTRADEMGENServiceContext::instance().create (iRandomSeed);
00129     _trademgenServiceContext = &lTRADEMGEN_ServiceContext;
00130   }
00131 
00132   // ////////////////////////////////////////////////////////////////////
00133   void TRADEMGEN_Service::
00134   addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
00135                     const bool iOwnStdairService) {
00136     // Retrieve the TraDemGen service context
00137     assert (_trademgenServiceContext != NULL);
00138     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00139       *_trademgenServiceContext;
00140 
00141     // Store the STDAIR service object within the (TRADEMGEN) service context
00142     lTRADEMGEN_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
00143                                                  iOwnStdairService);
00144   }
00145   
00146   // //////////////////////////////////////////////////////////////////////
00147   stdair::STDAIR_ServicePtr_T TRADEMGEN_Service::
00148   initStdAirService (const stdair::BasLogParams& iLogParams,
00149                      const stdair::BasDBParams& iDBParams) {
00150 
00156     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 
00157       boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
00158     assert (lSTDAIR_Service_ptr != NULL);
00159 
00160     return lSTDAIR_Service_ptr;
00161   }
00162   
00163   // //////////////////////////////////////////////////////////////////////
00164   stdair::STDAIR_ServicePtr_T TRADEMGEN_Service::
00165   initStdAirService (const stdair::BasLogParams& iLogParams) {
00166 
00172     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 
00173       boost::make_shared<stdair::STDAIR_Service> (iLogParams);
00174     assert (lSTDAIR_Service_ptr != NULL);
00175 
00176     return lSTDAIR_Service_ptr;
00177   }
00178   
00179   // //////////////////////////////////////////////////////////////////////
00180   void TRADEMGEN_Service::initTrademgenService() {
00181     // Do nothing at this stage. A sample BOM tree may be built by
00182     // calling the buildSampleBom() method
00183   }
00184 
00185   // //////////////////////////////////////////////////////////////////////
00186   void TRADEMGEN_Service::
00187   parseAndLoad (const stdair::Filename_T& iDemandInputFilename) {
00188 
00189     // Retrieve the TraDemGen service context
00190     assert (_trademgenServiceContext != NULL);
00191     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00192       *_trademgenServiceContext;
00193 
00194     // Retrieve the shared generator
00195     stdair::RandomGeneration& lSharedGenerator =
00196       lTRADEMGEN_ServiceContext.getUniformGenerator();
00197 
00198     // Retrieve the default POS distribution
00199     const POSProbabilityMass_T& lDefaultPOSProbabilityMass =
00200       lTRADEMGEN_ServiceContext.getPOSProbabilityMass();
00201     
00202     // Retrieve the StdAir service context
00203     stdair::STDAIR_Service& lSTDAIR_Service =
00204       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00205 
00206     // Retrieve the event queue
00207     stdair::EventQueue& lEventQueue = lSTDAIR_Service.getEventQueue();
00208 
00209     // Parse the input file and initialise the demand generators
00210     stdair::BasChronometer lDemandGeneration; lDemandGeneration.start();
00211     DemandParser::generateDemand (iDemandInputFilename, lEventQueue,
00212                                   lSharedGenerator, lDefaultPOSProbabilityMass);
00213     const double lGenerationMeasure = lDemandGeneration.elapsed();
00214 
00215     // DEBUG
00216     STDAIR_LOG_DEBUG ("Demand generation time: " << lGenerationMeasure);
00217   }
00218 
00219   // ////////////////////////////////////////////////////////////////////
00220   void TRADEMGEN_Service::buildSampleBom() {
00221 
00222     // Retrieve the TraDemGen service context
00223     if (_trademgenServiceContext == NULL) {
00224       throw stdair::NonInitialisedServiceException ("The TraDemGen service has "
00225                                                     "not been initialised");
00226     }
00227     assert (_trademgenServiceContext != NULL);
00228 
00229     // Retrieve the TraDemGen service context and whether it owns the Stdair
00230     // service
00231     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00232       *_trademgenServiceContext;
00233     const bool doesOwnStdairService =
00234       lTRADEMGEN_ServiceContext.getOwnStdairServiceFlag();
00235 
00236     // Retrieve the StdAir service object from the (TraDemGen) service context
00237     stdair::STDAIR_Service& lSTDAIR_Service =
00238       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00239 
00244     if (doesOwnStdairService == true) {
00245       //
00246       lSTDAIR_Service.buildSampleBom();
00247     }
00248 
00261     // Retrieve the shared generator
00262     stdair::RandomGeneration& lSharedGenerator =
00263       lTRADEMGEN_ServiceContext.getUniformGenerator();
00264 
00265     // Retrieve the default POS distribution
00266     const POSProbabilityMass_T& lDefaultPOSProbabilityMass =
00267       lTRADEMGEN_ServiceContext.getPOSProbabilityMass();
00268     
00269     // Retrieve the event queue
00270     stdair::EventQueue& lEventQueue = lSTDAIR_Service.getEventQueue();
00271 
00272     // Delegate the BOM building to the dedicated service
00273     DemandManager::buildSampleBom (lEventQueue, lSharedGenerator,
00274                                    lDefaultPOSProbabilityMass);
00275   }
00276 
00277   // //////////////////////////////////////////////////////////////////////
00278   stdair::BookingRequestStruct TRADEMGEN_Service::
00279   buildSampleBookingRequest (const bool isForCRS) {
00280 
00281     // Retrieve the TraDemGen service context
00282     if (_trademgenServiceContext == NULL) {
00283       throw stdair::NonInitialisedServiceException ("The TraDemGen service has "
00284                                                     "not been initialised");
00285     }
00286     assert (_trademgenServiceContext != NULL);
00287 
00288     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00289       *_trademgenServiceContext;
00290 
00291     // Retrieve the STDAIR service object from the (TraDemGen) service context
00292     stdair::STDAIR_Service& lSTDAIR_Service =
00293       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00294 
00295     // Delegate the BOM building to the dedicated service
00296     return lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
00297   }
00298 
00299   // //////////////////////////////////////////////////////////////////////
00300   std::string TRADEMGEN_Service::csvDisplay() const {
00301 
00302     // Retrieve the TraDemGen service context
00303     if (_trademgenServiceContext == NULL) {
00304       throw stdair::NonInitialisedServiceException ("The TraDemGen service has "
00305                                                     "not been initialised");
00306     }
00307     assert (_trademgenServiceContext != NULL);
00308 
00309     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00310       *_trademgenServiceContext;
00311 
00312     // Retrieve the STDAIR service object from the (TraDemGen) service context
00313     stdair::STDAIR_Service& lSTDAIR_Service =
00314       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00315 
00316     // Retrieve the event queue
00317     stdair::EventQueue& lEventQueue = lSTDAIR_Service.getEventQueue();
00318 
00319     // Delegate the BOM building to the dedicated service
00320     return BomDisplay::csvDisplay (lEventQueue);
00321   }
00322 
00323   // //////////////////////////////////////////////////////////////////////
00324   void TRADEMGEN_Service::displayAirlineListFromDB() const {
00325 
00326     // Retrieve the TraDemGen service context
00327     if (_trademgenServiceContext == NULL) {
00328       throw stdair::NonInitialisedServiceException ("The TraDemGen service has "
00329                                                     "not been initialised");
00330     }
00331     assert (_trademgenServiceContext != NULL);
00332     // TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00333     //  *_trademgenServiceContext;
00334 
00335     // Get the date-time for the present time
00336     boost::posix_time::ptime lNowDateTime =
00337       boost::posix_time::second_clock::local_time();
00338     //boost::gregorian::date lNowDate = lNowDateTime.date();
00339 
00340     // DEBUG
00341     STDAIR_LOG_DEBUG (std::endl
00342                       << "==================================================="
00343                       << std::endl
00344                       << lNowDateTime);
00345 
00346     // Delegate the query execution to the dedicated command
00347     stdair::BasChronometer lAirListChronometer;
00348     lAirListChronometer.start();
00349 
00350     // Retrieve the database session handler
00351     stdair::DBSession_T& lDBSession =
00352       stdair::DBSessionManager::instance().getDBSession();
00353     
00354     // Prepare and execute the select statement
00355     stdair::AirlineStruct lAirline;
00356     stdair::DBRequestStatement_T lSelectStatement (lDBSession);
00357     stdair::DBManagerForAirlines::prepareSelectStatement (lDBSession,
00358                                                           lSelectStatement,
00359                                                           lAirline);
00360     
00361     // Prepare the SQL request corresponding to the select statement
00362     bool hasStillData = true;
00363     unsigned int idx = 0;
00364     while (hasStillData == true) {
00365       hasStillData =
00366         stdair::DBManagerForAirlines::iterateOnStatement (lSelectStatement,
00367                                                           lAirline);
00368       
00369       // DEBUG
00370       STDAIR_LOG_DEBUG ("[" << idx << "]: " << lAirline);
00371       
00372       // Iteration
00373       ++idx;
00374     }
00375     
00376     const double lAirListMeasure = lAirListChronometer.elapsed();
00377     
00378     // DEBUG
00379     STDAIR_LOG_DEBUG ("Sample service for airline list retrieval: "
00380                       << lAirListMeasure);
00381   }
00382 
00383   // ////////////////////////////////////////////////////////////////////
00384   const stdair::Count_T& TRADEMGEN_Service::
00385   getExpectedTotalNumberOfRequestsToBeGenerated() const {
00386     
00387     // Retrieve the TraDemGen service context
00388     assert (_trademgenServiceContext != NULL);
00389     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00390       *_trademgenServiceContext;
00391 
00392     // Retrieve the StdAir service context
00393     stdair::STDAIR_Service& lSTDAIR_Service =
00394       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00395 
00396     // Retrieve the event queue object instance
00397     const stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00398     
00399     // Delegate the call to the dedicated command
00400     const stdair::Count_T& oExpectedTotalNumberOfRequestsToBeGenerated =
00401       lQueue.getExpectedTotalNbOfEvents (stdair::EventType::BKG_REQ);
00402 
00403     //
00404     return oExpectedTotalNumberOfRequestsToBeGenerated;
00405   }
00406 
00407   // ////////////////////////////////////////////////////////////////////
00408   const stdair::Count_T& TRADEMGEN_Service::
00409   getActualTotalNumberOfRequestsToBeGenerated() const {
00410     
00411     // Retrieve the TraDemGen service context
00412     assert (_trademgenServiceContext != NULL);
00413     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00414       *_trademgenServiceContext;
00415 
00416     // Retrieve the StdAir service context
00417     stdair::STDAIR_Service& lSTDAIR_Service =
00418       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00419 
00420     // Retrieve the event queue object instance
00421     const stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00422     
00423     // Delegate the call to the dedicated command
00424     const stdair::Count_T& oActualTotalNumberOfRequestsToBeGenerated =
00425       lQueue.getActualTotalNbOfEvents (stdair::EventType::BKG_REQ);
00426 
00427     //
00428     return oActualTotalNumberOfRequestsToBeGenerated;
00429   }
00430 
00431   // ////////////////////////////////////////////////////////////////////
00432   const bool TRADEMGEN_Service::
00433   stillHavingRequestsToBeGenerated (const stdair::DemandStreamKeyStr_T& iKey,
00434                                     stdair::ProgressStatusSet& ioPSS,
00435                                     const stdair::DemandGenerationMethod& iDemandGenerationMethod) const {
00436     
00437     // Retrieve the TraDemGen service context
00438     assert (_trademgenServiceContext != NULL);
00439     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00440       *_trademgenServiceContext;
00441 
00442     // Retrieve the StdAir service context
00443     stdair::STDAIR_Service& lSTDAIR_Service =
00444       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00445 
00446     // Retrieve the event queue object instance
00447     const stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00448     
00449     // Delegate the call to the dedicated command
00450     const bool oStillHavingRequestsToBeGenerated =
00451       DemandManager::stillHavingRequestsToBeGenerated (lQueue, iKey, ioPSS,
00452                                                        iDemandGenerationMethod);
00453 
00454     //
00455     return oStillHavingRequestsToBeGenerated;
00456   }
00457 
00458   // ////////////////////////////////////////////////////////////////////
00459   stdair::Count_T TRADEMGEN_Service::
00460   generateFirstRequests (const stdair::DemandGenerationMethod& iDemandGenerationMethod) const {
00461 
00462     // Retrieve the TraDemGen service context
00463     assert (_trademgenServiceContext != NULL);
00464     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00465       *_trademgenServiceContext;
00466 
00467     // Retrieve the StdAir service context
00468     stdair::STDAIR_Service& lSTDAIR_Service =
00469       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00470 
00471     // Retrieve the event queue object instance
00472     stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00473 
00474     // Retrieve the random generator
00475     stdair::RandomGeneration& lGenerator =
00476       lTRADEMGEN_ServiceContext.getUniformGenerator();
00477 
00478     // Delegate the call to the dedicated command
00479     const stdair::Count_T& oActualTotalNbOfEvents =
00480       DemandManager::generateFirstRequests (lQueue, lGenerator,
00481                                             iDemandGenerationMethod);
00482 
00483     //
00484     return oActualTotalNbOfEvents;
00485   }
00486 
00487   // ////////////////////////////////////////////////////////////////////
00488   stdair::BookingRequestPtr_T TRADEMGEN_Service::
00489   generateNextRequest (const stdair::DemandStreamKeyStr_T& iKey,
00490                        const stdair::DemandGenerationMethod& iDemandGenerationMethod) const {
00491 
00492     // Retrieve the TraDemGen service context
00493     assert (_trademgenServiceContext != NULL);
00494     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00495       *_trademgenServiceContext;
00496 
00497     // Retrieve the StdAir service context
00498     stdair::STDAIR_Service& lSTDAIR_Service =
00499       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00500 
00501     // Retrieve the event queue object instance
00502     stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00503     
00504     // Retrieve the random generator
00505     stdair::RandomGeneration& lGenerator =
00506       lTRADEMGEN_ServiceContext.getUniformGenerator();
00507 
00508     // Delegate the call to the dedicated command
00509     return DemandManager::generateNextRequest (lQueue, lGenerator, iKey,
00510                                                iDemandGenerationMethod);
00511   }
00512 
00513   // ////////////////////////////////////////////////////////////////////
00514   stdair::ProgressStatusSet TRADEMGEN_Service::
00515   popEvent (stdair::EventStruct& ioEventStruct) const {
00516 
00517     // Retrieve the TraDemGen service context
00518     assert (_trademgenServiceContext != NULL);
00519     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00520       *_trademgenServiceContext;
00521 
00522     // Retrieve the StdAir service context
00523     stdair::STDAIR_Service& lSTDAIR_Service =
00524       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00525 
00526     // Retrieve the event queue object instance
00527     stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00528     
00529     // Extract the next event from the queue
00530     return lQueue.popEvent (ioEventStruct);
00531   }
00532 
00533   // ////////////////////////////////////////////////////////////////////
00534   bool TRADEMGEN_Service::isQueueDone() const {
00535 
00536     // Retrieve the TraDemGen service context
00537     assert (_trademgenServiceContext != NULL);
00538     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00539       *_trademgenServiceContext;
00540 
00541     // Retrieve the StdAir service context
00542     stdair::STDAIR_Service& lSTDAIR_Service =
00543       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00544 
00545     // Retrieve the event queue object instance
00546     const stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00547     
00548     // Calculates whether the event queue has been fully emptied
00549     const bool isQueueDone = lQueue.isQueueDone();
00550 
00551     //
00552     return isQueueDone;
00553   }
00554 
00555   // ////////////////////////////////////////////////////////////////////
00556   bool TRADEMGEN_Service::
00557   generateCancellation (const stdair::TravelSolutionStruct& iTravelSolution,
00558                         const stdair::PartySize_T& iPartySize,
00559                         const stdair::DateTime_T& iRequestTime,
00560                         const stdair::Date_T& iDepartureDate) const {
00561 
00562     // Retrieve the TraDemGen service context
00563     assert (_trademgenServiceContext != NULL);
00564     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00565       *_trademgenServiceContext;
00566     
00567     // Retrieve the random generator
00568     stdair::RandomGeneration& lGenerator =
00569       lTRADEMGEN_ServiceContext.getUniformGenerator();
00570 
00571     // Retrieve the StdAir service context
00572     stdair::STDAIR_Service& lSTDAIR_Service =
00573       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00574 
00575     // Retrieve the event queue object instance
00576     stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00577 
00578     return DemandManager::generateCancellation (lQueue, lGenerator,
00579                                                 iTravelSolution, iPartySize,
00580                                                 iRequestTime, iDepartureDate);
00581   }
00582 
00583   // ////////////////////////////////////////////////////////////////////
00584   void TRADEMGEN_Service::reset() const {
00585 
00586     // Retrieve the TraDemGen service context
00587     assert (_trademgenServiceContext != NULL);
00588     TRADEMGEN_ServiceContext& lTRADEMGEN_ServiceContext =
00589       *_trademgenServiceContext;
00590 
00591     // Retrieve the StdAir service context
00592     stdair::STDAIR_Service& lSTDAIR_Service =
00593       lTRADEMGEN_ServiceContext.getSTDAIR_Service();
00594     // Retrieve the event queue object instance
00595     stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00596 
00597     // Retrieve the shared generator
00598     stdair::RandomGeneration& lSharedGenerator =
00599       lTRADEMGEN_ServiceContext.getUniformGenerator();
00600     
00601     // Delegate the call to the dedicated command
00602     DemandManager::reset (lQueue, lSharedGenerator.getBaseGenerator());
00603   }
00604 }