From: <den...@us...> - 2010-01-20 15:16:33
|
Revision: 97 http://stdair.svn.sourceforge.net/stdair/?rev=97&view=rev Author: denis_arnaud Date: 2010-01-20 15:16:23 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Dev] Added BasChronometer class. Modified Paths: -------------- trunk/stdair/stdair/basic/sources.mk Added Paths: ----------- trunk/stdair/stdair/basic/BasChronometer.cpp trunk/stdair/stdair/basic/BasChronometer.hpp Added: trunk/stdair/stdair/basic/BasChronometer.cpp =================================================================== --- trunk/stdair/stdair/basic/BasChronometer.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasChronometer.cpp 2010-01-20 15:16:23 UTC (rev 97) @@ -0,0 +1,45 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// Stdair +#include <stdair/basic/BasChronometer.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + BasChronometer::BasChronometer () : _startTimeLaunched (false) { + } + + // ////////////////////////////////////////////////////////////////////// + void BasChronometer::start () { + // Get the time-stamp of now, and store it for later use + _startTime = boost::posix_time::microsec_clock::local_time(); + + // Update the boolean which states whether the chronometer + // is launched + _startTimeLaunched = true; + } + + // ////////////////////////////////////////////////////////////////////// + double BasChronometer::elapsed () const { + assert (_startTimeLaunched == true); + + // Get the time-stamp of now + const boost::posix_time::ptime lStopTime = + boost::posix_time::microsec_clock::local_time(); + + // Calculate the time elapsed since the last time-stamp + const boost::posix_time::time_duration lElapsedTime = + lStopTime - _startTime; + + // Derived the corresponding number of milliseconds + const double lElapsedTimeInMicroSeconds = + static_cast<const double> (lElapsedTime.total_microseconds()); + + // The elapsed time given in return is expressed in seconds + return (lElapsedTimeInMicroSeconds / 1e6); + } + +} Added: trunk/stdair/stdair/basic/BasChronometer.hpp =================================================================== --- trunk/stdair/stdair/basic/BasChronometer.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasChronometer.hpp 2010-01-20 15:16:23 UTC (rev 97) @@ -0,0 +1,41 @@ +#ifndef __STDAIR_BAS_BASCHRONOMETER_HPP +#define __STDAIR_BAS_BASCHRONOMETER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost (STL Extension) +// Boost Date-Time (http://boost.org/doc/html/date_time/posix_time.html) +#include <boost/date_time/posix_time/posix_time.hpp> + +namespace stdair { + + /** Structure allowing measuring the time elapsed between two events. */ + struct BasChronometer { + /** Constructor. */ + BasChronometer(); + + /** Start the chronometer from the local time + <br>The elapsed time given is the one elapsed since the start + is launched. */ + void start (); + + /** Get the start time. */ + std::string getStart () const { + return boost::posix_time::to_simple_string (_startTime); + } + + /** Return the time elapsed since the structure has been instanciated. + <br>That elapsed time is expressed in seconds. */ + double elapsed () const; + + private: + /** Start time. */ + boost::posix_time::ptime _startTime; + + /** Boolean which states whether the chronometer is started or not.*/ + bool _startTimeLaunched; + }; + +} +#endif // __STDAIR_BAS_BASCHRONOMETER_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-19 18:44:31 UTC (rev 96) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-20 15:16:23 UTC (rev 97) @@ -5,6 +5,8 @@ $(top_srcdir)/stdair/basic/BasConst_BookingClass.hpp \ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ - $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp + $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ + $(top_srcdir)/stdair/basic/BasChronometer.hpp bas_cc_sources = \ - $(top_srcdir)/stdair/basic/BasConst.cpp + $(top_srcdir)/stdair/basic/BasConst.cpp \ + $(top_srcdir)/stdair/basic/BasChronometer.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-21 19:35:25
|
Revision: 102 http://stdair.svn.sourceforge.net/stdair/?rev=102&view=rev Author: denis_arnaud Date: 2010-01-21 19:35:16 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The log output stream initialisation has been moved into the StdAir library. Modified Paths: -------------- trunk/stdair/stdair/basic/sources.mk Added Paths: ----------- trunk/stdair/stdair/basic/StructAbstract.hpp Added: trunk/stdair/stdair/basic/StructAbstract.hpp =================================================================== --- trunk/stdair/stdair/basic/StructAbstract.hpp (rev 0) +++ trunk/stdair/stdair/basic/StructAbstract.hpp 2010-01-21 19:35:16 UTC (rev 102) @@ -0,0 +1,81 @@ +#ifndef __STDAIR_BAS_STRUCTABSTRACT_HPP +#define __STDAIR_BAS_STRUCTABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> + +namespace stdair { + + /** Base class for the light structures. */ + struct StructAbstract { + public: + + /** Destructor. */ + virtual ~StructAbstract() {} + + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { + ioOut << describe(); + } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + virtual void fromStream (std::istream& ioIn) {} + + /** Display of the structure. */ + virtual const std::string describe() const = 0; + + protected: + /** Protected Default Constructor to ensure this class is abtract. */ + StructAbstract() {} + }; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (p653) of his book "The C++ Standard Library: A Tutorial + and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_ostream<charT, traits>& +operator<< (std::basic_ostream<charT, traits>& ioOut, + const stdair::StructAbstract& iStruct) { + /** + string stream: + - with same format + - without special field width + */ + std::basic_ostringstream<charT,traits> ostr; + ostr.copyfmt (ioOut); + ostr.width (0); + + // Fill string stream + iStruct.toStream (ostr); + + // Print string stream + ioOut << ostr.str(); + + return ioOut; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (pp655-657) of his book "The C++ Standard Library: + A Tutorial and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_istream<charT, traits>& +operator>> (std::basic_istream<charT, traits>& ioIn, + stdair::StructAbstract& ioStruct) { + // Fill the Structure object with the input stream. + ioStruct.fromStream (ioIn); + return ioIn; + +} +#endif // __STDAIR_BAS_STRUCTABSTRACT_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-21 13:26:12 UTC (rev 101) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-21 19:35:16 UTC (rev 102) @@ -6,6 +6,7 @@ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ + $(top_srcdir)/stdair/basic/StructAbstract.hpp \ $(top_srcdir)/stdair/basic/BasChronometer.hpp \ $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ $(top_srcdir)/stdair/basic/BasLogParams.hpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-06-27 12:59:47
|
Revision: 196 http://stdair.svn.sourceforge.net/stdair/?rev=196&view=rev Author: denis_arnaud Date: 2010-06-27 12:59:39 +0000 (Sun, 27 Jun 2010) Log Message: ----------- [Dev] Added pragma directives to support Boost versions lower than 1.35 (e.g., for RedHat/CentOS 5). Modified Paths: -------------- trunk/stdair/stdair/basic/BasFileMgr.cpp trunk/stdair/stdair/basic/RandomGeneration.cpp Modified: trunk/stdair/stdair/basic/BasFileMgr.cpp =================================================================== --- trunk/stdair/stdair/basic/BasFileMgr.cpp 2010-06-13 14:07:35 UTC (rev 195) +++ trunk/stdair/stdair/basic/BasFileMgr.cpp 2010-06-27 12:59:39 UTC (rev 196) @@ -5,7 +5,13 @@ #include <cassert> // Boost (STL Extension) // Boost Filesystem (http://www.boost.org/doc/libs/1_41_0/libs/filesystem/doc/index.htm) +#include <boost/version.hpp> +#if BOOST_VERSION >= 103500 #include <boost/filesystem.hpp> +#else +#include <boost/filesystem/path.hpp> +#include <boost/filesystem/operations.hpp> +#endif // StdAir #include <stdair/basic/BasFileMgr.hpp> @@ -19,11 +25,17 @@ boostfs::path lPath (iFilepath); - if (boostfs::exists (lPath) == true && boostfs::is_regular (lPath) == true) { + if (boostfs::exists (lPath) == false) { + return oFine; + } + +#if BOOST_VERSION >= 103500 + if (boostfs::is_regular (lPath) == true) { oFine = true; } +#endif - return true; + return oFine; } } Modified: trunk/stdair/stdair/basic/RandomGeneration.cpp =================================================================== --- trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-06-13 14:07:35 UTC (rev 195) +++ trunk/stdair/stdair/basic/RandomGeneration.cpp 2010-06-27 12:59:39 UTC (rev 196) @@ -2,7 +2,10 @@ #include <cassert> #include <iostream> // Boost +#include <boost/version.hpp> +#if BOOST_VERSION >= 103500 #include <boost/math/distributions/normal.hpp> +#endif // BOOST_VERSION >= 103500 //STDAIR #include <stdair/basic/RandomGeneration.hpp> @@ -54,10 +57,15 @@ // ////////////////////////////////////////////////////////////////////// RealNumber_T RandomGeneration:: generateNormal (const RealNumber_T& mu, const RealNumber_T& sigma) { +#if BOOST_VERSION >= 103500 const Probability_T lVariateUnif = generateUniform01 (); const boost::math::normal lNormal (mu, sigma); const RealNumber_T lRealNumberOfRequestsToBeGenerated = boost::math::quantile(lNormal, lVariateUnif); +#else // BOOST_VERSION >= 103500 + // TODO: rely on GSL when Boost version smaller than 1.35 + const RealNumber_T lRealNumberOfRequestsToBeGenerated = 0.0; +#endif // BOOST_VERSION >= 103500 return lRealNumberOfRequestsToBeGenerated; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-08-02 09:13:02
|
Revision: 253 http://stdair.svn.sourceforge.net/stdair/?rev=253&view=rev Author: quannaus Date: 2010-08-02 09:12:56 +0000 (Mon, 02 Aug 2010) Log Message: ----------- [Dev] Added DEFAUTL_RANDOM_SEED. Modified Paths: -------------- trunk/stdair/stdair/basic/BasConst.cpp trunk/stdair/stdair/basic/BasConst_General.hpp Modified: trunk/stdair/stdair/basic/BasConst.cpp =================================================================== --- trunk/stdair/stdair/basic/BasConst.cpp 2010-08-01 20:56:52 UTC (rev 252) +++ trunk/stdair/stdair/basic/BasConst.cpp 2010-08-02 09:12:56 UTC (rev 253) @@ -64,7 +64,10 @@ /** Number of milliseconds in one second */ const Count_T MILLISECONDS_IN_ONE_SECOND = 1000; + /** Default random seed. */ + const RandomSeed_T DEFAULT_RANDOM_SEED = 120765987; + // //////// Fare Rules /////// /** Default saturdayStay value (false). */ const SaturdayStay_T DEFAULT_SATURDAY_STAY = false; Modified: trunk/stdair/stdair/basic/BasConst_General.hpp =================================================================== --- trunk/stdair/stdair/basic/BasConst_General.hpp 2010-08-01 20:56:52 UTC (rev 252) +++ trunk/stdair/stdair/basic/BasConst_General.hpp 2010-08-02 09:12:56 UTC (rev 253) @@ -50,5 +50,8 @@ /** Default epsilon duration. */ extern const Duration_T DEFAULT_EPSILON_DURATION; + + /** Default random seed. */ + extern const RandomSeed_T DEFAULT_RANDOM_SEED; } #endif // __STDAIR_BAS_BASCONST_GENERAL_HPP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |