Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006
00007 #include <boost/make_shared.hpp>
00008
00009 #include <stdair/basic/BasChronometer.hpp>
00010 #include <stdair/basic/BasFileMgr.hpp>
00011 #include <stdair/bom/BomManager.hpp>
00012 #include <stdair/bom/BookingRequestStruct.hpp>
00013 #include <stdair/factory/FacBomManager.hpp>
00014 #include <stdair/service/Logger.hpp>
00015 #include <stdair/STDAIR_Service.hpp>
00016
00017 #include <travelccm/factory/FacTRAVELCCMServiceContext.hpp>
00018 #include <travelccm/command/ChoiceManager.hpp>
00019 #include <travelccm/service/TRAVELCCM_ServiceContext.hpp>
00020 #include <travelccm/TRAVELCCM_Service.hpp>
00021
00022 namespace TRAVELCCM {
00023
00024
00025 TRAVELCCM_Service::TRAVELCCM_Service() : _travelccmServiceContext (NULL) {
00026 assert (false);
00027 }
00028
00029
00030 TRAVELCCM_Service::TRAVELCCM_Service (const TRAVELCCM_Service& iService)
00031 : _travelccmServiceContext (NULL) {
00032 assert (false);
00033 }
00034
00035
00036 TRAVELCCM_Service::TRAVELCCM_Service (const stdair::BasLogParams& iLogParams,
00037 const stdair::BasDBParams& iDBParams)
00038 : _travelccmServiceContext (NULL) {
00039
00040
00041 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00042 initStdAirService (iLogParams, iDBParams);
00043
00044
00045 initServiceContext();
00046
00047
00048
00049 const bool ownStdairService = true;
00050 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00051
00052
00053 initTravelCCMService();
00054 }
00055
00056
00057 TRAVELCCM_Service::TRAVELCCM_Service (const stdair::BasLogParams& iLogParams)
00058 : _travelccmServiceContext (NULL) {
00059
00060
00061 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00062 initStdAirService (iLogParams);
00063
00064
00065 initServiceContext();
00066
00067
00068
00069 const bool ownStdairService = true;
00070 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00071
00072
00073 initTravelCCMService();
00074 }
00075
00076
00077 TRAVELCCM_Service::
00078 TRAVELCCM_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr)
00079 : _travelccmServiceContext (NULL) {
00080
00081
00082 initServiceContext();
00083
00084
00085
00086 const bool doesNotOwnStdairService = false;
00087 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
00088
00089
00090 initTravelCCMService();
00091 }
00092
00093
00094 TRAVELCCM_Service::~TRAVELCCM_Service() {
00095
00096 finalise();
00097 }
00098
00099
00100 void TRAVELCCM_Service::finalise() {
00101 assert (_travelccmServiceContext != NULL);
00102
00103 _travelccmServiceContext->reset();
00104 }
00105
00106
00107 void TRAVELCCM_Service::initServiceContext() {
00108
00109 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
00110 FacTRAVELCCMServiceContext::instance().create();
00111 _travelccmServiceContext = &lTRAVELCCM_ServiceContext;
00112 }
00113
00114
00115 void TRAVELCCM_Service::
00116 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
00117 const bool iOwnStdairService) {
00118
00119 assert (_travelccmServiceContext != NULL);
00120 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
00121 *_travelccmServiceContext;
00122
00123
00124 lTRAVELCCM_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
00125 iOwnStdairService);
00126 }
00127
00128
00129 stdair::STDAIR_ServicePtr_T TRAVELCCM_Service::
00130 initStdAirService (const stdair::BasLogParams& iLogParams,
00131 const stdair::BasDBParams& iDBParams) {
00132
00139 stdair::STDAIR_ServicePtr_T oSTDAIR_Service_ptr =
00140 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
00141 assert (oSTDAIR_Service_ptr != NULL);
00142
00143 return oSTDAIR_Service_ptr;
00144 }
00145
00146
00147 stdair::STDAIR_ServicePtr_T TRAVELCCM_Service::
00148 initStdAirService (const stdair::BasLogParams& iLogParams) {
00149
00156 stdair::STDAIR_ServicePtr_T oSTDAIR_Service_ptr =
00157 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
00158 assert (oSTDAIR_Service_ptr != NULL);
00159
00160 return oSTDAIR_Service_ptr;
00161 }
00162
00163
00164 void TRAVELCCM_Service::initTravelCCMService() {
00165
00166
00167 }
00168
00169
00170 void TRAVELCCM_Service::buildSampleBom() {
00171
00172
00173 if (_travelccmServiceContext == NULL) {
00174 throw stdair::NonInitialisedServiceException ("The TravelCCM service has "
00175 "not been initialised");
00176 }
00177 assert (_travelccmServiceContext != NULL);
00178
00179
00180
00181 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
00182 *_travelccmServiceContext;
00183 const bool doesOwnStdairService =
00184 lTRAVELCCM_ServiceContext.getOwnStdairServiceFlag();
00185
00186
00187 stdair::STDAIR_Service& lSTDAIR_Service =
00188 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
00189
00194 if (doesOwnStdairService == true) {
00195
00196 lSTDAIR_Service.buildSampleBom();
00197 }
00198
00213 }
00214
00215
00216 void TRAVELCCM_Service::
00217 buildSampleTravelSolutions (stdair::TravelSolutionList_T& ioTSList) {
00218
00219
00220 if (_travelccmServiceContext == NULL) {
00221 throw stdair::NonInitialisedServiceException ("The Travelccm service has "
00222 "not been initialised");
00223 }
00224 assert (_travelccmServiceContext != NULL);
00225
00226 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
00227 *_travelccmServiceContext;
00228
00229
00230 stdair::STDAIR_Service& lSTDAIR_Service =
00231 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
00232
00233
00234 lSTDAIR_Service.buildSampleTravelSolutions (ioTSList);
00235 }
00236
00237
00238 stdair::BookingRequestStruct TRAVELCCM_Service::
00239 buildSampleBookingRequest (const bool isForCRS) {
00240
00241
00242 if (_travelccmServiceContext == NULL) {
00243 throw stdair::NonInitialisedServiceException ("The Travelccm service has "
00244 "not been initialised");
00245 }
00246 assert (_travelccmServiceContext != NULL);
00247
00248 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
00249 *_travelccmServiceContext;
00250
00251
00252 stdair::STDAIR_Service& lSTDAIR_Service =
00253 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
00254
00255
00256 return lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
00257 }
00258
00259
00260 std::string TRAVELCCM_Service::csvDisplay() const {
00261
00262
00263 if (_travelccmServiceContext == NULL) {
00264 throw stdair::NonInitialisedServiceException ("The TravelccmMaster service"
00265 " has not been initialised");
00266 }
00267 assert (_travelccmServiceContext != NULL);
00268
00269 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
00270 *_travelccmServiceContext;
00271
00272
00273 stdair::STDAIR_Service& lSTDAIR_Service =
00274 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
00275
00276
00277 return lSTDAIR_Service.csvDisplay();
00278 }
00279
00280
00281 std::string TRAVELCCM_Service::
00282 csvDisplay (const stdair::TravelSolutionList_T& iTravelSolutionList) const {
00283
00284 if (_travelccmServiceContext == NULL) {
00285 throw stdair::NonInitialisedServiceException ("The TravelccmMaster service"
00286 " has not been initialised");
00287 }
00288 assert (_travelccmServiceContext != NULL);
00289
00290 TRAVELCCM_ServiceContext& lTRAVELCCM_ServiceContext =
00291 *_travelccmServiceContext;
00292
00293
00294 stdair::STDAIR_Service& lSTDAIR_Service =
00295 lTRAVELCCM_ServiceContext.getSTDAIR_Service();
00296
00297
00298 return lSTDAIR_Service.csvDisplay (iTravelSolutionList);
00299 }
00300
00301
00302 const stdair::TravelSolutionStruct* TRAVELCCM_Service::
00303 chooseTravelSolution (stdair::TravelSolutionList_T& ioTravelSolutionList,
00304 const stdair::BookingRequestStruct& iBookingRequest) {
00305
00306 const stdair::TravelSolutionStruct* oTravelSolution_ptr =
00307 ChoiceManager::chooseTravelSolution (ioTravelSolutionList,
00308 iBookingRequest);
00309 return oTravelSolution_ptr;
00310 }
00311
00312 }