StdAir Logo  0.45.1
C++ Standard Airline IT Object Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // StdAir
13 #include <stdair/bom/BomRoot.hpp>
17 
18 namespace stdair {
19 
20  // //////////////////////////////////////////////////////////////////////
21  STDAIR_ServiceContext::STDAIR_ServiceContext()
22  : _bomRoot (NULL), _eventQueue (NULL),
23  _initType (ServiceInitialisationType::NOT_YET_INITIALISED) {
24  // Build the BomRoot object
25  init();
26  }
27 
28  // //////////////////////////////////////////////////////////////////////
29  STDAIR_ServiceContext::
30  STDAIR_ServiceContext (const STDAIR_ServiceContext& iServiceContext)
31  : _bomRoot (iServiceContext._bomRoot),
32  _eventQueue (iServiceContext._eventQueue),
33  _initType (ServiceInitialisationType::NOT_YET_INITIALISED) {
34  assert (false);
35  }
36 
37  // //////////////////////////////////////////////////////////////////////
38  STDAIR_ServiceContext::~STDAIR_ServiceContext() {
39  }
40 
41  // //////////////////////////////////////////////////////////////////////
42  void STDAIR_ServiceContext::init() {
43  //
44  initBomRoot();
45 
46  //
47  initEventQueue();
48  }
49 
50  // //////////////////////////////////////////////////////////////////////
51  void STDAIR_ServiceContext::initBomRoot() {
52  _bomRoot = &FacBom<BomRoot>::instance().create();
53  }
54 
55  // //////////////////////////////////////////////////////////////////////
56  void STDAIR_ServiceContext::initEventQueue() {
57 
58  // The event queue key is just a string. For now, it is not used.
59  const EventQueueKey lKey ("EQ01");
60 
61  // Create an EventQueue object instance
62  EventQueue& lEventQueue = FacBom<EventQueue>::instance().create (lKey);
63 
64  // Store the event queue object
65  _eventQueue = &lEventQueue;
66  }
67 
68  // //////////////////////////////////////////////////////////////////////
69  const std::string STDAIR_ServiceContext::shortDisplay() const {
70  std::ostringstream oStr;
71  oStr << "STDAIR_ServiceContext -- " << _initType
72  << " -- DB: " << _dbParams;
73  if (_eventQueue != NULL) {
74  oStr << " -- Queue: " << _eventQueue->toString();
75  }
76  return oStr.str();
77  }
78 
79  // //////////////////////////////////////////////////////////////////////
80  const std::string STDAIR_ServiceContext::display() const {
81  std::ostringstream oStr;
82  oStr << shortDisplay();
83  return oStr.str();
84  }
85 
86  // //////////////////////////////////////////////////////////////////////
87  const std::string STDAIR_ServiceContext::describe() const {
88  return shortDisplay();
89  }
90 
91  // //////////////////////////////////////////////////////////////////////
92  BomRoot& STDAIR_ServiceContext::getBomRoot() const {
93  assert (_bomRoot != NULL);
94  return *_bomRoot;
95  }
96 
97  // //////////////////////////////////////////////////////////////////////
98  EventQueue& STDAIR_ServiceContext::getEventQueue() const {
99  assert (_eventQueue != NULL);
100  return *_eventQueue;
101  }
102 
103 }
104