$treeview $search $mathjax
SimCRS Logo  1.00.0
$projectbrief
$projectbrief
$searchbox

FacSimcrsServiceContext.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 // SIMCRS Common
00007 #include <simcrs/factory/FacSupervisor.hpp>
00008 #include <simcrs/factory/FacSimcrsServiceContext.hpp>
00009 #include <simcrs/service/SIMCRS_ServiceContext.hpp>
00010 
00011 namespace SIMCRS {
00012 
00013   FacSimcrsServiceContext* FacSimcrsServiceContext::_instance = NULL;
00014 
00015   // //////////////////////////////////////////////////////////////////////
00016   FacSimcrsServiceContext::~FacSimcrsServiceContext () {
00017     _instance = NULL;
00018   }
00019 
00020   // //////////////////////////////////////////////////////////////////////
00021   FacSimcrsServiceContext& FacSimcrsServiceContext::instance () {
00022 
00023     if (_instance == NULL) {
00024       _instance = new FacSimcrsServiceContext();
00025       assert (_instance != NULL);
00026       
00027       FacSupervisor::instance().registerServiceFactory (_instance);
00028     }
00029     return *_instance;
00030   }
00031 
00032   // //////////////////////////////////////////////////////////////////////
00033   SIMCRS_ServiceContext& FacSimcrsServiceContext::
00034   create (const std::string& iTravelDatabaseName) {
00035     SIMCRS_ServiceContext* aSIMCRS_ServiceContext_ptr = NULL;
00036 
00037     aSIMCRS_ServiceContext_ptr =
00038       new SIMCRS_ServiceContext (iTravelDatabaseName);
00039     assert (aSIMCRS_ServiceContext_ptr != NULL);
00040 
00041     // The new object is added to the Bom pool
00042     _pool.push_back (aSIMCRS_ServiceContext_ptr);
00043 
00044     return *aSIMCRS_ServiceContext_ptr;
00045   }
00046 
00047 }