SEvMgr Logo  1.00.9
C++ Simulation-Oriented Discrete Event Management Library
Loading...
Searching...
No Matches
SEVMGR_ServiceContext.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <sstream>
7// StdAir
8#include <stdair/STDAIR_Service.hpp>
9#include <stdair/basic/BasConst_General.hpp>
10#include <stdair/factory/FacBom.hpp>
11// SEvMgr
15
16namespace SEVMGR {
17
18 // //////////////////////////////////////////////////////////////////////
19 SEVMGR_ServiceContext::SEVMGR_ServiceContext()
20 : _eventQueue (NULL) {
21 init();
22 }
23
24 // //////////////////////////////////////////////////////////////////////
25 SEVMGR_ServiceContext::
26 SEVMGR_ServiceContext (const SEVMGR_ServiceContext& iServiceContext)
27 : _eventQueue (iServiceContext._eventQueue) {
28 }
29
30 // //////////////////////////////////////////////////////////////////////
31 SEVMGR_ServiceContext::~SEVMGR_ServiceContext() {
32 }
33
34 // //////////////////////////////////////////////////////////////////////
35 void SEVMGR_ServiceContext::init() {
36 //
37 initEventQueue();
38 }
39
40 // //////////////////////////////////////////////////////////////////////
41 void SEVMGR_ServiceContext::initEventQueue() {
42
43 // The event queue key is just a string. For now, it is not used.
44 const EventQueueKey lKey ("EQ01");
45
46 // Create an EventQueue object instance
47 EventQueue& lEventQueue = stdair::FacBom<EventQueue>::instance().create (lKey);
48
49 // Store the event queue object
50 _eventQueue = &lEventQueue;
51 }
52
53 // //////////////////////////////////////////////////////////////////////
54 const std::string SEVMGR_ServiceContext::shortDisplay() const {
55 std::ostringstream oStr;
56 oStr << "SEVMGR_ServiceContext -- Owns StdAir service: "
57 << _ownStdairService;
58 if (_eventQueue != NULL) {
59 oStr << " -- Queue: " << _eventQueue->toString();
60 }
61 return oStr.str();
62 }
63
64 // //////////////////////////////////////////////////////////////////////
65 const std::string SEVMGR_ServiceContext::display() const {
66 std::ostringstream oStr;
67 oStr << shortDisplay();
68 return oStr.str();
69 }
70
71 // //////////////////////////////////////////////////////////////////////
72 const std::string SEVMGR_ServiceContext::describe() const {
73 return shortDisplay();
74 }
75
76 // //////////////////////////////////////////////////////////////////////
77 void SEVMGR_ServiceContext::reset() {
78
79 // The shared_ptr<>::reset() method drops the refcount by one.
80 // If the count result is dropping to zero, the resource pointed to
81 // by the shared_ptr<> will be freed.
82
83 // Reset the stdair shared pointer
84 _stdairService.reset();
85 }
86
87 // //////////////////////////////////////////////////////////////////////
88 EventQueue& SEVMGR_ServiceContext::getEventQueue() const {
89 assert (_eventQueue != NULL);
90 return *_eventQueue;
91 }
92
93}