7 #include <boost/make_shared.hpp>
9 #include <stdair/basic/BasChronometer.hpp>
10 #include <stdair/basic/BasFileMgr.hpp>
11 #include <stdair/bom/BomManager.hpp>
12 #include <stdair/bom/BookingRequestStruct.hpp>
13 #include <stdair/factory/FacBomManager.hpp>
14 #include <stdair/service/Logger.hpp>
15 #include <stdair/STDAIR_Service.hpp>
25 TRAVELCCM_Service::TRAVELCCM_Service() : _travelccmServiceContext (NULL) {
30 TRAVELCCM_Service::TRAVELCCM_Service (
const TRAVELCCM_Service& iService)
31 : _travelccmServiceContext (NULL) {
36 TRAVELCCM_Service::TRAVELCCM_Service (
const stdair::BasLogParams& iLogParams,
37 const stdair::BasDBParams& iDBParams)
38 : _travelccmServiceContext (NULL) {
41 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
42 initStdAirService (iLogParams, iDBParams);
49 const bool ownStdairService =
true;
50 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
53 initTravelCCMService();
57 TRAVELCCM_Service::TRAVELCCM_Service (
const stdair::BasLogParams& iLogParams)
58 : _travelccmServiceContext (NULL) {
61 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
62 initStdAirService (iLogParams);
69 const bool ownStdairService =
true;
70 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
73 initTravelCCMService();
78 TRAVELCCM_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr)
79 : _travelccmServiceContext (NULL) {
86 const bool doesNotOwnStdairService =
false;
87 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
90 initTravelCCMService();
100 void TRAVELCCM_Service::finalise() {
101 assert (_travelccmServiceContext != NULL);
103 _travelccmServiceContext->reset();
107 void TRAVELCCM_Service::initServiceContext() {
109 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
111 _travelccmServiceContext = &lTRAVELCCM_ServiceContext;
115 void TRAVELCCM_Service::
116 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
117 const bool iOwnStdairService) {
119 assert (_travelccmServiceContext != NULL);
120 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
121 *_travelccmServiceContext;
124 lTRAVELCCM_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
129 stdair::STDAIR_ServicePtr_T TRAVELCCM_Service::
130 initStdAirService (
const stdair::BasLogParams& iLogParams,
131 const stdair::BasDBParams& iDBParams) {
139 stdair::STDAIR_ServicePtr_T oSTDAIR_Service_ptr =
140 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
141 assert (oSTDAIR_Service_ptr != NULL);
143 return oSTDAIR_Service_ptr;
147 stdair::STDAIR_ServicePtr_T TRAVELCCM_Service::
148 initStdAirService (
const stdair::BasLogParams& iLogParams) {
156 stdair::STDAIR_ServicePtr_T oSTDAIR_Service_ptr =
157 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
158 assert (oSTDAIR_Service_ptr != NULL);
160 return oSTDAIR_Service_ptr;
164 void TRAVELCCM_Service::initTravelCCMService() {
173 if (_travelccmServiceContext == NULL) {
174 throw stdair::NonInitialisedServiceException (
"The TravelCCM service has "
175 "not been initialised");
177 assert (_travelccmServiceContext != NULL);
182 *_travelccmServiceContext;
183 const bool doesOwnStdairService =
184 lTRAVELCCM_ServiceContext.getOwnStdairServiceFlag();
187 stdair::STDAIR_Service& lSTDAIR_Service =
188 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
191 stdair::BomRoot& lPersistentBomRoot =
192 lSTDAIR_Service.getPersistentBomRoot();
198 if (doesOwnStdairService ==
true) {
200 lSTDAIR_Service.buildSampleBom();
221 if (doesOwnStdairService ==
true) {
231 if (_travelccmServiceContext == NULL) {
232 throw stdair::NonInitialisedServiceException (
"The TravelCCM service has "
233 "not been initialised");
235 assert (_travelccmServiceContext != NULL);
240 *_travelccmServiceContext;
241 const bool doesOwnStdairService =
242 lTRAVELCCM_ServiceContext.getOwnStdairServiceFlag();
245 stdair::STDAIR_Service& lSTDAIR_Service =
246 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
252 if (doesOwnStdairService ==
true) {
253 lSTDAIR_Service.clonePersistentBom ();
268 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
282 if (_travelccmServiceContext == NULL) {
283 throw stdair::NonInitialisedServiceException (
"The Travelccm service has "
284 "not been initialised");
286 assert (_travelccmServiceContext != NULL);
289 *_travelccmServiceContext;
292 stdair::STDAIR_Service& lSTDAIR_Service =
293 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
296 lSTDAIR_Service.buildSampleTravelSolutions (ioTSList);
304 if (_travelccmServiceContext == NULL) {
305 throw stdair::NonInitialisedServiceException (
"The Travelccm service has "
306 "not been initialised");
308 assert (_travelccmServiceContext != NULL);
311 *_travelccmServiceContext;
314 stdair::STDAIR_Service& lSTDAIR_Service =
315 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
318 return lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
325 if (_travelccmServiceContext == NULL) {
326 throw stdair::NonInitialisedServiceException (
"The TravelccmMaster service"
327 " has not been initialised");
329 assert (_travelccmServiceContext != NULL);
332 *_travelccmServiceContext;
335 stdair::STDAIR_Service& lSTDAIR_Service =
336 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
337 const stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
340 return lSTDAIR_Service.csvDisplay(lBomRoot);
345 csvDisplay (
const stdair::TravelSolutionList_T& iTravelSolutionList)
const {
347 if (_travelccmServiceContext == NULL) {
348 throw stdair::NonInitialisedServiceException (
"The TravelccmMaster service"
349 " has not been initialised");
351 assert (_travelccmServiceContext != NULL);
354 *_travelccmServiceContext;
357 stdair::STDAIR_Service& lSTDAIR_Service =
358 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
361 return lSTDAIR_Service.csvDisplay (iTravelSolutionList);
367 const stdair::BookingRequestStruct& iBookingRequest,
368 const stdair::PassengerChoiceModel::EN_PassengerChoiceModel& iPassengerChoiceModel) {
370 const stdair::TravelSolutionStruct* oTravelSolution_ptr =
373 iPassengerChoiceModel);
374 return oTravelSolution_ptr;