From: <den...@us...> - 2010-01-21 19:32:37
|
Revision: 53 http://dsim.svn.sourceforge.net/dsim/?rev=53&view=rev Author: denis_arnaud Date: 2010-01-21 19:32:31 +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/bom/ConfigurationParameters.cpp trunk/dsim/dsim/bom/RDSParameters.cpp trunk/dsim/dsim/command/Simulator.cpp trunk/dsim/dsim/factory/FacSupervisor.cpp trunk/dsim/dsim/factory/FacSupervisor.hpp trunk/dsim/dsim/service/sources.mk Removed Paths: ------------- trunk/dsim/dsim/service/Logger.cpp trunk/dsim/dsim/service/Logger.hpp Modified: trunk/dsim/dsim/bom/ConfigurationParameters.cpp =================================================================== --- trunk/dsim/dsim/bom/ConfigurationParameters.cpp 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/bom/ConfigurationParameters.cpp 2010-01-21 19:32:31 UTC (rev 53) @@ -6,7 +6,6 @@ #include <cassert> // DSIM #include <dsim/bom/ConfigurationParameters.hpp> -#include <dsim/service/Logger.hpp> namespace DSIM { @@ -25,14 +24,8 @@ // //////////////////////////////////////////////////////////////////// const std::string ConfigurationParameters::describe() const { - // Store current formatting flags of std::cout - std::ios::fmtflags oldFlags = std::cout.flags(); - std::ostringstream ostr; - // Reset formatting flags of std::cout - std::cout.flags (oldFlags); - return ostr.str(); } Modified: trunk/dsim/dsim/bom/RDSParameters.cpp =================================================================== --- trunk/dsim/dsim/bom/RDSParameters.cpp 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/bom/RDSParameters.cpp 2010-01-21 19:32:31 UTC (rev 53) @@ -6,7 +6,6 @@ #include <cassert> // DSIM #include <dsim/bom/RDSParameters.hpp> -#include <dsim/service/Logger.hpp> namespace DSIM { @@ -25,18 +24,12 @@ // //////////////////////////////////////////////////////////////////// const std::string RDSParameters::describe() const { - // Store current formatting flags of std::cout - std::ios::fmtflags oldFlags = std::cout.flags(); - std::ostringstream ostr; ostr << "RDS Parameters: " << std::endl; ostr << " Schedule file: " << _scheduleInputFilename; ostr << std::endl; - - // Reset formatting flags of std::cout - std::cout.flags (oldFlags); return ostr.str(); } Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-01-21 19:32:31 UTC (rev 53) @@ -6,13 +6,14 @@ #include <string> #include <vector> #include <exception> -// STDAIR +// StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/service/Logger.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> // Dsim +#include <dsim/DSIM_Types.hpp> #include <dsim/command/Simulator.hpp> -#include <dsim/service/Logger.hpp> namespace DSIM { @@ -22,7 +23,7 @@ try { // DEBUG - DSIM_LOG_DEBUG ("The simulation is starting"); + STDAIR_LOG_DEBUG ("The simulation is starting"); // Airline code stdair::AirlineCode_T lAirlineCode ("BA"); @@ -34,10 +35,10 @@ ioSIMCRS_Service.sell (lAirlineCode, lPartySize); // DEBUG - DSIM_LOG_DEBUG ("The simulation has ended"); + STDAIR_LOG_DEBUG ("The simulation has ended"); } catch (const std::exception& lStdError) { - DSIM_LOG_ERROR ("Error: " << lStdError.what()); + STDAIR_LOG_ERROR ("Error: " << lStdError.what()); throw SimulationException(); } } Modified: trunk/dsim/dsim/factory/FacSupervisor.cpp =================================================================== --- trunk/dsim/dsim/factory/FacSupervisor.cpp 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/factory/FacSupervisor.cpp 2010-01-21 19:32:31 UTC (rev 53) @@ -7,15 +7,13 @@ #include <dsim/factory/FacBomAbstract.hpp> #include <dsim/factory/FacServiceAbstract.hpp> #include <dsim/factory/FacSupervisor.hpp> -#include <dsim/service/Logger.hpp> namespace DSIM { FacSupervisor* FacSupervisor::_instance = NULL; // ////////////////////////////////////////////////////////////////////// - FacSupervisor::FacSupervisor () : - _logger (NULL) { + FacSupervisor::FacSupervisor () { } // ////////////////////////////////////////////////////////////////////// @@ -40,15 +38,9 @@ } // ////////////////////////////////////////////////////////////////////// - void FacSupervisor::registerLoggerService (Logger* ioLogger_ptr) { - _logger = ioLogger_ptr; - } - - // ////////////////////////////////////////////////////////////////////// FacSupervisor::~FacSupervisor() { cleanBomLayer(); cleanServiceLayer(); - cleanLoggerService(); } // ////////////////////////////////////////////////////////////////////// @@ -80,16 +72,10 @@ } // ////////////////////////////////////////////////////////////////////// - void FacSupervisor::cleanLoggerService() { - delete _logger; _logger = NULL; - } - - // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanFactory () { if (_instance != NULL) { _instance->cleanBomLayer(); _instance->cleanServiceLayer(); - _instance->cleanLoggerService(); } delete (_instance); _instance = NULL; } Modified: trunk/dsim/dsim/factory/FacSupervisor.hpp =================================================================== --- trunk/dsim/dsim/factory/FacSupervisor.hpp 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/factory/FacSupervisor.hpp 2010-01-21 19:32:31 UTC (rev 53) @@ -12,7 +12,6 @@ // Forward declarations class FacBomAbstract; class FacServiceAbstract; - class Logger; /** Singleton class to register and clean all Factories. */ class FacSupervisor { @@ -39,16 +38,6 @@ @param FacServiceAbstract& the concrete Factory to register. */ void registerServiceFactory (FacServiceAbstract*); - /** Register a newly instantiated concrete factory for the - Logger object. In fact, as the Logger object - follows the singleton pattern, the concrete factory is the - Logger object itself. - <br>When a concrete Factory is firstly instantiated this - factory have to register itself to the FacSupervisor. - @param FacServiceAbstract& the concrete Factory to - register. */ - void registerLoggerService (Logger*); - /** Clean all created object. <br>Call the clean method of all the instantiated factories for the Bom layer. */ @@ -59,9 +48,6 @@ for the Service layer. */ void cleanServiceLayer(); - /** Delete the Logger object. */ - void cleanLoggerService(); - /** Clean the static instance. <br> The singleton is deleted.*/ static void cleanFactory (); @@ -84,9 +70,6 @@ /** The unique instance.*/ static FacSupervisor* _instance; - /** Logger (singleton) instance. */ - Logger* _logger; - /** List of instantiated factories for the Bom layer. */ BomFactoryPool_T _bomPool; Deleted: trunk/dsim/dsim/service/Logger.cpp =================================================================== --- trunk/dsim/dsim/service/Logger.cpp 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/service/Logger.cpp 2010-01-21 19:32:31 UTC (rev 53) @@ -1,64 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <iostream> -// Dsim Logger -#include <dsim/factory/FacSupervisor.hpp> -#include <dsim/service/Logger.hpp> - -namespace DSIM { - - Logger* Logger::_instance = NULL; - - // ////////////////////////////////////////////////////////////////////// - Logger::Logger () : _logStream (&std::cout) { - assert (false); - } - - // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const Logger&) : _logStream (&std::cout) { - assert (false); - } - - // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream) - : _level (iLevel), _logStream (&ioLogStream) { - } - - // ////////////////////////////////////////////////////////////////////// - Logger::~Logger () { - _logStream = NULL; - } - - // ////////////////////////////////////////////////////////////////////// - LOG::EN_LogLevel Logger::getLogLevel() { - return _level; - } - - // ////////////////////////////////////////////////////////////////////// - std::ostream& Logger::getLogStream() { - assert (_logStream != NULL); - return *_logStream; - } - - // ////////////////////////////////////////////////////////////////////// - void Logger::setLogParameters (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogStream) { - _level = iLogLevel; - _logStream = &ioLogStream; - } - - // ////////////////////////////////////////////////////////////////////// - Logger& Logger::instance() { - if (_instance == NULL) { - _instance = new Logger (LOG::DEBUG, std::cout); - - assert (_instance != NULL); - - FacSupervisor::instance().registerLoggerService (_instance); - } - return *_instance; - } - -} Deleted: trunk/dsim/dsim/service/Logger.hpp =================================================================== --- trunk/dsim/dsim/service/Logger.hpp 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/service/Logger.hpp 2010-01-21 19:32:31 UTC (rev 53) @@ -1,94 +0,0 @@ -#ifndef __DSIM_SVC_LOGGER_HPP -#define __DSIM_SVC_LOGGER_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <cassert> -#include <sstream> -#include <string> -// DSIM -#include <dsim/DSIM_Types.hpp> - -// /////////////// LOG MACROS ///////////////// -#define DSIM_LOG_CORE(iLevel, iToBeLogged) \ - { std::ostringstream ostr; ostr << iToBeLogged; \ - DSIM::Logger::instance().log (iLevel, __LINE__, __FILE__, ostr.str()); } - -#define DSIM_LOG_CRITICAL(iToBeLogged) \ - DSIM_LOG_CORE (DSIM::LOG::CRITICAL, iToBeLogged) - -#define DSIM_LOG_ERROR(iToBeLogged) \ - DSIM_LOG_CORE (DSIM::LOG::ERROR, iToBeLogged) - -#define DSIM_LOG_NOTIFICATION(iToBeLogged) \ - DSIM_LOG_CORE (DSIM::LOG::NOTIFICATION, iToBeLogged) - -#define DSIM_LOG_WARNING(iToBeLogged) \ - DSIM_LOG_CORE (DSIM::LOG::WARNING, iToBeLogged) - -#define DSIM_LOG_DEBUG(iToBeLogged) \ - DSIM_LOG_CORE (DSIM::LOG::DEBUG, iToBeLogged) - -#define DSIM_LOG_VERBOSE(iToBeLogged) \ - DSIM_LOG_CORE (DSIM::LOG::VERBOSE, iToBeLogged) -// /////////// (END OF) LOG MACROS ///////////// - - -namespace DSIM { - - /** Class holding the stream for logs. - <br>Note that the error logs are seen as standard output logs, - but with a higher level of visibility. */ - class Logger { - // Friend classes - friend class FacSupervisor; - public: - - /** Main log entry. */ - template <typename T> - void log (const LOG::EN_LogLevel iLevel, const int iLineNumber, - const std::string& iFileName, const T& iToBeLogged) { - if (iLevel <= _level) { - assert (_logStream != NULL); - *_logStream << iFileName << ":" << iLineNumber - << ": " << iToBeLogged << std::endl; - } - } - - /** Get the log level. */ - LOG::EN_LogLevel getLogLevel(); - - /** get the log stream. */ - std::ostream& getLogStream(); - - /** Set the logger parameters (level and stream). */ - void setLogParameters (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogStream); - - /** Returns a current Logger instance.*/ - static Logger& instance(); - - private: - /** Default constructors are private so that only the required - constructor can be used. */ - Logger (); - Logger (const Logger&); - Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream); - /** Destructor. */ - ~Logger (); - - private: - /** Log level. */ - LOG::EN_LogLevel _level; - - /** Stream dedicated to the logs. */ - std::ostream* _logStream; - - /** Instance object.*/ - static Logger* _instance; - }; - -} -#endif // __DSIM_SVC_LOGGER_HPP Modified: trunk/dsim/dsim/service/sources.mk =================================================================== --- trunk/dsim/dsim/service/sources.mk 2010-01-21 13:25:10 UTC (rev 52) +++ trunk/dsim/dsim/service/sources.mk 2010-01-21 19:32:31 UTC (rev 53) @@ -1,7 +1,5 @@ svc_h_sources = $(top_srcdir)/dsim/service/ServiceAbstract.hpp \ - $(top_srcdir)/dsim/service/DSIM_ServiceContext.hpp \ - $(top_srcdir)/dsim/service/Logger.hpp + $(top_srcdir)/dsim/service/DSIM_ServiceContext.hpp svc_cc_sources = $(top_srcdir)/dsim/service/ServiceAbstract.cpp \ $(top_srcdir)/dsim/service/DSIM_ServiceContext.cpp \ - $(top_srcdir)/dsim/service/Logger.cpp \ $(top_srcdir)/dsim/service/DSIM_Service.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |