|
From: <qua...@us...> - 2010-01-29 16:02:52
|
Revision: 58
http://dsim.svn.sourceforge.net/dsim/?rev=58&view=rev
Author: quannaus
Date: 2010-01-29 16:02:46 +0000 (Fri, 29 Jan 2010)
Log Message:
-----------
[Dev] Fixed a bug.
Modified Paths:
--------------
trunk/dsim/dsim/DSIM_Service.hpp
trunk/dsim/dsim/service/DSIM_Service.cpp
Modified: trunk/dsim/dsim/DSIM_Service.hpp
===================================================================
--- trunk/dsim/dsim/DSIM_Service.hpp 2010-01-29 15:59:32 UTC (rev 57)
+++ trunk/dsim/dsim/DSIM_Service.hpp 2010-01-29 16:02:46 UTC (rev 58)
@@ -62,8 +62,19 @@
/** Initialise.
@param const stdair::Filename_T& Filename of the input schedule file. */
- void init (const stdair::Filename_T&);
+ void init (stdair::STDAIR_ServicePtr_T, const stdair::Filename_T&);
+ /** Initialise the (DSIM) service context (i.e., the
+ DSIM_ServiceContext object). */
+ void initServiceContext ();
+
+ /** Initialise the STDAIR service (including the log service).
+ <br>A reference on the root of the BOM tree, namely the BomRoot object,
+ is stored within the service context for later use.
+ @param const stdair::BasLogParams& Parameters for the output log stream.
+ */
+ stdair::STDAIR_ServicePtr_T initStdAirService (const stdair::BasLogParams&);
+
/** Finalise. */
void finalise ();
Modified: trunk/dsim/dsim/service/DSIM_Service.cpp
===================================================================
--- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-29 15:59:32 UTC (rev 57)
+++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-29 16:02:46 UTC (rev 58)
@@ -7,7 +7,12 @@
// StdAir
#include <stdair/basic/BasChronometer.hpp>
#include <stdair/bom/BomManager.hpp> // for display()
+#include <stdair/bom/AirlineFeature.hpp>
+#include <stdair/bom/AirlineFeatureSet.hpp>
+#include <stdair/bom/BomRoot.hpp>
+#include <stdair/factory/FacBomContent.hpp>
#include <stdair/service/Logger.hpp>
+#include <stdair/STDAIR_Service.hpp>
// Distribution
#include <simcrs/SIMCRS_Service.hpp>
// Dsim
@@ -32,21 +37,29 @@
// //////////////////////////////////////////////////////////////////////
DSIM_Service::DSIM_Service (const stdair::Filename_T& iScheduleInputFilename)
: _dsimServiceContext (NULL) {
+
+ // Initialise the service context
+ initServiceContext ();
+ // Initialise the context
+ //init (iScheduleInputFilename);
- // Initialise the context
- init (iScheduleInputFilename);
+ assert (false);
}
// //////////////////////////////////////////////////////////////////////
DSIM_Service::DSIM_Service (const stdair::BasLogParams& iLogParams,
const stdair::Filename_T& iScheduleInputFilename)
: _dsimServiceContext (NULL) {
-
- // Set the log file
- logInit (iLogParams);
-
+
+ // Initialise the service context
+ initServiceContext ();
+
+ // Initialise the STDAIR service handler
+ stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
+ initStdAirService (iLogParams);
+
// Initialise the (remaining of the) context
- init (iScheduleInputFilename);
+ init (lSTDAIR_Service_ptr, iScheduleInputFilename);
}
// //////////////////////////////////////////////////////////////////////
@@ -55,18 +68,61 @@
finalise();
}
- // //////////////////////////////////////////////////////////////////////
- void DSIM_Service::logInit (const stdair::BasLogParams& iLogParams) {
- stdair::Logger::init (iLogParams);
- }
-
- // //////////////////////////////////////////////////////////////////////
- void DSIM_Service::init (const stdair::Filename_T& iScheduleInputFilename) {
+ // ////////////////////////////////////////////////////////////////////
+ void DSIM_Service::initServiceContext () {
// Initialise the context
DSIM_ServiceContext& lDSIM_ServiceContext =
FacDsimServiceContext::instance().create ();
_dsimServiceContext = &lDSIM_ServiceContext;
+ }
+ // //////////////////////////////////////////////////////////////////////
+ stdair::STDAIR_ServicePtr_T DSIM_Service::
+ initStdAirService (const stdair::BasLogParams& iLogParams) {
+
+ // Retrieve the Dsim service context
+ assert (_dsimServiceContext != NULL);
+ DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext;
+
+ // Initialise the STDAIR service handler
+ // Note that the track on the object memory is kept thanks to the Boost
+ // Smart Pointers component.
+ stdair::STDAIR_ServicePtr_T oSTDAIR_Service_ptr =
+ stdair::STDAIR_ServicePtr_T (new stdair::STDAIR_Service (iLogParams));
+
+ // Retrieve the root of the BOM tree, on which all of the other BOM objects
+ // will be attached
+ assert (oSTDAIR_Service_ptr != NULL);
+ stdair::BomRoot& lBomRoot = oSTDAIR_Service_ptr->getBomRoot();
+
+ // TODO: do not hardcode the initialisation of AirlineFeatureSet
+ // Initialise the set of required airline features
+ stdair::AirlineFeatureSet& lAirlineFeatureSet =
+ stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>();
+
+ // Airline code
+ stdair::AirlineCode_T lAirlineCode ("BA");
+ // Initialise an AirlineFeature object
+ stdair::AirlineFeatureKey_T lAirlineFeatureKey (lAirlineCode);
+ stdair::AirlineFeature& lAirlineFeature = stdair::FacBomContent::
+ instance().create<stdair::AirlineFeature> (lAirlineFeatureKey);
+ stdair::FacBomContent::
+ linkWithParent<stdair::AirlineFeature> (lAirlineFeature,
+ lAirlineFeatureSet);
+
+ // Set the AirlineFeatureSet for the BomRoot.
+ lBomRoot.setAirlineFeatureSet (&lAirlineFeatureSet);
+
+ return oSTDAIR_Service_ptr;
+ }
+
+ // //////////////////////////////////////////////////////////////////////
+ void DSIM_Service::init (stdair::STDAIR_ServicePtr_T ioSTDAIR_ServicePtr,
+ const stdair::Filename_T& iScheduleInputFilename) {
+ // Retrieve the service context
+ assert (_dsimServiceContext != NULL);
+ DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext;
+
// TODO: do not hardcode the CRS code (e.g., take it from a
// configuration file).
// Initialise the SIMCRS service handler
@@ -76,7 +132,8 @@
// on the Service object, and deletes that object when it is no longer
// referenced (e.g., at the end of the process).
SIMCRS_ServicePtr_T lSIMCRS_Service =
- SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (lCRSCode,
+ SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (ioSTDAIR_ServicePtr,
+ lCRSCode,
iScheduleInputFilename));
lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|