StdAir Logo  1.00.13
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
STDAIR_ServiceContext.cpp
Go to the documentation of this file.
1
5// //////////////////////////////////////////////////////////////////////
6// Import section
7// //////////////////////////////////////////////////////////////////////
8// STL
9#include <cassert>
10#include <sstream>
11// Boost
12#if BOOST_VERSION_MACRO >= 103900
13#include <boost/make_shared.hpp>
14#else // BOOST_VERSION_MACRO >= 103900
15#include <boost/shared_ptr.hpp>
16#endif // BOOST_VERSION_MACRO >= 103900
17// StdAir
23
24namespace stdair {
25
26 // //////////////////////////////////////////////////////////////////////
27 STDAIR_ServiceContext::STDAIR_ServiceContext()
28 : _cloneBomRoot (NULL),
29 _persistentBomRoot (NULL),
30 _initType (ServiceInitialisationType::NOT_YET_INITIALISED) {
31 // Build the BomRoot object
32 init();
33 }
34
35 // //////////////////////////////////////////////////////////////////////
36 STDAIR_ServiceContext::
37 STDAIR_ServiceContext (const STDAIR_ServiceContext& iServiceContext)
38 : _cloneBomRoot (iServiceContext._cloneBomRoot),
39 _persistentBomRoot (iServiceContext._persistentBomRoot),
40 _initType (ServiceInitialisationType::NOT_YET_INITIALISED) {
41 assert (false);
42 }
43
44 // //////////////////////////////////////////////////////////////////////
45 STDAIR_ServiceContext::~STDAIR_ServiceContext() {
46 }
47
48 // //////////////////////////////////////////////////////////////////////
49 void STDAIR_ServiceContext::init() {
50 //
51 initBomRoot();
52 initConfigHolder();
53 }
54
55 // //////////////////////////////////////////////////////////////////////
56 void STDAIR_ServiceContext::initBomRoot() {
57 _persistentBomRoot = &FacBom<BomRoot>::instance().create();
58 initCloneBomRoot();
59 }
60
61 // //////////////////////////////////////////////////////////////////////
62 void STDAIR_ServiceContext::initCloneBomRoot() {
63 _cloneBomRoot =
64 &FacCloneBom<BomRoot>::instance().clone(*_persistentBomRoot);
65 }
66
67 // //////////////////////////////////////////////////////////////////////
68 void STDAIR_ServiceContext::initConfigHolder() {
69 _configHolderPtr = boost::make_shared<ConfigHolderStruct> ();
70 }
71
72 // //////////////////////////////////////////////////////////////////////
73 const std::string STDAIR_ServiceContext::shortDisplay() const {
74 std::ostringstream oStr;
75 oStr << "STDAIR_ServiceContext -- " << _initType
76 << " -- DB: " << _dbParams;
77 return oStr.str();
78 }
79
80 // //////////////////////////////////////////////////////////////////////
81 const std::string STDAIR_ServiceContext::display() const {
82 std::ostringstream oStr;
83 oStr << shortDisplay();
84 return oStr.str();
85 }
86
87 // //////////////////////////////////////////////////////////////////////
88 const std::string STDAIR_ServiceContext::describe() const {
89 return shortDisplay();
90 }
91
92 // //////////////////////////////////////////////////////////////////////
93 BomRoot& STDAIR_ServiceContext::getPersistentBomRoot() const {
94 assert (_persistentBomRoot != NULL);
95 return *_persistentBomRoot;
96 }
97
98 // //////////////////////////////////////////////////////////////////////
99 BomRoot& STDAIR_ServiceContext::getCloneBomRoot() const {
100 assert (_cloneBomRoot != NULL);
101 return *_cloneBomRoot;
102 }
103
104 // //////////////////////////////////////////////////////////////////////
105 ConfigHolderStruct& STDAIR_ServiceContext::getConfigHolder() const {
106 assert (_configHolderPtr != NULL);
107 return *_configHolderPtr;
108 }
109}
110
Handle on the StdAir library context.