From: <den...@us...> - 2010-01-21 13:25:25
|
Revision: 52 http://dsim.svn.sourceforge.net/dsim/?rev=52&view=rev Author: denis_arnaud Date: 2010-01-21 13:25:10 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The log output stream initialisation has been moved into the StdAir library. Modified Paths: -------------- trunk/dsim/dsim/DSIM_Service.hpp trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/test/dsim/simulate.cpp Modified: trunk/dsim/dsim/DSIM_Service.hpp =================================================================== --- trunk/dsim/dsim/DSIM_Service.hpp 2010-01-20 20:11:00 UTC (rev 51) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-01-21 13:25:10 UTC (rev 52) @@ -4,11 +4,9 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// STL -#include <iosfwd> -#include <string> // StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> // Dsim #include <dsim/DSIM_Types.hpp> @@ -29,10 +27,25 @@ public: // ////////// Constructors and destructors ////////// /** Constructor. - @param std::ostream& Output log stream (for instance, std::cout). + <br>The init() method is called; see the corresponding documentation + for more details. + <br>Moreover, a reference on an output stream is given, so + that log outputs can be directed onto that stream. + @param const stdair::BasLogParams& Parameters for the output log stream. @param const stdair::Filename_T& Filename of the input schedule file. */ - DSIM_Service (std::ostream& ioLogStream, const stdair::Filename_T&); + DSIM_Service (const stdair::BasLogParams&, const stdair::Filename_T&); + /** Constructor. + <br>The init() method is called; see the corresponding documentation + for more details. + <br>Moreover, as no reference on any output stream is given, + it is assumed that the StdAir log service has already been + initialised with the proper log output stream by some other + methods in the calling chain (for instance, when the DSIM_Service + is itself being initialised by another library service). + @param const stdair::Filename_T& Filename of the input schedule file. */ + DSIM_Service (const stdair::Filename_T&); + /** Destructor. */ ~DSIM_Service(); @@ -44,10 +57,12 @@ /** Default copy constructor. */ DSIM_Service (const DSIM_Service&); + /** Initialise the log. */ + void logInit (const stdair::BasLogParams&); + /** Initialise. - @param std::ostream& Output log stream (for instance, std::cout). @param const stdair::Filename_T& Filename of the input schedule file. */ - void init (std::ostream& ioLogStream, const stdair::Filename_T&); + void init (const stdair::Filename_T&); /** Finalise. */ void finalise (); Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-20 20:11:00 UTC (rev 51) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-21 13:25:10 UTC (rev 52) @@ -4,11 +4,10 @@ // STL #include <cassert> #include <ostream> -// Boost -#include <boost/date_time/gregorian/gregorian.hpp> -#include <boost/date_time/posix_time/ptime.hpp> // StdAir #include <stdair/basic/BasChronometer.hpp> +#include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/service/Logger.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> // Dsim @@ -16,20 +15,11 @@ #include <dsim/command/Simulator.hpp> #include <dsim/factory/FacDsimServiceContext.hpp> #include <dsim/service/DSIM_ServiceContext.hpp> -#include <dsim/service/Logger.hpp> #include <dsim/DSIM_Service.hpp> namespace DSIM { // ////////////////////////////////////////////////////////////////////// - DSIM_Service:: - DSIM_Service (std::ostream& ioLogStream, - const stdair::Filename_T& iScheduleInputFilename) - : _dsimServiceContext (NULL) { - init (ioLogStream, iScheduleInputFilename); - } - - // ////////////////////////////////////////////////////////////////////// DSIM_Service::DSIM_Service () : _dsimServiceContext (NULL) { assert (false); } @@ -40,23 +30,38 @@ } // ////////////////////////////////////////////////////////////////////// + DSIM_Service::DSIM_Service (const stdair::Filename_T& iScheduleInputFilename) + : _dsimServiceContext (NULL) { + + // Initialise the context + init (iScheduleInputFilename); + } + + // ////////////////////////////////////////////////////////////////////// + DSIM_Service::DSIM_Service (const stdair::BasLogParams& iLogParams, + const stdair::Filename_T& iScheduleInputFilename) + : _dsimServiceContext (NULL) { + + // Set the log file + logInit (iLogParams); + + // Initialise the (remaining of the) context + init (iScheduleInputFilename); + } + + // ////////////////////////////////////////////////////////////////////// DSIM_Service::~DSIM_Service () { // Delete/Clean all the objects from memory finalise(); } // ////////////////////////////////////////////////////////////////////// - void logInit (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogOutputFile) { - Logger::instance().setLogParameters (iLogLevel, ioLogOutputFile); + void DSIM_Service::logInit (const stdair::BasLogParams& iLogParams) { + stdair::Logger::init (iLogParams); } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::init (std::ostream& ioLogStream, - const stdair::Filename_T& iScheduleInputFilename) { - // Set the log file - logInit (LOG::DEBUG, ioLogStream); - + void DSIM_Service::init (const stdair::Filename_T& iScheduleInputFilename) { // Initialise the context DSIM_ServiceContext& lDSIM_ServiceContext = FacDsimServiceContext::instance().create (); @@ -71,7 +76,7 @@ // 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 (ioLogStream, lCRSCode, + SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (lCRSCode, iScheduleInputFilename)); lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service); } @@ -103,11 +108,11 @@ const double lSimulationMeasure = lSimulationChronometer.elapsed(); // DEBUG - DSIM_LOG_DEBUG ("Simulation: " << lSimulationMeasure << " - " - << lDSIM_ServiceContext.display()); + STDAIR_LOG_DEBUG ("Simulation: " << lSimulationMeasure << " - " + << lDSIM_ServiceContext.display()); } catch (const std::exception& error) { - DSIM_LOG_ERROR ("Exception: " << error.what()); + STDAIR_LOG_ERROR ("Exception: " << error.what()); throw SimulationException(); } } Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2010-01-20 20:11:00 UTC (rev 51) +++ trunk/dsim/test/dsim/simulate.cpp 2010-01-21 13:25:10 UTC (rev 52) @@ -26,7 +26,8 @@ logOutputFile.clear(); // Initialise the list of classes/buckets - DSIM::DSIM_Service dsimService (logOutputFile, lScheduleInputFilename); + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + DSIM::DSIM_Service dsimService (lLogParams, lScheduleInputFilename); // Perform a simulation dsimService.simulate(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |