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

stdair/service/STDAIR_ServiceContext.cpp

Go to the documentation of this file.
00001 
00005 // //////////////////////////////////////////////////////////////////////
00006 // Import section
00007 // //////////////////////////////////////////////////////////////////////
00008 // STL
00009 #include <cassert>
00010 #include <sstream>
00011 // Boost
00012 #if BOOST_VERSION >= 103900
00013 #include <boost/make_shared.hpp>
00014 #else  // BOOST_VERSION >= 103900
00015 #include <boost/shared_ptr.hpp>
00016 #endif // BOOST_VERSION >= 103900
00017 // StdAir
00018 #include <stdair/basic/BasConst_General.hpp>
00019 #include <stdair/bom/BomRoot.hpp>
00020 #include <stdair/factory/FacBom.hpp>
00021 #include <stdair/factory/FacCloneBom.hpp>
00022 #include <stdair/service/STDAIR_ServiceContext.hpp>
00023 
00024 namespace stdair {
00025 
00026   // //////////////////////////////////////////////////////////////////////
00027   STDAIR_ServiceContext::STDAIR_ServiceContext()
00028     : _cloneBomRoot (NULL), 
00029       _persistentBomRoot (NULL),
00030       _initType (ServiceInitialisationType::NOT_YET_INITIALISED) {
00031     // Build the BomRoot object
00032     init();
00033   }
00034 
00035   // //////////////////////////////////////////////////////////////////////
00036   STDAIR_ServiceContext::
00037   STDAIR_ServiceContext (const STDAIR_ServiceContext& iServiceContext)
00038     : _cloneBomRoot (iServiceContext._cloneBomRoot),
00039       _persistentBomRoot (iServiceContext._persistentBomRoot),
00040       _initType (ServiceInitialisationType::NOT_YET_INITIALISED) {
00041     assert (false);
00042   }
00043 
00044   // //////////////////////////////////////////////////////////////////////
00045   STDAIR_ServiceContext::~STDAIR_ServiceContext() {
00046   }
00047 
00048   // //////////////////////////////////////////////////////////////////////
00049   void STDAIR_ServiceContext::init() {
00050     //
00051     initBomRoot();
00052     initConfigHolder();
00053   }
00054 
00055   // //////////////////////////////////////////////////////////////////////
00056   void STDAIR_ServiceContext::initBomRoot() {
00057     _persistentBomRoot = &FacBom<BomRoot>::instance().create();
00058     initCloneBomRoot();
00059   }
00060 
00061   // //////////////////////////////////////////////////////////////////////
00062   void STDAIR_ServiceContext::initCloneBomRoot() {
00063     _cloneBomRoot = 
00064       &FacCloneBom<BomRoot>::instance().clone(*_persistentBomRoot);
00065   } 
00066 
00067   // //////////////////////////////////////////////////////////////////////
00068   void STDAIR_ServiceContext::initConfigHolder() {
00069     _configHolderPtr = boost::make_shared<ConfigHolderStruct> ();
00070   }
00071   
00072   // //////////////////////////////////////////////////////////////////////
00073   const std::string STDAIR_ServiceContext::shortDisplay() const {
00074     std::ostringstream oStr;
00075     oStr << "STDAIR_ServiceContext -- " << _initType
00076          << " -- DB: " << _dbParams;
00077     return oStr.str();
00078   }
00079 
00080   // //////////////////////////////////////////////////////////////////////
00081   const std::string STDAIR_ServiceContext::display() const {
00082     std::ostringstream oStr;
00083     oStr << shortDisplay();
00084     return oStr.str();
00085   }
00086 
00087   // //////////////////////////////////////////////////////////////////////
00088   const std::string STDAIR_ServiceContext::describe() const {
00089     return shortDisplay();
00090   } 
00091 
00092   // //////////////////////////////////////////////////////////////////////
00093   BomRoot& STDAIR_ServiceContext::getPersistentBomRoot() const {
00094     assert (_persistentBomRoot != NULL);
00095     return *_persistentBomRoot;
00096   }  
00097   
00098   // //////////////////////////////////////////////////////////////////////
00099   BomRoot& STDAIR_ServiceContext::getCloneBomRoot() const {
00100     assert (_cloneBomRoot != NULL);
00101     return *_cloneBomRoot;
00102   }  
00103 
00104   // //////////////////////////////////////////////////////////////////////
00105   ConfigHolderStruct& STDAIR_ServiceContext::getConfigHolder() const { 
00106     assert (_configHolderPtr != NULL);
00107     return *_configHolderPtr;
00108   } 
00109 }
00110