$treeview $search $mathjax
TraDemGen Logo  1.00.2
$projectbrief
$projectbrief
$searchbox

TRADEMGEN_ServiceContext.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // StdAir
00008 #include <stdair/STDAIR_Service.hpp>
00009 #include <stdair/basic/BasConst_General.hpp>
00010 // TraDemGen
00011 #include <trademgen/basic/BasConst_DemandGeneration.hpp>
00012 #include <trademgen/service/TRADEMGEN_ServiceContext.hpp>
00013 
00014 namespace TRADEMGEN {
00015 
00016   // //////////////////////////////////////////////////////////////////////
00017   TRADEMGEN_ServiceContext::TRADEMGEN_ServiceContext ()
00018     : _ownStdairService (false), _uniformGenerator (stdair::DEFAULT_RANDOM_SEED),
00019       _posProbabilityMass (DEFAULT_POS_PROBALILITY_MASS) {
00020   }
00021 
00022   // //////////////////////////////////////////////////////////////////////
00023   TRADEMGEN_ServiceContext::
00024   TRADEMGEN_ServiceContext (const TRADEMGEN_ServiceContext& iServiceContext)
00025     : _ownStdairService (false), _uniformGenerator (stdair::DEFAULT_RANDOM_SEED),
00026       _posProbabilityMass (DEFAULT_POS_PROBALILITY_MASS) {
00027   }
00028 
00029   // //////////////////////////////////////////////////////////////////////
00030   TRADEMGEN_ServiceContext::
00031   TRADEMGEN_ServiceContext (const stdair::RandomSeed_T& iRandomSeed)
00032     : _ownStdairService (false), _uniformGenerator (iRandomSeed),
00033       _posProbabilityMass (DEFAULT_POS_PROBALILITY_MASS) {
00034   }
00035 
00036   // //////////////////////////////////////////////////////////////////////
00037   TRADEMGEN_ServiceContext::~TRADEMGEN_ServiceContext() {
00038   }
00039   
00040   // //////////////////////////////////////////////////////////////////////
00041   const std::string TRADEMGEN_ServiceContext::shortDisplay() const {
00042     std::ostringstream oStr;
00043     oStr << "TRADEMGEN_ServiceContext -- Owns StdAir service: "
00044          << _ownStdairService << " -- Generator: " << _uniformGenerator;
00045     return oStr.str();
00046   }
00047 
00048   // //////////////////////////////////////////////////////////////////////
00049   const std::string TRADEMGEN_ServiceContext::display() const {
00050     std::ostringstream oStr;
00051     oStr << shortDisplay();
00052     return oStr.str();
00053   }
00054 
00055   // //////////////////////////////////////////////////////////////////////
00056   const std::string TRADEMGEN_ServiceContext::describe() const {
00057     return shortDisplay();
00058   }
00059 
00060   // //////////////////////////////////////////////////////////////////////
00061   void TRADEMGEN_ServiceContext::reset() {
00062 
00063     // The shared_ptr<>::reset() method drops the refcount by one.
00064     // If the count result is dropping to zero, the resource pointed to
00065     // by the shared_ptr<> will be freed.
00066     
00067     // Reset the stdair shared pointer
00068     _stdairService.reset();
00069 
00070     // Reset the sevmgr shared pointer
00071     _sevmgrService.reset();
00072   }
00073 
00074 }