TvlSim Logo  1.01.6
C++ Simulated Travel-Oriented Distribution System Library
Loading...
Searching...
No Matches
TVLSIM_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/factory/FacBom.hpp>
9// Dsim
13
14namespace TVLSIM {
15
16 // //////////////////////////////////////////////////////////////////////
17 TVLSIM_ServiceContext::TVLSIM_ServiceContext (const TVLSIM_ServiceContext&)
18 : _ownStdairService (false),
19 _simulationStatus (NULL) {
20 assert (false);
21 }
22
23 // //////////////////////////////////////////////////////////////////////
24 TVLSIM_ServiceContext::TVLSIM_ServiceContext ()
25 : _simulatorID (DEFAULT_TVLSIM_ID),
26 _simulationStatus (NULL) {
27 initSimulationStatus (DEFAULT_TVLSIM_ID);
28 }
29
30
31 // //////////////////////////////////////////////////////////////////////
32 TVLSIM_ServiceContext::TVLSIM_ServiceContext (const SimulatorID_T& iSimulatorID)
33 : _simulatorID (iSimulatorID),
34 _simulationStatus (NULL) {
35 initSimulationStatus (iSimulatorID);
36 }
37
38 // //////////////////////////////////////////////////////////////////////
39 TVLSIM_ServiceContext::~TVLSIM_ServiceContext() {
40 }
41
42
43 // //////////////////////////////////////////////////////////////////////
44 void TVLSIM_ServiceContext::initSimulationStatus (const SimulatorID_T& iSimulatorID) {
45
46 // Create a Simulation Status key
47 const SimulationStatusKey lKey (iSimulatorID);
48
49 // Create a Simulation Status object instance
50 SimulationStatus& lSimulationStatus =
51 stdair::FacBom<SimulationStatus>::instance().create (lKey);
52
53 // Store the event queue object
54 _simulationStatus = &lSimulationStatus;
55 }
56
57 // //////////////////////////////////////////////////////////////////////
58 const std::string TVLSIM_ServiceContext::shortDisplay() const {
59 std::ostringstream oStr;
60 oStr << "TVLSIM_ServiceContext [" << _simulatorID
61 << "] -- Owns StdAir service: " << _ownStdairService
62 << ". Configuration parameters: "
63 << _simulationStatus->describe();
64 return oStr.str();
65 }
66
67 // //////////////////////////////////////////////////////////////////////
68 const std::string TVLSIM_ServiceContext::display() const {
69 std::ostringstream oStr;
70 oStr << shortDisplay();
71 return oStr.str();
72 }
73
74 // //////////////////////////////////////////////////////////////////////
75 const std::string TVLSIM_ServiceContext::describe() const {
76 return shortDisplay();
77 }
78
79 // //////////////////////////////////////////////////////////////////////
80 void TVLSIM_ServiceContext::reset() {
81
82 // The shared_ptr<>::reset() method drops the refcount by one.
83 // If the count result is dropping to zero, the resource pointed to
84 // by the shared_ptr<> will be freed.
85
86 // Reset the simcrs shared pointer
87 _simcrsService.reset();
88
89 // Reset the trademgen shared pointer
90 _trademgenService.reset();
91
92 // Reset the travelccm shared pointer
93 _travelccmService.reset();
94
95 // Reset the sevmgr shared pointer
96 _sevmgrService.reset();
97
98 // Reset the stdair shared pointer
99 _stdairService.reset();
100 }
101
102}
const std::string DEFAULT_TVLSIM_ID
Definition BasConst.cpp:12