Go to the documentation of this file.00001
00002
00003
00004
00005 #include <cassert>
00006 #include <sstream>
00007
00008 #include <boost/make_shared.hpp>
00009
00010 #include <stdair/basic/BasChronometer.hpp>
00011 #include <stdair/basic/BasConst_General.hpp>
00012 #include <stdair/bom/BomRoot.hpp>
00013 #include <stdair/bom/BomDisplay.hpp>
00014 #include <stdair/bom/EventStruct.hpp>
00015 #include <stdair/bom/EventQueue.hpp>
00016 #include <stdair/service/Logger.hpp>
00017 #include <stdair/STDAIR_Service.hpp>
00018
00019 #include <sevmgr/basic/BasConst_SEVMGR_Service.hpp>
00020 #include <sevmgr/factory/FacSEVMGRServiceContext.hpp>
00021 #include <sevmgr/command/EventQueueManager.hpp>
00022 #include <sevmgr/service/SEVMGR_ServiceContext.hpp>
00023 #include <sevmgr/SEVMGR_Service.hpp>
00024
00025 namespace SEVMGR {
00026
00027
00028 SEVMGR_Service::SEVMGR_Service() : _sevmgrServiceContext (NULL) {
00029 assert (false);
00030 }
00031
00032
00033 SEVMGR_Service::SEVMGR_Service (const SEVMGR_Service& iService)
00034 : _sevmgrServiceContext (NULL) {
00035 assert (false);
00036 }
00037
00038
00039 SEVMGR_Service::SEVMGR_Service (const stdair::BasLogParams& iLogParams,
00040 const stdair::BasDBParams& iDBParams)
00041 : _sevmgrServiceContext (NULL) {
00042
00043
00044 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00045 initStdAirService (iLogParams, iDBParams);
00046
00047
00048 initServiceContext();
00049
00050
00051
00052 const bool ownStdairService = true;
00053 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00054
00055
00056 initSevmgrService();
00057 }
00058
00059
00060 SEVMGR_Service::SEVMGR_Service (const stdair::BasLogParams& iLogParams)
00061 : _sevmgrServiceContext (NULL) {
00062
00063
00064 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00065 initStdAirService (iLogParams);
00066
00067
00068 initServiceContext();
00069
00070
00071
00072 const bool ownStdairService = true;
00073 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
00074
00075
00076 initSevmgrService();
00077 }
00078
00079
00080 SEVMGR_Service::
00081 SEVMGR_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr)
00082 : _sevmgrServiceContext (NULL) {
00083
00084
00085 initServiceContext();
00086
00087
00088
00089 const bool doesNotOwnStdairService = false;
00090 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
00091
00092
00093 initSevmgrService();
00094 }
00095
00096
00097 SEVMGR_Service::~SEVMGR_Service() {
00098
00099 finalise();
00100 }
00101
00102
00103 void SEVMGR_Service::finalise() {
00104 assert (_sevmgrServiceContext != NULL);
00105
00106 _sevmgrServiceContext->reset();
00107 }
00108
00109
00110 void SEVMGR_Service::initServiceContext() {
00111
00112 SEVMGR_ServiceContext& lSEVMGR_ServiceContext =
00113 FacSEVMGRServiceContext::instance().create();
00114 _sevmgrServiceContext = &lSEVMGR_ServiceContext;
00115 }
00116
00117
00118 void SEVMGR_Service::
00119 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
00120 const bool iOwnStdairService) {
00121
00122 assert (_sevmgrServiceContext != NULL);
00123 SEVMGR_ServiceContext& lSEVMGR_ServiceContext =
00124 *_sevmgrServiceContext;
00125
00126
00127 lSEVMGR_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
00128 iOwnStdairService);
00129 }
00130
00131
00132 stdair::STDAIR_ServicePtr_T SEVMGR_Service::
00133 initStdAirService (const stdair::BasLogParams& iLogParams,
00134 const stdair::BasDBParams& iDBParams) {
00135
00141 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00142 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
00143 assert (lSTDAIR_Service_ptr != NULL);
00144
00145 return lSTDAIR_Service_ptr;
00146 }
00147
00148
00149 stdair::STDAIR_ServicePtr_T SEVMGR_Service::
00150 initStdAirService (const stdair::BasLogParams& iLogParams) {
00151
00157 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
00158 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
00159 assert (lSTDAIR_Service_ptr != NULL);
00160
00161 return lSTDAIR_Service_ptr;
00162 }
00163
00164
00165 void SEVMGR_Service::initSevmgrService() {
00166
00167
00168 }
00169
00170
00171 void SEVMGR_Service::buildSampleBom() {
00172
00173
00174 if (_sevmgrServiceContext == NULL) {
00175 throw stdair::NonInitialisedServiceException ("The Sevmgr service has "
00176 "not been initialised");
00177 }
00178 assert (_sevmgrServiceContext != NULL);
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 }
00189
00190
00191 std::string SEVMGR_Service::csvDisplay() const {
00192
00193
00194 if (_sevmgrServiceContext == NULL) {
00195 throw stdair::NonInitialisedServiceException ("The Sevmgr service has "
00196 "not been initialised");
00197 }
00198 assert (_sevmgrServiceContext != NULL);
00199
00200 SEVMGR_ServiceContext& lSEVMGR_ServiceContext = *_sevmgrServiceContext;
00201
00202
00203 stdair::STDAIR_Service& lSTDAIR_Service =
00204 lSEVMGR_ServiceContext.getSTDAIR_Service();
00205
00206
00207 stdair::EventQueue& lEventQueue = lSTDAIR_Service.getEventQueue();
00208
00209
00210 return stdair::BomDisplay::csvDisplay (lEventQueue);
00211 }
00212
00213
00214 stdair::ProgressStatusSet SEVMGR_Service::
00215 popEvent (stdair::EventStruct& ioEventStruct) const {
00216
00217
00218 assert (_sevmgrServiceContext != NULL);
00219 SEVMGR_ServiceContext& lSEVMGR_ServiceContext = *_sevmgrServiceContext;
00220
00221
00222 stdair::STDAIR_Service& lSTDAIR_Service =
00223 lSEVMGR_ServiceContext.getSTDAIR_Service();
00224
00225
00226 stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00227
00228
00229 return lQueue.popEvent (ioEventStruct);
00230 }
00231
00232
00233 bool SEVMGR_Service::isQueueDone() const {
00234
00235
00236 assert (_sevmgrServiceContext != NULL);
00237 SEVMGR_ServiceContext& lSEVMGR_ServiceContext =
00238 *_sevmgrServiceContext;
00239
00240
00241 stdair::STDAIR_Service& lSTDAIR_Service =
00242 lSEVMGR_ServiceContext.getSTDAIR_Service();
00243
00244
00245 const stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00246
00247
00248 const bool isQueueDone = lQueue.isQueueDone();
00249
00250
00251 return isQueueDone;
00252 }
00253
00254
00255 void SEVMGR_Service::reset() const {
00256
00257
00258 assert (_sevmgrServiceContext != NULL);
00259 SEVMGR_ServiceContext& lSEVMGR_ServiceContext =
00260 *_sevmgrServiceContext;
00261
00262
00263 stdair::STDAIR_Service& lSTDAIR_Service =
00264 lSEVMGR_ServiceContext.getSTDAIR_Service();
00265
00266 stdair::EventQueue& lQueue = lSTDAIR_Service.getEventQueue();
00267
00268
00269 EventQueueManager::reset (lQueue);
00270 }
00271 }