TraDemGen Logo  0.2.2
C++ Simulated Travel Demand Generation Library
FacTRADEMGENServiceContext.cpp
Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 // StdAir
00007 #include <stdair/service/FacSupervisor.hpp>
00008 // TraDemGen
00009 #include <trademgen/factory/FacTRADEMGENServiceContext.hpp>
00010 #include <trademgen/service/TRADEMGEN_ServiceContext.hpp>
00011 
00012 namespace TRADEMGEN {
00013 
00014   FacTRADEMGENServiceContext* FacTRADEMGENServiceContext::_instance = NULL;
00015 
00016   // //////////////////////////////////////////////////////////////////////
00017   FacTRADEMGENServiceContext::~FacTRADEMGENServiceContext() {
00018     _instance = NULL;
00019   }
00020 
00021   // //////////////////////////////////////////////////////////////////////
00022   FacTRADEMGENServiceContext& FacTRADEMGENServiceContext::instance() {
00023 
00024     if (_instance == NULL) {
00025       _instance = new FacTRADEMGENServiceContext();
00026       assert (_instance != NULL);
00027       
00028       stdair::FacSupervisor::instance().registerServiceFactory (_instance);
00029     }
00030     return *_instance;
00031   }
00032 
00033   // //////////////////////////////////////////////////////////////////////
00034   TRADEMGEN_ServiceContext& FacTRADEMGENServiceContext::
00035   create (const stdair::RandomSeed_T& iRandomSeed) {
00036     TRADEMGEN_ServiceContext* aServiceContext_ptr = NULL;
00037 
00038     aServiceContext_ptr = new TRADEMGEN_ServiceContext (iRandomSeed);
00039     assert (aServiceContext_ptr != NULL);
00040 
00041     // The new object is added to the Bom pool
00042     _pool.push_back (aServiceContext_ptr);
00043 
00044     return *aServiceContext_ptr;
00045   }
00046 
00047 }
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines