You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(23) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(16) |
Feb
(13) |
Mar
(1) |
Apr
(6) |
May
(4) |
Jun
(3) |
Jul
(33) |
Aug
(3) |
Sep
(16) |
Oct
(7) |
Nov
(20) |
Dec
(2) |
From: <qua...@us...> - 2010-02-12 14:04:46
|
Revision: 66 http://dsim.svn.sourceforge.net/dsim/?rev=66&view=rev Author: quannaus Date: 2010-02-12 14:04:38 +0000 (Fri, 12 Feb 2010) Log Message: ----------- [dev] Removed the hardcoded creation of AirlineFeatureSet and AirlineFeature objects. Modified Paths: -------------- trunk/dsim/dsim/service/DSIM_Service.cpp Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-12 13:57:44 UTC (rev 65) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-12 14:04:38 UTC (rev 66) @@ -111,26 +111,7 @@ // Retrieve the root of the BOM tree, on which all of the other BOM objects // will be attached assert (lSTDAIR_Service_ptr != NULL); - stdair::BomRoot& lBomRoot = lSTDAIR_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); - // Store the STDAIR service object within the (TRADEMGEN) service context lDSIM_ServiceContext.setSTDAIR_Service (lSTDAIR_Service_ptr); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-12 13:57:55
|
Revision: 65 http://dsim.svn.sourceforge.net/dsim/?rev=65&view=rev Author: quannaus Date: 2010-02-12 13:57:44 +0000 (Fri, 12 Feb 2010) Log Message: ----------- [dev] Added the request generation code into the simulator. Modified Paths: -------------- trunk/dsim/dsim/command/Simulator.cpp Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-02-10 10:13:15 UTC (rev 64) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-02-12 13:57:44 UTC (rev 65) @@ -8,6 +8,12 @@ #include <exception> // StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/DemandCharacteristics.hpp> +#include <stdair/basic/DemandDistribution.hpp> +#include <stdair/basic/CategoricalAttribute.hpp> +#include <stdair/basic/ContinuousAttribute.hpp> +#include <stdair/bom/EventStruct.hpp> +#include <stdair/bom/EventQueue.hpp> #include <stdair/bom/OutboundPathTypes.hpp> #include <stdair/bom/BookingRequestStruct.hpp> #include <stdair/bom/TravelSolutionStruct.hpp> @@ -33,12 +39,190 @@ // DEBUG STDAIR_LOG_DEBUG ("The simulation is starting"); - // Generate a booking request. - stdair::BookingRequestStruct lBookingRequest = - ioTRADEMGEN_Service.generateBookingRequest (); + // Hardcoded section for demand generation. + // Demand characteristics + stdair::DemandCharacteristics demandCharacteristics1; + stdair::DemandCharacteristics demandCharacteristics2; + // Demand distribution + stdair::DemandDistribution demandDistribution1; + stdair::DemandDistribution demandDistribution2; + // distribution of number of requests + demandDistribution1.setMeanNumberOfRequests (10.0); + demandDistribution1.setStandardDeviationNumberOfRequests (2.0); + demandDistribution2.setMeanNumberOfRequests (12.0); + demandDistribution2.setStandardDeviationNumberOfRequests (1.0); + + // origin + demandCharacteristics1.setOrigin ("LHR"); + demandCharacteristics2.setOrigin ("LHR"); + // destination + demandCharacteristics1.setDestination ("JFK"); + demandCharacteristics2.setDestination ("JFK"); + // preferred departure date + demandCharacteristics1.setPreferredDepartureDate (boost::gregorian::date (2010,1,17)); + demandCharacteristics2.setPreferredDepartureDate (boost::gregorian::date (2010,1,18)); + // Passenger type + demandCharacteristics1.setPaxType ("L"); + demandCharacteristics2.setPaxType ("B"); + + // arrival pattern + std::multimap<stdair::FloatDuration_T, stdair::Probability_T> arrivalPatternCumulativeDistribution1; + arrivalPatternCumulativeDistribution1. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (-365.0, 0) ); + arrivalPatternCumulativeDistribution1. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (-67.0, 0.2) ); + arrivalPatternCumulativeDistribution1. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (-17.0, 0.5) ); + arrivalPatternCumulativeDistribution1. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (0.0, 1.0) ); + + std::multimap<stdair::FloatDuration_T, stdair::Probability_T> arrivalPatternCumulativeDistribution2; + arrivalPatternCumulativeDistribution2. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (-365.0, 0) ); + arrivalPatternCumulativeDistribution2. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (-300.0, 0.5) ); + arrivalPatternCumulativeDistribution2. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (-200.0, 0.9) ); + arrivalPatternCumulativeDistribution2. + insert ( std::pair<stdair::FloatDuration_T, stdair::Probability_T> (0.0, 1.0) ); + + // When creating the ContinuousAttribute object, the mapping is + // inverted, i.e., the inverse cumulative distribution can be + // derived from the cumulative distribution + const stdair::ContinuousAttribute<stdair::FloatDuration_T> arrivalPattern1 (arrivalPatternCumulativeDistribution1); + demandCharacteristics1.setArrivalPattern (arrivalPattern1); + const stdair::ContinuousAttribute<stdair::FloatDuration_T> arrivalPattern2 (arrivalPatternCumulativeDistribution2); + demandCharacteristics2.setArrivalPattern (arrivalPattern2); + + // Display + STDAIR_LOG_DEBUG ("Demand 1: " << demandCharacteristics1.display() + << demandDistribution1.display() + << std::endl << std::endl); + + STDAIR_LOG_DEBUG ("Demand 2: " << demandCharacteristics2.display() + << demandDistribution2.display() + << std::endl << std::endl); + + // Seeds + stdair::RandomSeed_T seed = 2; + + // Key + stdair::DemandStreamKey_T key1 = 1; + stdair::DemandStreamKey_T key2 = 2; + + + + // Initialize the demand stream + ioTRADEMGEN_Service.addDemandStream (key1, demandCharacteristics1, + demandDistribution1, seed, seed, seed); + ioTRADEMGEN_Service.addDemandStream (key2, demandCharacteristics2, + demandDistribution2, seed, seed, seed); + + // Get the total number of requests to be generated + stdair::Count_T totalNumberOfRequestsToBeGenerated1 = + ioTRADEMGEN_Service.getTotalNumberOfRequestsToBeGenerated (key1); + stdair::Count_T totalNumberOfRequestsToBeGenerated2 = + ioTRADEMGEN_Service.getTotalNumberOfRequestsToBeGenerated (key2); + + STDAIR_LOG_DEBUG ("Number of requests to be generated (demand 1): " + << totalNumberOfRequestsToBeGenerated1 << std::endl); + STDAIR_LOG_DEBUG ("Number of requests to be generated (demand 2): " + << totalNumberOfRequestsToBeGenerated2 << std::endl); + + // ///////////////////////////////////////////////////// + // Event queue + stdair::EventQueue lEventQueue = stdair::EventQueue (); + + // Initialize by adding one request of each type + const bool stillHavingRequestsToBeGenerated1 = + ioTRADEMGEN_Service.stillHavingRequestsToBeGenerated (key1); + if (stillHavingRequestsToBeGenerated1) { + stdair::BookingRequestPtr_T lRequest1 = + ioTRADEMGEN_Service.generateNextRequest (key1); + assert (lRequest1 != NULL); + stdair::DateTime_T lRequestDateTime = lRequest1->getRequestDateTime (); + stdair::EventStruct lEventStruct ("Request", lRequestDateTime, key1, + lRequest1); + lEventQueue.addEvent (lEventStruct); + } + + const bool stillHavingRequestsToBeGenerated2 = + ioTRADEMGEN_Service.stillHavingRequestsToBeGenerated (key2); + if (stillHavingRequestsToBeGenerated2) { + stdair::BookingRequestPtr_T lRequest2 = + ioTRADEMGEN_Service.generateNextRequest (key2); + assert (lRequest2 != NULL); + stdair::DateTime_T lRequestDateTime = lRequest2->getRequestDateTime (); + stdair::EventStruct lEventStruct("Request", lRequestDateTime, key2, + lRequest2); + lEventQueue.addEvent (lEventStruct); + } + + // Pop requests, get type, and generate next request of same type + int i = 0; + while (lEventQueue.isQueueDone() == false && i < 20) { + // DEBUG + STDAIR_LOG_DEBUG ("Before popping (" << i << ")" ); + STDAIR_LOG_DEBUG ("Queue size: " << lEventQueue.getQueueSize () ); + STDAIR_LOG_DEBUG ("Is queue done? " << lEventQueue.isQueueDone () ); + + stdair::EventStruct& lEventStruct = lEventQueue.popEvent (); + + // DEBUG + STDAIR_LOG_DEBUG ("After popping" ); + STDAIR_LOG_DEBUG ("Queue size: " << lEventQueue.getQueueSize ()); + STDAIR_LOG_DEBUG ("Is queue done? " << lEventQueue.isQueueDone ()); + + STDAIR_LOG_DEBUG ("Popped request " << i ); + + const stdair::BookingRequestStruct& lPoppedRequest = + lEventStruct.getBookingRequest (); + + // DEBUG + STDAIR_LOG_DEBUG (lPoppedRequest.describe()); + + // Play booking request + playBookingRequest (ioSIMCRS_Service, lPoppedRequest); + + // Retrieve the corresponding demand stream + const stdair::DemandStreamKey_T& lDemandStreamKey = + lEventStruct.getDemandStreamKey (); + // generate next request + bool stillHavingRequestsToBeGenerated = + ioTRADEMGEN_Service.stillHavingRequestsToBeGenerated(lDemandStreamKey); + STDAIR_LOG_DEBUG ("stillHavingRequestsToBeGenerated: " << stillHavingRequestsToBeGenerated ); + if (stillHavingRequestsToBeGenerated) { + stdair::BookingRequestPtr_T lNextRequest = + ioTRADEMGEN_Service.generateNextRequest (lDemandStreamKey); + assert (lNextRequest != NULL); + // DEBUG + STDAIR_LOG_DEBUG ("Added request: " << lNextRequest->describe()); + + stdair::DateTime_T lNextRequestDateTime = + lNextRequest->getRequestDateTime (); + stdair::EventStruct lNextEventStruct ("Request", + lNextRequestDateTime, + lDemandStreamKey, + lNextRequest); + lEventQueue.eraseLastUsedEvent (); + lEventQueue.addEvent (lNextEventStruct); + + // DEBUG + STDAIR_LOG_DEBUG ("After adding"); + STDAIR_LOG_DEBUG ("Queue size: " << lEventQueue.getQueueSize ()); + STDAIR_LOG_DEBUG ("Is queue done? " << lEventQueue.isQueueDone ()); + + } + + // DEBUG + STDAIR_LOG_DEBUG (std::endl); + + // Iterate + ++i; + } // Play booking request - playBookingRequest (ioSIMCRS_Service, lBookingRequest); + //playBookingRequest (ioSIMCRS_Service, lBookingRequest); // DEBUG STDAIR_LOG_DEBUG ("The simulation has ended"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-10 10:13:21
|
Revision: 64 http://dsim.svn.sourceforge.net/dsim/?rev=64&view=rev Author: quannaus Date: 2010-02-10 10:13:15 +0000 (Wed, 10 Feb 2010) Log Message: ----------- [test] Changed some database parameters. Modified Paths: -------------- trunk/dsim/test/dsim/SimulationTestSuite.cpp trunk/dsim/test/dsim/simulate.cpp Modified: trunk/dsim/test/dsim/SimulationTestSuite.cpp =================================================================== --- trunk/dsim/test/dsim/SimulationTestSuite.cpp 2010-02-07 19:45:32 UTC (rev 63) +++ trunk/dsim/test/dsim/SimulationTestSuite.cpp 2010-02-10 10:13:15 UTC (rev 64) @@ -39,8 +39,9 @@ // Initialise the simulation context const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); - const stdair::BasDBParams lDBParams ("dsim", "dsim", "localhost", "3306", - "dsim"); + const stdair::BasDBParams lDBParams ("anguyen", "anguyen", + "ncemysqlp.nce.amadeus.net", "3321", + "sim_anguyen"); DSIM::DSIM_Service dsimService (lLogParams, lDBParams, lScheduleInputFilename, lDemandInputFilename); Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2010-02-07 19:45:32 UTC (rev 63) +++ trunk/dsim/test/dsim/simulate.cpp 2010-02-10 10:13:15 UTC (rev 64) @@ -39,7 +39,6 @@ DSIM::DSIM_Service dsimService (lLogParams, lDBParams, lScheduleInputFilename, lDemandInputFilename); - // Perform a simulation dsimService.simulate(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-07 19:45:38
|
Revision: 63 http://dsim.svn.sourceforge.net/dsim/?rev=63&view=rev Author: denis_arnaud Date: 2010-02-07 19:45:32 +0000 (Sun, 07 Feb 2010) Log Message: ----------- 1. Integrated more initialisation procedures within the STDAIR_Service object. 2. Added a sample stdair::DBManagerForAirlines class. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/dsim/DSIM_Service.hpp trunk/dsim/dsim/batches/simulate.cpp trunk/dsim/dsim/service/DSIM_Service.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/configure.ac 2010-02-07 19:45:32 UTC (rev 63) @@ -406,6 +406,7 @@ stdair/bom/Makefile stdair/dbadaptor/Makefile stdair/factory/Makefile + stdair/command/Makefile stdair/config/Makefile stdair/service/Makefile stdair/core/Makefile Modified: trunk/dsim/dsim/DSIM_Service.hpp =================================================================== --- trunk/dsim/dsim/DSIM_Service.hpp 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-02-07 19:45:32 UTC (rev 63) @@ -67,7 +67,7 @@ void simulate(); /** Display the list of airlines. */ - void displayAirlineListFromDB(); + void displayAirlineListFromDB() const; private: Modified: trunk/dsim/dsim/batches/simulate.cpp =================================================================== --- trunk/dsim/dsim/batches/simulate.cpp 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/dsim/batches/simulate.cpp 2010-02-07 19:45:32 UTC (rev 63) @@ -15,8 +15,6 @@ #include <stdair/basic/BasLogParams.hpp> #include <stdair/basic/BasDBParams.hpp> #include <stdair/factory/FacBomContent.hpp> -#include <stdair/bom/AirlineFeatureSet.hpp> -#include <stdair/bom/AirlineFeature.hpp> // DSIM #include <dsim/DSIM_Service.hpp> #include <dsim/config/dsim-paths.hpp> @@ -296,18 +294,6 @@ logOutputFile.open (lLogFilename.c_str()); logOutputFile.clear(); - // Initialise the set of required airline features - stdair::AirlineFeatureSet& lAirlineFeatureSet = - stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>(); - - // 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); - // Initialise the simulation context const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); DSIM::DSIM_Service dsimService (lLogParams, lDBParams, Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-07 19:45:32 UTC (rev 63) @@ -210,7 +210,7 @@ } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::displayAirlineListFromDB () { + void DSIM_Service::displayAirlineListFromDB () const { if (_dsimServiceContext == NULL) { throw NonInitialisedServiceException(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-07 02:41:50
|
Revision: 62 http://dsim.svn.sourceforge.net/dsim/?rev=62&view=rev Author: denis_arnaud Date: 2010-02-07 02:41:42 +0000 (Sun, 07 Feb 2010) Log Message: ----------- [DB] Now fully support database storage (with a simple example for airline names). Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/dsim/DSIM_Service.hpp trunk/dsim/dsim/batches/Makefile.am trunk/dsim/dsim/batches/sources.mk trunk/dsim/dsim/command/Makefile.am trunk/dsim/dsim/command/sources.mk trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/dsim/service/DSIM_ServiceContext.hpp trunk/dsim/test/dsim/Makefile.am trunk/dsim/test/dsim/simulate.cpp Added Paths: ----------- trunk/dsim/dsim/batches/simulate.cpp trunk/dsim/dsim/command/DBManager.cpp trunk/dsim/dsim/command/DBManager.hpp trunk/dsim/test/dsim/SimulationTestSuite.cpp trunk/dsim/test/dsim/SimulationTestSuite.hpp Property Changed: ---------------- trunk/dsim/dsim/batches/ trunk/dsim/test/dsim/ Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/configure.ac 2010-02-07 02:41:42 UTC (rev 62) @@ -171,20 +171,20 @@ # ----------------------------------------------------------- # OpenMPI: http://www.open-mpi.org # ----------------------------------------------------------- -#AX_OPENMPI -#AC_SUBST(MPIGEN_VERSION) -#AC_SUBST(MPIGEN_CFLAGS) -#AC_SUBST(MPIGEN_LIBS) +AX_OPENMPI +AC_SUBST(MPIGEN_VERSION) +AC_SUBST(MPIGEN_CFLAGS) +AC_SUBST(MPIGEN_LIBS) # ----------------------------------------------------------- # MPICH2: http://www.mcs.anl.gov/research/projects/mpich2 # Note: Boost.MPI depends on MPICH2 by default, rather than # on OpenMPI # ----------------------------------------------------------- -AX_MPICH2 -AC_SUBST(MPIGEN_VERSION) -AC_SUBST(MPIGEN_CFLAGS) -AC_SUBST(MPIGEN_LIBS) +#AX_MPICH2 +#AC_SUBST(MPIGEN_VERSION) +#AC_SUBST(MPIGEN_CFLAGS) +#AC_SUBST(MPIGEN_LIBS) # --------------------------------------------------------------- # Support for Boost (Extension of the STL): http://www.boost.org @@ -404,6 +404,7 @@ stdair/Makefile stdair/basic/Makefile stdair/bom/Makefile + stdair/dbadaptor/Makefile stdair/factory/Makefile stdair/config/Makefile stdair/service/Makefile Modified: trunk/dsim/dsim/DSIM_Service.hpp =================================================================== --- trunk/dsim/dsim/DSIM_Service.hpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -6,10 +6,17 @@ // ////////////////////////////////////////////////////////////////////// // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/BasLogParams.hpp> // Dsim #include <dsim/DSIM_Types.hpp> +// Forward declarations. +namespace stdair { + class AirlineFeatureSet; + class STDAIR_Service; + struct BasLogParams; + struct BasDBParams; +} + namespace DSIM { // Forward declaration @@ -19,37 +26,50 @@ /** Interface for the DSIM Services. */ class DSIM_Service { public: - // /////////// Business Methods ///////////// - /** Perform a simulation. */ - void simulate(); - - - public: // ////////// Constructors and destructors ////////// /** Constructor. <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. + <br>A reference on an output stream is given, so that log + outputs can be directed onto that stream. + <br>Moreover, database connection parameters are given, so that a + session can be created on the corresponding database. @param const stdair::BasLogParams& Parameters for the output log stream. - @param const stdair::Filename_T& Filename of the input schedule file. */ - DSIM_Service (const stdair::BasLogParams&, const stdair::Filename_T&); + @param const stdair::BasDBParams& Parameters for the database access. + @param const stdair::Filename_T& Filename of the input schedule file. + @param const stdair::Filename_T& Filename of the input demand file. */ + DSIM_Service (const stdair::BasLogParams&, const stdair::BasDBParams&, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilenames); /** 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&); + neither any database access parameter 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. + @param const stdair::Filename_T& Filename of the input demand file. */ + DSIM_Service (stdair::STDAIR_ServicePtr_T, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilenames); /** Destructor. */ ~DSIM_Service(); + public: + // /////////// Business Methods ///////////// + /** Perform a simulation. */ + void simulate(); + + /** Display the list of airlines. */ + void displayAirlineListFromDB(); + + private: // /////// Construction and Destruction helper methods /////// /** Default constructor. */ @@ -57,13 +77,6 @@ /** Default copy constructor. */ DSIM_Service (const DSIM_Service&); - /** Initialise the log. */ - void logInit (const stdair::BasLogParams&); - - /** Initialise. - @param const stdair::Filename_T& Filename of the input schedule file. */ - void init (stdair::STDAIR_ServicePtr_T, const stdair::Filename_T&); - /** Initialise the (DSIM) service context (i.e., the DSIM_ServiceContext object). */ void initServiceContext (); @@ -72,9 +85,20 @@ <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&); - + @param const stdair::BasDBParams& Parameters for the database access. + @param const stdair::AirlineFeatureSet& Set of airline features. */ + void initStdAirService (const stdair::BasLogParams&, + const stdair::BasDBParams&); + + /** Initialise. + <br>The CSV file, describing the airline schedules for the + simulator, is parsed and the inventories are generated accordingly. + @param const stdair::AirlineFeatureSet& Set of airline features. + @param const stdair::Filename_T& Filename of the input schedule file. + @param const stdair::Filename_T& Filename of the input demand file. */ + void init (const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename); + /** Finalise. */ void finalise (); Property changes on: trunk/dsim/dsim/batches ___________________________________________________________________ Modified: svn:ignore - .deps .libs Makefile.in Makefile dsim + .deps .libs Makefile.in Makefile simulate simulate.log Modified: trunk/dsim/dsim/batches/Makefile.am =================================================================== --- trunk/dsim/dsim/batches/Makefile.am 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/batches/Makefile.am 2010-02-07 02:41:42 UTC (rev 62) @@ -6,10 +6,12 @@ MAINTAINERCLEANFILES = Makefile.in + # Binaries (batches) -bin_PROGRAMS = +bin_PROGRAMS = simulate -#airinv_SOURCES = $(batches_h_sources) $(batches_cc_sources) -#airinv_CXXFLAGS = $(BOOST_CFLAGS) -#airinv_LDADD = -#airinv_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(top_builddir)/airinv/core/libairinv.la +simulate_SOURCES = $(batches_h_sources) $(batches_cc_sources) +simulate_CXXFLAGS = $(BOOST_CFLAGS) +simulate_LDADD = +simulate_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(SOCI_LIBS) \ + $(top_builddir)/dsim/core/libdsim.la Added: trunk/dsim/dsim/batches/simulate.cpp =================================================================== --- trunk/dsim/dsim/batches/simulate.cpp (rev 0) +++ trunk/dsim/dsim/batches/simulate.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,338 @@ +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <fstream> +#include <vector> +#include <string> +// Boost (Extended STL) +#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/date_time/gregorian/gregorian.hpp> +#include <boost/tokenizer.hpp> +#include <boost/program_options.hpp> +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> +#include <stdair/factory/FacBomContent.hpp> +#include <stdair/bom/AirlineFeatureSet.hpp> +#include <stdair/bom/AirlineFeature.hpp> +// DSIM +#include <dsim/DSIM_Service.hpp> +#include <dsim/config/dsim-paths.hpp> + +// //////// Type definitions /////// +typedef std::vector<std::string> WordList_T; + + +// //////// Constants ////// +/** Default name and location for the log file. */ +const std::string K_DSIM_DEFAULT_LOG_FILENAME ("simulate.log"); + +/** Default name and location for the (CSV) demand input file. */ +const std::string K_DSIM_DEFAULT_DEMAND_INPUT_FILENAME ("../../test/samples/demand01.csv"); + +/** Default name and location for the (CSV) schedule input file. */ +const std::string K_DSIM_DEFAULT_SCHEDULE_INPUT_FILENAME ("../../test/samples/schedule01.csv"); + +/** Default query string. */ +const std::string K_DSIM_DEFAULT_QUERY_STRING ("my good old query"); + +/** Default name and location for the Xapian database. */ +const std::string K_DSIM_DEFAULT_DB_USER ("dsim"); +const std::string K_DSIM_DEFAULT_DB_PASSWD ("dsim"); +const std::string K_DSIM_DEFAULT_DB_DBNAME ("dsim"); +const std::string K_DSIM_DEFAULT_DB_HOST ("localhost"); +const std::string K_DSIM_DEFAULT_DB_PORT ("3306"); + + +// ////////////////////////////////////////////////////////////////////// +void tokeniseStringIntoWordList (const std::string& iPhrase, + WordList_T& ioWordList) { + // Empty the word list + ioWordList.clear(); + + // Boost Tokeniser + typedef boost::tokenizer<boost::char_separator<char> > Tokeniser_T; + + // Define the separators + const boost::char_separator<char> lSepatorList(" .,;:|+-*/_=!@#$%`~^&(){}[]?'<>\""); + + // Initialise the phrase to be tokenised + Tokeniser_T lTokens (iPhrase, lSepatorList); + for (Tokeniser_T::const_iterator tok_iter = lTokens.begin(); + tok_iter != lTokens.end(); ++tok_iter) { + const std::string& lTerm = *tok_iter; + ioWordList.push_back (lTerm); + } + +} + +// ////////////////////////////////////////////////////////////////////// +std::string createStringFromWordList (const WordList_T& iWordList) { + std::ostringstream oStr; + + unsigned short idx = iWordList.size(); + for (WordList_T::const_iterator itWord = iWordList.begin(); + itWord != iWordList.end(); ++itWord, --idx) { + const std::string& lWord = *itWord; + oStr << lWord; + if (idx > 1) { + oStr << " "; + } + } + + return oStr.str(); +} + + +// ///////// Parsing of Options & Configuration ///////// +// A helper function to simplify the main part. +template<class T> std::ostream& operator<< (std::ostream& os, + const std::vector<T>& v) { + std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout, " ")); + return os; +} + +/** Early return status (so that it can be differentiated from an error). */ +const int K_DSIM_EARLY_RETURN_STATUS = 99; + +/** Read and parse the command line options. */ +int readConfiguration (int argc, char* argv[], + std::string& ioQueryString, + stdair::Filename_T& ioScheduleInputFilename, + stdair::Filename_T& ioDemandInputFilename, + std::string& ioLogFilename, + std::string& ioDBUser, std::string& ioDBPasswd, + std::string& ioDBHost, std::string& ioDBPort, + std::string& ioDBDBName) { + + // Initialise the travel query string, if that one is empty + if (ioQueryString.empty() == true) { + ioQueryString = K_DSIM_DEFAULT_QUERY_STRING; + } + + // Transform the query string into a list of words (STL strings) + WordList_T lWordList; + tokeniseStringIntoWordList (ioQueryString, lWordList); + + // Declare a group of options that will be allowed only on command line + boost::program_options::options_description generic ("Generic options"); + generic.add_options() + ("prefix", "print installation prefix") + ("version,v", "print version string") + ("help,h", "produce help message"); + + // Declare a group of options that will be allowed both on command + // line and in config file + boost::program_options::options_description config ("Configuration"); + config.add_options() + ("demand,d", + boost::program_options::value< std::string >(&ioScheduleInputFilename)->default_value(K_DSIM_DEFAULT_DEMAND_INPUT_FILENAME), + "(CVS) input file for the demand distributions") + ("schedule,s", + boost::program_options::value< std::string >(&ioDemandInputFilename)->default_value(K_DSIM_DEFAULT_SCHEDULE_INPUT_FILENAME), + "(CVS) input file for the schedules") + ("log,l", + boost::program_options::value< std::string >(&ioLogFilename)->default_value(K_DSIM_DEFAULT_LOG_FILENAME), + "Filepath for the logs") + ("user,u", + boost::program_options::value< std::string >(&ioDBUser)->default_value(K_DSIM_DEFAULT_DB_USER), + "SQL database hostname (e.g., dsim)") + ("passwd,p", + boost::program_options::value< std::string >(&ioDBPasswd)->default_value(K_DSIM_DEFAULT_DB_PASSWD), + "SQL database hostname (e.g., dsim)") + ("host,H", + boost::program_options::value< std::string >(&ioDBHost)->default_value(K_DSIM_DEFAULT_DB_HOST), + "SQL database hostname (e.g., localhost)") + ("port,P", + boost::program_options::value< std::string >(&ioDBPort)->default_value(K_DSIM_DEFAULT_DB_PORT), + "SQL database port (e.g., 3306)") + ("dbname,m", + boost::program_options::value< std::string >(&ioDBDBName)->default_value(K_DSIM_DEFAULT_DB_DBNAME), + "SQL database name (e.g., dsim)") + ("query,q", + boost::program_options::value< WordList_T >(&lWordList)->multitoken(), + "Query word list") + ; + + // Hidden options, will be allowed both on command line and + // in config file, but will not be shown to the user. + boost::program_options::options_description hidden ("Hidden options"); + hidden.add_options() + ("copyright", + boost::program_options::value< std::vector<std::string> >(), + "Show the copyright (license)"); + + boost::program_options::options_description cmdline_options; + cmdline_options.add(generic).add(config).add(hidden); + + boost::program_options::options_description config_file_options; + config_file_options.add(config).add(hidden); + + boost::program_options::options_description visible ("Allowed options"); + visible.add(generic).add(config); + + boost::program_options::positional_options_description p; + p.add ("copyright", -1); + + boost::program_options::variables_map vm; + boost::program_options:: + store (boost::program_options::command_line_parser (argc, argv). + options (cmdline_options).positional(p).run(), vm); + + std::ifstream ifs ("simulate.cfg"); + boost::program_options::store (parse_config_file (ifs, config_file_options), + vm); + boost::program_options::notify (vm); + + if (vm.count ("help")) { + std::cout << visible << std::endl; + return K_DSIM_EARLY_RETURN_STATUS; + } + + if (vm.count ("version")) { + std::cout << PACKAGE_NAME << ", version " << PACKAGE_VERSION << std::endl; + return K_DSIM_EARLY_RETURN_STATUS; + } + + if (vm.count ("prefix")) { + std::cout << "Installation prefix: " << PREFIXDIR << std::endl; + return K_DSIM_EARLY_RETURN_STATUS; + } + + if (vm.count ("schedule")) { + ioScheduleInputFilename = vm["schedule"].as< std::string >(); + std::cout << "Schedule input filename is: " << ioScheduleInputFilename + << std::endl; + } + + if (vm.count ("demand")) { + ioDemandInputFilename = vm["demand"].as< std::string >(); + std::cout << "Demand input filename is: " << ioDemandInputFilename + << std::endl; + } + + if (vm.count ("log")) { + ioLogFilename = vm["log"].as< std::string >(); + std::cout << "Log filename is: " << ioLogFilename << std::endl; + } + + if (vm.count ("user")) { + ioDBUser = vm["user"].as< std::string >(); + std::cout << "SQL database user name is: " << ioDBUser << std::endl; + } + + if (vm.count ("passwd")) { + ioDBPasswd = vm["passwd"].as< std::string >(); + //std::cout << "SQL database user password is: " << ioDBPasswd << std::endl; + } + + if (vm.count ("host")) { + ioDBHost = vm["host"].as< std::string >(); + std::cout << "SQL database host name is: " << ioDBHost << std::endl; + } + + if (vm.count ("port")) { + ioDBPort = vm["port"].as< std::string >(); + std::cout << "SQL database port number is: " << ioDBPort << std::endl; + } + + if (vm.count ("dbname")) { + ioDBDBName = vm["dbname"].as< std::string >(); + std::cout << "SQL database name is: " << ioDBDBName << std::endl; + } + + ioQueryString = createStringFromWordList (lWordList); + std::cout << "The query string is: " << ioQueryString << std::endl; + + return 0; +} + +// ///////// M A I N //////////// +int main (int argc, char* argv[]) { + + try { + + // Query + std::string lQuery; + + // Schedule input file name + stdair::Filename_T lScheduleInputFilename; + + // Demand input file name + stdair::Filename_T lDemandInputFilename; + + // Output log File + std::string lLogFilename; + + // SQL database parameters + std::string lDBUser; + std::string lDBPasswd; + std::string lDBHost; + std::string lDBPort; + std::string lDBDBName; + + // Airline code + stdair::AirlineCode_T lAirlineCode ("BA"); + + // Call the command-line option parser + const int lOptionParserStatus = + readConfiguration (argc, argv, lQuery, lScheduleInputFilename, + lDemandInputFilename, lLogFilename, + lDBUser, lDBPasswd, lDBHost, lDBPort, lDBDBName); + + if (lOptionParserStatus == K_DSIM_EARLY_RETURN_STATUS) { + return 0; + } + + // Set the database parameters + stdair::BasDBParams lDBParams (lDBUser, lDBPasswd, lDBHost, lDBPort, + lDBDBName); + + // Set the log parameters + std::ofstream logOutputFile; + // open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + // Initialise the set of required airline features + stdair::AirlineFeatureSet& lAirlineFeatureSet = + stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>(); + + // 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); + + // Initialise the simulation context + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + DSIM::DSIM_Service dsimService (lLogParams, lDBParams, + lScheduleInputFilename, + lDemandInputFilename); + + // Perform a simulation + dsimService.simulate(); + + // DEBUG + // Display the airlines stored in the database + dsimService.displayAirlineListFromDB(); + + } catch (const DSIM::RootException& otexp) { + std::cerr << "Standard exception: " << otexp.what() << std::endl; + return -1; + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return -1; + + } catch (...) { + return -1; + } + + return 0; +} + Modified: trunk/dsim/dsim/batches/sources.mk =================================================================== --- trunk/dsim/dsim/batches/sources.mk 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/batches/sources.mk 2010-02-07 02:41:42 UTC (rev 62) @@ -1,2 +1,2 @@ batches_h_sources = -batches_cc_sources = +batches_cc_sources = $(top_srcdir)/dsim/batches/simulate.cpp Added: trunk/dsim/dsim/command/DBManager.cpp =================================================================== --- trunk/dsim/dsim/command/DBManager.cpp (rev 0) +++ trunk/dsim/dsim/command/DBManager.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,166 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// SOCI +#include <soci/core/soci.h> +#include <soci/backends/mysql/soci-mysql.h> +// StdAir +#include <stdair/bom/AirlineStruct.hpp> +#include <stdair/dbadaptor/DbaAirline.hpp> +#include <stdair/service/Logger.hpp> +// Dsim +#include <dsim/command/DBManager.hpp> + +namespace DSIM { + + // ////////////////////////////////////////////////////////////////////// + void DBManager:: + prepareSelectStatement (stdair::DBSession_T& ioSociSession, + stdair::DBRequestStatement_T& ioSelectStatement, + stdair::AirlineStruct& ioAirline) { + + try { + + // Instanciate a SQL statement (no request is performed at that stage) + /** + select code, name + from airlines; + */ + + ioSelectStatement = (ioSociSession.prepare + << "select iata_code, name " + << "from airlines ", soci::into (ioAirline)); + + // Execute the SQL query + ioSelectStatement.execute(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + void DBManager:: + prepareSelectOnAirlineCodeStatement (stdair::DBSession_T& ioSociSession, + stdair::DBRequestStatement_T& ioSelectStatement, + const stdair::AirlineCode_T& iAirlineCode, + stdair::AirlineStruct& ioAirline) { + + try { + + // Instanciate a SQL statement (no request is performed at that stage) + /** + select code, name + from airlines + where code = iAirlineCode; + */ + + ioSelectStatement = (ioSociSession.prepare + << "select iata_code, name " + << "from airlines " + << "where iata_code = :airline_code ", + soci::into (ioAirline), soci::use (iAirlineCode)); + + // Execute the SQL query + ioSelectStatement.execute(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + bool DBManager::iterateOnStatement (stdair::DBRequestStatement_T& ioStatement, + stdair::AirlineStruct& ioAirline) { + bool hasStillData = false; + + try { + + // Retrieve the next row of Airline object + hasStillData = ioStatement.fetch(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + + return hasStillData; + } + + // ////////////////////////////////////////////////////////////////////// + void DBManager::updateAirlineInDB (stdair::DBSession_T& ioSociSession, + const stdair::AirlineStruct& iAirline) { + + try { + + // Begin a transaction on the database + ioSociSession.begin(); + + // Retrieve the airline code + const std::string& lAirlineCode = iAirline.getAirlineCode(); + + // Retrieve the airline name + const std::string& lAirlineName = iAirline.getAirlineName(); + + // Instanciate a SQL statement (no request is performed at that stage) + stdair::DBRequestStatement_T lUpdateStatement = + (ioSociSession.prepare + << "update airlines " + << "set name = :name " + << "where iata_code = :iata_code", + soci::use (lAirlineName), soci::use (lAirlineCode)); + + // Execute the SQL query + lUpdateStatement.execute (true); + + // Commit the transaction on the database + ioSociSession.commit(); + + // Debug + // STDAIR_LOG_DEBUG ("[" << lAirlineCode << "] " << iAirline); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + bool DBManager::retrieveAirline (stdair::DBSession_T& ioSociSession, + const stdair::AirlineCode_T& iAirlineCode, + stdair::AirlineStruct& ioAirline) { + bool oHasRetrievedAirline = false; + + try { + + // Prepare the SQL request corresponding to the select statement + stdair::DBRequestStatement_T lSelectStatement (ioSociSession); + DBManager::prepareSelectOnAirlineCodeStatement (ioSociSession, + lSelectStatement, + iAirlineCode, ioAirline); + const bool shouldDoReset = true; + bool hasStillData = iterateOnStatement (lSelectStatement, ioAirline); + if (hasStillData == true) { + oHasRetrievedAirline = true; + } + + // Sanity check + const bool shouldNotDoReset = false; + hasStillData = iterateOnStatement (lSelectStatement, ioAirline); + + // Debug + // STDAIR_LOG_DEBUG ("[" << iDocID << "] " << ioAirline); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + + return oHasRetrievedAirline; + } + +} Added: trunk/dsim/dsim/command/DBManager.hpp =================================================================== --- trunk/dsim/dsim/command/DBManager.hpp (rev 0) +++ trunk/dsim/dsim/command/DBManager.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,77 @@ +#ifndef __DSIM_CMD_DBMANAGER_HPP +#define __DSIM_CMD_DBMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +// Dsim +#include <dsim/DSIM_Types.hpp> + +namespace DSIM { + + // Forward declarations + struct AirlineStruct; + + /** Class building the Business Object Model (BOM) from data retrieved + from the database. */ + class DBManager { + public: + /** Update the fields of the database row + corresponding to the given BOM object. + @parameter stdair::DBSession_T& + @parameter stdair::AirlineStruct& . */ + static void updateAirlineInDB (stdair::DBSession_T&, + const stdair::AirlineStruct&); + + /** Retrieve, from the (MySQL) database, the row corresponding to + the given BOM code, and fill the given BOM object with that retrieved + data. + @parameter stdair::DBSession_T& + @parameter const stdair::AirlineCode_T& + @parameter stdair::AirlineStruct& . */ + static bool retrieveAirline (stdair::DBSession_T&, + const stdair::AirlineCode_T&, + stdair::AirlineStruct&); + + + public: + /** Prepare (parse and put in cache) the SQL statement. + @parameter stdair::DBSession_T& + @parameter stdair::DBRequestStatement_T& + @parameter stdair::AirlineStruct& . */ + static void prepareSelectStatement (stdair::DBSession_T&, + stdair::DBRequestStatement_T&, + stdair::AirlineStruct&); + + /** Iterate on the SQL statement. + <br>The SQL has to be already prepared. + @parameter stdair::DBRequestStatement_T& + @parameter stdair::AirlineStruct& . */ + static bool iterateOnStatement (stdair::DBRequestStatement_T&, + stdair::AirlineStruct&); + + + private: + /** Prepare (parse and put in cache) the SQL statement. + @parameter stdair::DBSession_T& + @parameter stdair::DBRequestStatement_T& + @parameter const stdair::AirlineCode_T& + @parameter stdair::AirlineStruct& */ + static void prepareSelectOnAirlineCodeStatement (stdair::DBSession_T&, + stdair::DBRequestStatement_T&, + const stdair::AirlineCode_T&, + stdair::AirlineStruct&); + + + private: + /** Constructors. */ + DBManager() {} + DBManager(const DBManager&) {} + /** Destructor. */ + ~DBManager() {} + }; + +} +#endif // __DSIM_CMD_DBMANAGER_HPP Modified: trunk/dsim/dsim/command/Makefile.am =================================================================== --- trunk/dsim/dsim/command/Makefile.am 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/command/Makefile.am 2010-02-07 02:41:42 UTC (rev 62) @@ -5,9 +5,9 @@ noinst_LTLIBRARIES= libcmd.la libcmd_la_SOURCES= $(cmd_h_sources) $(cmd_cc_sources) -libcmd_la_CXXFLAGS = $(BOOST_CFLAGS) +libcmd_la_CXXFLAGS = $(BOOST_CFLAGS) $(SOCI_CFLAGS) libcmd_la_LIBADD = -libcmd_la_LDFLAGS = $(BOOST_LIBS) \ +libcmd_la_LDFLAGS = $(BOOST_LIBS) $(SOCI_LIBS) \ $(top_builddir)/simcrs/core/libsimcrs.la \ $(top_builddir)/trademgen/core/libtrademgen.la Modified: trunk/dsim/dsim/command/sources.mk =================================================================== --- trunk/dsim/dsim/command/sources.mk 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/command/sources.mk 2010-02-07 02:41:42 UTC (rev 62) @@ -1,6 +1,8 @@ cmd_h_sources = \ $(top_srcdir)/dsim/command/CmdAbstract.hpp \ + $(top_srcdir)/dsim/command/DBManager.hpp \ $(top_srcdir)/dsim/command/Simulator.hpp cmd_cc_sources = \ $(top_srcdir)/dsim/command/CmdAbstract.cpp \ + $(top_srcdir)/dsim/command/DBManager.cpp \ $(top_srcdir)/dsim/command/Simulator.cpp \ No newline at end of file Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -4,24 +4,29 @@ // STL #include <cassert> #include <ostream> +// SOCI +#include <soci/core/soci.h> // StdAir #include <stdair/basic/BasChronometer.hpp> #include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/AirlineStruct.hpp> #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/service/DBSessionManager.hpp> #include <stdair/STDAIR_Service.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> -// TRADEMGEN +// TraDemGen #include <trademgen/TRADEMGEN_Service.hpp> #include <trademgen/DBParams.hpp> // Dsim #include <dsim/basic/BasConst_DSIM_Service.hpp> +#include <dsim/factory/FacDsimServiceContext.hpp> +#include <dsim/command/DBManager.hpp> #include <dsim/command/Simulator.hpp> -#include <dsim/factory/FacDsimServiceContext.hpp> #include <dsim/service/DSIM_ServiceContext.hpp> #include <dsim/DSIM_Service.hpp> @@ -38,31 +43,40 @@ } // ////////////////////////////////////////////////////////////////////// - DSIM_Service::DSIM_Service (const stdair::Filename_T& iScheduleInputFilename) + DSIM_Service::DSIM_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_ServicePtr, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename) : _dsimServiceContext (NULL) { // Initialise the service context initServiceContext (); + + // Retrieve the Trademgen service context + assert (_dsimServiceContext != NULL); + DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext; + + // Store the STDAIR service object within the (TRADEMGEN) service context + lDSIM_ServiceContext.setSTDAIR_Service (ioSTDAIR_ServicePtr); + // Initialise the context - //init (iScheduleInputFilename); - - assert (false); + init (iScheduleInputFilename, iDemandInputFilename); } // ////////////////////////////////////////////////////////////////////// DSIM_Service::DSIM_Service (const stdair::BasLogParams& iLogParams, - const stdair::Filename_T& iScheduleInputFilename) + const stdair::BasDBParams& iDBParams, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename) : _dsimServiceContext (NULL) { // Initialise the service context initServiceContext (); // Initialise the STDAIR service handler - stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = - initStdAirService (iLogParams); + initStdAirService (iLogParams, iDBParams); // Initialise the (remaining of the) context - init (lSTDAIR_Service_ptr, iScheduleInputFilename); + init (iScheduleInputFilename, iDemandInputFilename); } // ////////////////////////////////////////////////////////////////////// @@ -80,8 +94,8 @@ } // ////////////////////////////////////////////////////////////////////// - stdair::STDAIR_ServicePtr_T DSIM_Service:: - initStdAirService (const stdair::BasLogParams& iLogParams) { + void DSIM_Service::initStdAirService (const stdair::BasLogParams& iLogParams, + const stdair::BasDBParams& iDBParams) { // Retrieve the Dsim service context assert (_dsimServiceContext != NULL); @@ -90,13 +104,14 @@ // 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)); + stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = + stdair::STDAIR_ServicePtr_T (new stdair::STDAIR_Service (iLogParams, + iDBParams)); // 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(); + assert (lSTDAIR_Service_ptr != NULL); + stdair::BomRoot& lBomRoot = lSTDAIR_Service_ptr->getBomRoot(); // TODO: do not hardcode the initialisation of AirlineFeatureSet // Initialise the set of required airline features @@ -116,16 +131,22 @@ // Set the AirlineFeatureSet for the BomRoot. lBomRoot.setAirlineFeatureSet (&lAirlineFeatureSet); - return oSTDAIR_Service_ptr; + // Store the STDAIR service object within the (TRADEMGEN) service context + lDSIM_ServiceContext.setSTDAIR_Service (lSTDAIR_Service_ptr); } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::init (stdair::STDAIR_ServicePtr_T ioSTDAIR_ServicePtr, - const stdair::Filename_T& iScheduleInputFilename) { + void DSIM_Service::init (const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename) { // Retrieve the service context assert (_dsimServiceContext != NULL); DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext; + // Retrieve the StdAir service context + stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = + lDSIM_ServiceContext.getSTDAIR_Service(); + assert (lSTDAIR_Service_ptr != NULL); + // TODO: do not hardcode the CRS code (e.g., take it from a // configuration file). // Initialise the SIMCRS service handler @@ -135,20 +156,17 @@ // 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 (ioSTDAIR_ServicePtr, + SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (lSTDAIR_Service_ptr, lCRSCode, iScheduleInputFilename)); lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service); - // TODO: do not hardcode the stdair::BasDBParams. // TODO: do not hardcode the demand input file. // Initialise the TRADEMGEN service handler - const stdair::Filename_T lDemandInputFilename ("../../test/samples/demand01.csv"); - const stdair::BasDBParams lDBParams = - stdair::BasDBParams ("dsim", "dsim", "localhost", "3306", "dsim"); TRADEMGEN_ServicePtr_T lTRADEMGEN_Service = - TRADEMGEN_ServicePtr_T (new TRADEMGEN::TRADEMGEN_Service (ioSTDAIR_ServicePtr, - lDemandInputFilename)); + TRADEMGEN_ServicePtr_T (new TRADEMGEN:: + TRADEMGEN_Service (lSTDAIR_Service_ptr, + iDemandInputFilename)); lDSIM_ServiceContext.setTRADEMGEN_Service (lTRADEMGEN_Service); } @@ -191,4 +209,62 @@ } } + // ////////////////////////////////////////////////////////////////////// + void DSIM_Service::displayAirlineListFromDB () { + if (_dsimServiceContext == NULL) { + throw NonInitialisedServiceException(); + } + assert (_dsimServiceContext != NULL); + DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext; + + // Get the date-time for the present time + boost::posix_time::ptime lNowDateTime = + boost::posix_time::second_clock::local_time(); + boost::gregorian::date lNowDate = lNowDateTime.date(); + + // DEBUG + STDAIR_LOG_DEBUG (std::endl + << "===================================================" + << std::endl + << lNowDateTime); + + try { + + // Delegate the query execution to the dedicated command + stdair::BasChronometer lDsimChronometer; + lDsimChronometer.start(); + + // Retrieve the database session handler + stdair::DBSession_T& lDBSession = + stdair::DBSessionManager::instance().getDBSession(); + + // Prepare and execute the select statement + stdair::AirlineStruct lAirline; + stdair::DBRequestStatement_T lSelectStatement (lDBSession); + DBManager::prepareSelectStatement(lDBSession, lSelectStatement, lAirline); + + // Prepare the SQL request corresponding to the select statement + bool hasStillData = true; + unsigned int idx = 0; + while (hasStillData == true) { + hasStillData = DBManager::iterateOnStatement (lSelectStatement, + lAirline); + // DEBUG + STDAIR_LOG_DEBUG ("[" << idx << "]: " << lAirline); + + // Iteration + ++idx; + } + + const double lDsimMeasure = lDsimChronometer.elapsed(); + + // DEBUG + STDAIR_LOG_DEBUG ("Sample service for Dsim: " << lDsimMeasure); + + } catch (const std::exception& error) { + STDAIR_LOG_ERROR ("Exception: " << error.what()); + throw SimulationException(); + } + } + } Modified: trunk/dsim/dsim/service/DSIM_ServiceContext.hpp =================================================================== --- trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -8,6 +8,8 @@ #include <string> // Boost #include <boost/shared_ptr.hpp> +// StdAir +#include <stdair/STDAIR_Types.hpp> // Dsim #include <dsim/DSIM_Types.hpp> #include <dsim/bom/ConfigurationParameters.hpp> @@ -36,6 +38,11 @@ friend class FacDsimServiceContext; public: // ///////// Getters ////////// + /** Get the pointer on the STDAIR service handler. */ + stdair::STDAIR_ServicePtr_T getSTDAIR_Service () const { + return _stdairService; + } + /** Get the simulator ID. */ const SimulatorID_T& getSimulatorID () const { return _simulatorID; @@ -62,6 +69,11 @@ } // ///////// Setters ////////// + /** Set the pointer on the STDAIR service handler. */ + void setSTDAIR_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_ServicePtr) { + _stdairService = ioSTDAIR_ServicePtr; + } + /** Set the simulator ID. */ void setSimulatorID (const SimulatorID_T& iSimulatorID) { _simulatorID = iSimulatorID; @@ -106,6 +118,8 @@ private: // ///////////// Children //////////// + /** Standard Airline (StdAir) Service Handler. */ + stdair::STDAIR_ServicePtr_T _stdairService; /** CRS Service Handler. */ SIMCRS_ServicePtr_T _simcrsService; /** TRADEMGEN Service Handler. */ Property changes on: trunk/dsim/test/dsim ___________________________________________________________________ Modified: svn:ignore - .deps .libs Makefile.in Makefile simulate simulate.log + .deps .libs Makefile.in Makefile simulate simulate.log SimulationTestSuite SimulationTestSuite_results.xml Modified: trunk/dsim/test/dsim/Makefile.am =================================================================== --- trunk/dsim/test/dsim/Makefile.am 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/test/dsim/Makefile.am 2010-02-07 02:41:42 UTC (rev 62) @@ -1,4 +1,4 @@ -## test sub-directory +## test/dsim sub-directory include $(top_srcdir)/Makefile.common MAINTAINERCLEANFILES = Makefile.in @@ -9,20 +9,19 @@ EXTRA_DIST = ## -check_PROGRAMS = simulate +check_PROGRAMS = SimulationTestSuite TESTS = $(check_PROGRAMS) XFAIL_TESTS = # -#SimulationTestSuite_SOURCES = SimulationTestSuite.hpp \ - SimulationTestSuite.cpp -#SimulationTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) -#SimulationTestSuite_LDADD = $(top_builddir)/test/com/libcppunitcore.la -#SimulationTestSuite_LDFLAGS = \ -# $(BOOST_LIBS) $(CPPUNIT_LIBS) \ -# $(top_builddir)/dsim/libdsim.la - -simulate_SOURCES = simulate.cpp -simulate_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) -simulate_LDADD = -simulate_LDFLAGS = $(BOOST_LIBS) \ +SimulationTestSuite_SOURCES = SimulationTestSuite.hpp SimulationTestSuite.cpp +SimulationTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) +SimulationTestSuite_LDADD = +SimulationTestSuite_LDFLAGS = \ + $(BOOST_LIBS) $(CPPUNIT_LIBS) \ + $(top_builddir)/extracppunit/libextracc-extracppunit.la \ $(top_builddir)/dsim/core/libdsim.la + +#simulate_SOURCES = simulate.cpp +#simulate_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) +#simulate_LDADD = +#simulate_LDFLAGS = $(BOOST_LIBS) $(top_builddir)/dsim/core/libdsim.la Added: trunk/dsim/test/dsim/SimulationTestSuite.cpp =================================================================== --- trunk/dsim/test/dsim/SimulationTestSuite.cpp (rev 0) +++ trunk/dsim/test/dsim/SimulationTestSuite.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,83 @@ +// STL +#include <sstream> +#include <fstream> +#include <string> +// CPPUNIT +#include <extracppunit/CppUnitCore.hpp> +// StdAir +#include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> +// Dsim +#include <dsim/DSIM_Types.hpp> +#include <dsim/DSIM_Service.hpp> +// Dsim Test Suite +#include <test/dsim/SimulationTestSuite.hpp> + +// ////////////////////////////////////////////////////////////////////// +// Test is based on ... +// ////////////////////////////////////////////////////////////////////// + +// ////////////////////////////////////////////////////////////////////// +void SimulationTestSuite::simpleSimulationHelper() { + + try { + + // Schedule input file name + const std::string lScheduleInputFilename ("../samples/schedule01.csv"); + + // Demand input file name + const stdair::Filename_T lDemandInputFilename ("../samples/demand01.csv"); + + // Output log File + const std::string lLogFilename ("simulate.log"); + + // Set the log parameters + std::ofstream logOutputFile; + // Open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + // Initialise the simulation context + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + const stdair::BasDBParams lDBParams ("dsim", "dsim", "localhost", "3306", + "dsim"); + DSIM::DSIM_Service dsimService (lLogParams, lDBParams, + lScheduleInputFilename, + lDemandInputFilename); + + // Perform a simulation + dsimService.simulate(); + + } catch (const DSIM::RootException& otexp) { + std::cerr << "Standard exception: " << otexp.what() << std::endl; + return; + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return; + + } catch (...) { + return; + } + +} + +// ////////////////////////////////////////////////////////////////////// +void SimulationTestSuite::simpleSimulation () { + // TODO: Check that the simulation goes as expected + CPPUNIT_ASSERT_NO_THROW ( simpleSimulationHelper();); +} + +// ////////////////////////////////////////////////////////////////////// +// void SimulationTestSuite::errorCase () { +// CPPUNIT_ASSERT (false); +// } + +// ////////////////////////////////////////////////////////////////////// +SimulationTestSuite::SimulationTestSuite () { + _describeKey << "Running test on simulation"; +} + +// /////////////// M A I N ///////////////// +CPPUNIT_MAIN() + Added: trunk/dsim/test/dsim/SimulationTestSuite.hpp =================================================================== --- trunk/dsim/test/dsim/SimulationTestSuite.hpp (rev 0) +++ trunk/dsim/test/dsim/SimulationTestSuite.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,31 @@ +// STL +#include <iosfwd> +// CPPUNIT +#include <cppunit/extensions/HelperMacros.h> + +/** Utility class for CPPUnit-based testing. */ +class SimulationTestSuite : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE (SimulationTestSuite); + CPPUNIT_TEST (simpleSimulation); + // CPPUNIT_TEST (errorCase); + CPPUNIT_TEST_SUITE_END (); +public: + + /** Test a simple simulation functionality. */ + void simpleSimulation(); + + /** Test some error detection functionalities. */ + // void errorCase (); + + /** Constructor. */ + SimulationTestSuite (); + +private: + /** Test a simple simulation functionality. */ + void simpleSimulationHelper(); + +protected: + std::stringstream _describeKey; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION (SimulationTestSuite); Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/test/dsim/simulate.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -4,6 +4,10 @@ #include <sstream> #include <fstream> #include <string> +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> // DSIM #include <dsim/DSIM_Service.hpp> #include <dsim/config/dsim-paths.hpp> @@ -11,11 +15,16 @@ // ///////// M A I N //////////// int main (int argc, char* argv[]) { + try { + // Schedule input file name - std::string lScheduleInputFilename ("../samples/schedule01.csv"); + const std::string lScheduleInputFilename ("../samples/schedule01.csv"); + // Demand input file name + const stdair::Filename_T lDemandInputFilename ("../samples/demand01.csv"); + // Output log File - std::string lLogFilename ("simulate.log"); + const std::string lLogFilename ("simulate.log"); // Set the log parameters std::ofstream logOutputFile; @@ -23,13 +32,29 @@ logOutputFile.open (lLogFilename.c_str()); logOutputFile.clear(); - // Initialise the list of classes/buckets + // Initialise the simulation context const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); - DSIM::DSIM_Service dsimService (lLogParams, lScheduleInputFilename); + const stdair::BasDBParams lDBParams ("dsim", "dsim", "localhost", "3306", + "dsim"); + DSIM::DSIM_Service dsimService (lLogParams, lDBParams, + lScheduleInputFilename, + lDemandInputFilename); // Perform a simulation dsimService.simulate(); + } catch (const DSIM::RootException& otexp) { + std::cerr << "Standard exception: " << otexp.what() << std::endl; + return -1; + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return -1; + + } catch (...) { + return -1; + } + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-06 17:58:50
|
Revision: 61 http://dsim.svn.sourceforge.net/dsim/?rev=61&view=rev Author: denis_arnaud Date: 2010-02-06 17:58:43 +0000 (Sat, 06 Feb 2010) Log Message: ----------- [DB] Added support for database management (still a little work to do). Modified Paths: -------------- trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/test/dsim/simulate.cpp Property Changed: ---------------- trunk/dsim/ Property changes on: trunk/dsim ___________________________________________________________________ Modified: svn:externals - config https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/trademgen airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/airsched avlcal https://avlcal.svn.sourceforge.net/svnroot/avlcal/trunk/avlcal/avlcal airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/airinv simfqt https://simfqt.svn.sourceforge.net/svnroot/simfqt/trunk/simfqt/simfqt simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/simcrs rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/rmol travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/travelccm extracppunit https://extracc.svn.sourceforge.net/svnroot/extracc/trunk/extracc/extracppunit + config https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config db https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/db stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/trademgen airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/airsched avlcal https://avlcal.svn.sourceforge.net/svnroot/avlcal/trunk/avlcal/avlcal airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/airinv simfqt https://simfqt.svn.sourceforge.net/svnroot/simfqt/trunk/simfqt/simfqt simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/simcrs rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/rmol travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/travelccm extracppunit https://extracc.svn.sourceforge.net/svnroot/extracc/trunk/extracc/extracppunit Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-03 16:28:56 UTC (rev 60) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-06 17:58:43 UTC (rev 61) @@ -140,15 +140,16 @@ iScheduleInputFilename)); lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service); - // TODO: do not hardcode the DBParams. + // TODO: do not hardcode the stdair::BasDBParams. + // TODO: do not hardcode the demand input file. // Initialise the TRADEMGEN service handler - const TRADEMGEN::DBParams lDBParams = - TRADEMGEN::DBParams ("anguyen", "anguyen", "ncemysqlp.nce.amadeus.net", - "3321", "sim_anguyen"); + const stdair::Filename_T lDemandInputFilename ("../../test/samples/demand01.csv"); + const stdair::BasDBParams lDBParams = + stdair::BasDBParams ("dsim", "dsim", "localhost", "3306", "dsim"); TRADEMGEN_ServicePtr_T lTRADEMGEN_Service = - TRADEMGEN_ServicePtr_T (new TRADEMGEN::TRADEMGEN_Service (lDBParams)); + TRADEMGEN_ServicePtr_T (new TRADEMGEN::TRADEMGEN_Service (ioSTDAIR_ServicePtr, + lDemandInputFilename)); lDSIM_ServiceContext.setTRADEMGEN_Service (lTRADEMGEN_Service); - } // ////////////////////////////////////////////////////////////////////// Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2010-02-03 16:28:56 UTC (rev 60) +++ trunk/dsim/test/dsim/simulate.cpp 2010-02-06 17:58:43 UTC (rev 61) @@ -11,8 +11,6 @@ // ///////// M A I N //////////// int main (int argc, char* argv[]) { - try { - // Schedule input file name std::string lScheduleInputFilename ("../samples/schedule01.csv"); @@ -32,13 +30,6 @@ // Perform a simulation dsimService.simulate(); - } catch (const std::exception& stde) { - std::cerr << "Standard exception: " << stde.what() << std::endl; - return -1; - - } catch (...) { - return -1; - } - return 0; } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-03 16:29:34
|
Revision: 60 http://dsim.svn.sourceforge.net/dsim/?rev=60&view=rev Author: quannaus Date: 2010-02-03 16:28:56 +0000 (Wed, 03 Feb 2010) Log Message: ----------- [dev] Integrated TRADEMGEN service into DSIM. Modified Paths: -------------- trunk/dsim/dsim/command/Makefile.am trunk/dsim/dsim/command/Simulator.cpp trunk/dsim/dsim/command/Simulator.hpp trunk/dsim/dsim/core/Makefile.am trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/dsim/service/DSIM_ServiceContext.hpp Modified: trunk/dsim/dsim/command/Makefile.am =================================================================== --- trunk/dsim/dsim/command/Makefile.am 2010-02-03 14:57:56 UTC (rev 59) +++ trunk/dsim/dsim/command/Makefile.am 2010-02-03 16:28:56 UTC (rev 60) @@ -8,7 +8,8 @@ libcmd_la_CXXFLAGS = $(BOOST_CFLAGS) libcmd_la_LIBADD = libcmd_la_LDFLAGS = $(BOOST_LIBS) \ - $(top_builddir)/simcrs/core/libsimcrs.la + $(top_builddir)/simcrs/core/libsimcrs.la \ + $(top_builddir)/trademgen/core/libtrademgen.la #pkgincludedir = $(includedir)/@PACKAGE@/command Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-02-03 14:57:56 UTC (rev 59) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-02-03 16:28:56 UTC (rev 60) @@ -14,6 +14,8 @@ #include <stdair/service/Logger.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> +// TRADEMGEN +#include <trademgen/TRADEMGEN_Service.hpp> // Airsched #include <airsched/AIRSCHED_Service.hpp> // Dsim @@ -23,30 +25,18 @@ namespace DSIM { // //////////////////////////////////////////////////////////////////// - void Simulator::simulate (SIMCRS::SIMCRS_Service& ioSIMCRS_Service) { + void Simulator::simulate (SIMCRS::SIMCRS_Service& ioSIMCRS_Service, + TRADEMGEN::TRADEMGEN_Service& ioTRADEMGEN_Service) { try { // DEBUG STDAIR_LOG_DEBUG ("The simulation is starting"); - // TODO: remove this hardcoded section - // Hardcode a booking request in order to simulate a sale. - // Departure airport code - stdair::AirportCode_T lOrigin ("LHR"); - // Arrival airport code - stdair::AirportCode_T lDestination ("JFK"); - // Departure date - stdair::Date_T lDepartureDate (2010, 01, 19); - // Passenger type - stdair::PassengerType_T lPaxType ("L"); - // Number of passengers in the travelling group - stdair::NbOfSeats_T lPartySize = 5; - // Booking request - stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination, - lDepartureDate, - lPaxType, lPartySize); - + // Generate a booking request. + stdair::BookingRequestStruct lBookingRequest = + ioTRADEMGEN_Service.generateBookingRequest (); + // Play booking request playBookingRequest (ioSIMCRS_Service, lBookingRequest); Modified: trunk/dsim/dsim/command/Simulator.hpp =================================================================== --- trunk/dsim/dsim/command/Simulator.hpp 2010-02-03 14:57:56 UTC (rev 59) +++ trunk/dsim/dsim/command/Simulator.hpp 2010-02-03 16:28:56 UTC (rev 60) @@ -16,6 +16,10 @@ class SIMCRS_Service; } +namespace TRADEMGEN { + class TRADEMGEN_Service; +} + namespace DSIM { /** Class wrapping the simulation methods. */ @@ -24,7 +28,7 @@ private: /** Perform a simulation. */ - static void simulate (SIMCRS::SIMCRS_Service&); + static void simulate (SIMCRS::SIMCRS_Service&,TRADEMGEN::TRADEMGEN_Service&); /** Play a booking request event. */ static void playBookingRequest (SIMCRS::SIMCRS_Service&, Modified: trunk/dsim/dsim/core/Makefile.am =================================================================== --- trunk/dsim/dsim/core/Makefile.am 2010-02-03 14:57:56 UTC (rev 59) +++ trunk/dsim/dsim/core/Makefile.am 2010-02-03 16:28:56 UTC (rev 60) @@ -24,4 +24,5 @@ $(top_builddir)/stdair/core/libstdair.la \ $(top_builddir)/airsched/core/libairsched.la \ $(top_builddir)/simcrs/core/libsimcrs.la \ + $(top_builddir)/trademgen/core/libtrademgen.la \ -version-info $(GENERIC_LIBRARY_VERSION) Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-03 14:57:56 UTC (rev 59) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-03 16:28:56 UTC (rev 60) @@ -15,6 +15,9 @@ #include <stdair/STDAIR_Service.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> +// TRADEMGEN +#include <trademgen/TRADEMGEN_Service.hpp> +#include <trademgen/DBParams.hpp> // Dsim #include <dsim/basic/BasConst_DSIM_Service.hpp> #include <dsim/command/Simulator.hpp> @@ -136,6 +139,16 @@ lCRSCode, iScheduleInputFilename)); lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service); + + // TODO: do not hardcode the DBParams. + // Initialise the TRADEMGEN service handler + const TRADEMGEN::DBParams lDBParams = + TRADEMGEN::DBParams ("anguyen", "anguyen", "ncemysqlp.nce.amadeus.net", + "3321", "sim_anguyen"); + TRADEMGEN_ServicePtr_T lTRADEMGEN_Service = + TRADEMGEN_ServicePtr_T (new TRADEMGEN::TRADEMGEN_Service (lDBParams)); + lDSIM_ServiceContext.setTRADEMGEN_Service (lTRADEMGEN_Service); + } // ////////////////////////////////////////////////////////////////////// @@ -157,11 +170,14 @@ // Get a reference on the SIMCRS service handler SIMCRS::SIMCRS_Service& lSIMCRS_Service = lDSIM_ServiceContext.getSIMCRS_Service(); + // Get a reference on the TRADEMGEN service handler + TRADEMGEN::TRADEMGEN_Service& lTRADEMGEN_Service = + lDSIM_ServiceContext.getTRADEMGEN_Service(); // Delegate the booking to the dedicated command stdair::BasChronometer lSimulationChronometer; lSimulationChronometer.start(); - Simulator::simulate (lSIMCRS_Service); + Simulator::simulate (lSIMCRS_Service, lTRADEMGEN_Service); const double lSimulationMeasure = lSimulationChronometer.elapsed(); // DEBUG Modified: trunk/dsim/dsim/service/DSIM_ServiceContext.hpp =================================================================== --- trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2010-02-03 14:57:56 UTC (rev 59) +++ trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2010-02-03 16:28:56 UTC (rev 60) @@ -18,11 +18,17 @@ namespace SIMCRS { class SIMCRS_Service; } +namespace TRADEMGEN { + class TRADEMGEN_Service; +} /** Pointer on the SIMCRS Service handler. */ typedef boost::shared_ptr<SIMCRS::SIMCRS_Service> SIMCRS_ServicePtr_T; +/** Pointer on the TRADEMGEN Service handler. */ +typedef boost::shared_ptr<TRADEMGEN::TRADEMGEN_Service> TRADEMGEN_ServicePtr_T; + namespace DSIM { /** Class holding the context of the Dsim services. */ @@ -50,6 +56,11 @@ return *_simcrsService.get(); } + /** Get a reference on the TRADEMGEN service handler. */ + TRADEMGEN::TRADEMGEN_Service& getTRADEMGEN_Service () const { + return *_trademgenService.get(); + } + // ///////// Setters ////////// /** Set the simulator ID. */ void setSimulatorID (const SimulatorID_T& iSimulatorID) { @@ -71,6 +82,11 @@ _simcrsService = ioSIMCRS_ServicePtr; } + /** Set the pointer on the TRADEMGEN service handler. */ + void setTRADEMGEN_Service (TRADEMGEN_ServicePtr_T ioTRADEMGEN_ServicePtr) { + _trademgenService = ioTRADEMGEN_ServicePtr; + } + // ///////// Display Methods ////////// /** Display the short DSIM_ServiceContext content. */ const std::string shortDisplay() const; @@ -92,6 +108,8 @@ // ///////////// Children //////////// /** CRS Service Handler. */ SIMCRS_ServicePtr_T _simcrsService; + /** TRADEMGEN Service Handler. */ + TRADEMGEN_ServicePtr_T _trademgenService; private: // //////////// Attributes ////////////////// This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-03 14:58:09
|
Revision: 59 http://dsim.svn.sourceforge.net/dsim/?rev=59&view=rev Author: quannaus Date: 2010-02-03 14:57:56 +0000 (Wed, 03 Feb 2010) Log Message: ----------- [dev] Implemented a sale. Modified Paths: -------------- trunk/dsim/dsim/command/Simulator.cpp Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-01-29 16:02:46 UTC (rev 58) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-02-03 14:57:56 UTC (rev 59) @@ -10,6 +10,7 @@ #include <stdair/STDAIR_Types.hpp> #include <stdair/bom/OutboundPathTypes.hpp> #include <stdair/bom/BookingRequestStruct.hpp> +#include <stdair/bom/TravelSolutionStruct.hpp> #include <stdair/service/Logger.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> @@ -64,19 +65,24 @@ const stdair::BookingRequestStruct& iBookingRequest) { // Retrieve a list of travel solutions corresponding the given // booking request. - stdair::OutboundPathLightList_T lOutboundPathList = + stdair::TravelSolutionList_T lTravelSolutionList = ioSIMCRS_Service.getTravelSolutions (iBookingRequest); // Hardcode a travel solution choice. - if (lOutboundPathList.empty() == false) { - stdair::OutboundPath* lChosenTravelSolution_ptr = lOutboundPathList.at(0); - + if (lTravelSolutionList.empty() == false) { + // DEBUG + STDAIR_LOG_DEBUG ("A travel solution is chosen."); + + stdair::TravelSolutionStruct lChosenTravelSolution = + lTravelSolutionList.at(0); // Get the number of seats in the request. const stdair::NbOfSeats_T& lNbOfSeats = iBookingRequest.getPartySize(); + // Make a sale. + ioSIMCRS_Service.sell (lChosenTravelSolution, lNbOfSeats); - // Make a sale. - assert (lChosenTravelSolution_ptr != NULL); - ioSIMCRS_Service.sell (*lChosenTravelSolution_ptr, lNbOfSeats); + } else { + // DEBUG + STDAIR_LOG_DEBUG ("No travel solution is chosen."); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <den...@us...> - 2010-01-29 15:59:39
|
Revision: 57 http://dsim.svn.sourceforge.net/dsim/?rev=57&view=rev Author: denis_arnaud Date: 2010-01-29 15:59:32 +0000 (Fri, 29 Jan 2010) Log Message: ----------- [Test] Added test on Boost.SmartPointers. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/boost/Makefile.am Added Paths: ----------- trunk/dsim/test/boost/smart_pointers/ trunk/dsim/test/boost/smart_pointers/Makefile.am trunk/dsim/test/boost/smart_pointers/reference_lost.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-01-28 19:38:14 UTC (rev 56) +++ trunk/dsim/configure.ac 2010-01-29 15:59:32 UTC (rev 57) @@ -507,6 +507,7 @@ test/boost/spirit/Makefile test/boost/serialization/Makefile test/boost/signals/Makefile + test/boost/smart_pointers/Makefile test/stdair/Makefile test/trademgen/Makefile test/airsched/Makefile Modified: trunk/dsim/test/boost/Makefile.am =================================================================== --- trunk/dsim/test/boost/Makefile.am 2010-01-28 19:38:14 UTC (rev 56) +++ trunk/dsim/test/boost/Makefile.am 2010-01-29 15:59:32 UTC (rev 57) @@ -5,6 +5,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit +SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit \ + smart_pointers EXTRA_DIST = Property changes on: trunk/dsim/test/boost/smart_pointers ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile reference_lost Copied: trunk/dsim/test/boost/smart_pointers/Makefile.am (from rev 56, trunk/dsim/test/boost/filesystem/Makefile.am) =================================================================== --- trunk/dsim/test/boost/smart_pointers/Makefile.am (rev 0) +++ trunk/dsim/test/boost/smart_pointers/Makefile.am 2010-01-29 15:59:32 UTC (rev 57) @@ -0,0 +1,19 @@ +## test/boost/smart_pointers sub-directory +include $(top_srcdir)/Makefile.common + +# +MAINTAINERCLEANFILES = Makefile.in + +# +SUBDIRS = + +EXTRA_DIST = + +# +check_PROGRAMS = reference_lost + +# +reference_lost_SOURCES = reference_lost.cpp +reference_lost_CXXFLAGS = $(BOOST_CFLAGS) +reference_lost_LDADD = +reference_lost_LDFLAGS = $(BOOST_LIBS) Copied: trunk/dsim/test/boost/smart_pointers/reference_lost.cpp (from rev 56, trunk/dsim/test/boost/filesystem/simple_ls.cpp) =================================================================== --- trunk/dsim/test/boost/smart_pointers/reference_lost.cpp (rev 0) +++ trunk/dsim/test/boost/smart_pointers/reference_lost.cpp 2010-01-29 15:59:32 UTC (rev 57) @@ -0,0 +1,53 @@ +// STL +#include <cassert> +#include <iostream> +// Boost +#include <boost/shared_ptr.hpp> + +/** Simple object. */ +class Object { +public: + Object() { + std::cout << "Object constructor" << std::endl; + } + Object(const Object&) { + std::cout << "Object copy constructor" << std::endl; + } + ~Object() { + std::cout << "Object destructor" << std::endl; + } + void display() const { + std::cout << "Description: " << _description << std::endl; + } + +private: + /** Description. */ + std::string _description; +}; + + +/** Pointer on the STDAIR Service handler. */ +typedef boost::shared_ptr<Object> ObjectPtr_T; + + +// ////////////////////// M A I N /////////////////////// +int main (int argc, char* argv[]) { + + Object* lObject_ptr = new Object; + assert (lObject_ptr != NULL); + Object& lObject = *lObject_ptr; + + std::cout << "The reference is good?" << std::endl; + lObject.display(); + std::cout << "Yes, the reference is good!" << std::endl; + + { + ObjectPtr_T lObjectSmartPtr = ObjectPtr_T (lObject_ptr); + } + + std::cout << "The reference is still good?" << std::endl; + lObject.display(); + std::cout << "Yes, the reference is still good!" << std::endl; + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-28 19:38:20
|
Revision: 56 http://dsim.svn.sourceforge.net/dsim/?rev=56&view=rev Author: denis_arnaud Date: 2010-01-28 19:38:14 +0000 (Thu, 28 Jan 2010) Log Message: ----------- [DSIM] Check that the pointer on OutboundPath object is not NULL. Modified Paths: -------------- trunk/dsim/dsim/command/Simulator.cpp Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-01-28 15:53:26 UTC (rev 55) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-01-28 19:38:14 UTC (rev 56) @@ -75,8 +75,10 @@ const stdair::NbOfSeats_T& lNbOfSeats = iBookingRequest.getPartySize(); // Make a sale. + assert (lChosenTravelSolution_ptr != NULL); ioSIMCRS_Service.sell (*lChosenTravelSolution_ptr, lNbOfSeats); } } } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-01-28 15:53:35
|
Revision: 55 http://dsim.svn.sourceforge.net/dsim/?rev=55&view=rev Author: quannaus Date: 2010-01-28 15:53:26 +0000 (Thu, 28 Jan 2010) Log Message: ----------- [Dev] Implementing the sale. Modified Paths: -------------- trunk/dsim/dsim/command/Simulator.cpp trunk/dsim/dsim/command/Simulator.hpp Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-01-26 15:14:31 UTC (rev 54) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-01-28 15:53:26 UTC (rev 55) @@ -8,10 +8,13 @@ #include <exception> // StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/OutboundPathTypes.hpp> #include <stdair/bom/BookingRequestStruct.hpp> #include <stdair/service/Logger.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> +// Airsched +#include <airsched/AIRSCHED_Service.hpp> // Dsim #include <dsim/DSIM_Types.hpp> #include <dsim/command/Simulator.hpp> @@ -37,14 +40,14 @@ // Passenger type stdair::PassengerType_T lPaxType ("L"); // Number of passengers in the travelling group - stdair::PartySize_T lPartySize = 5; + stdair::NbOfSeats_T lPartySize = 5; // Booking request stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination, lDepartureDate, lPaxType, lPartySize); // Play booking request - playBookingRequest (lBookingRequest); + playBookingRequest (ioSIMCRS_Service, lBookingRequest); // DEBUG STDAIR_LOG_DEBUG ("The simulation has ended"); @@ -57,8 +60,23 @@ // //////////////////////////////////////////////////////////////////// void Simulator:: - playBookingRequest (const stdair::BookingRequestStruct& iBookingRequest) { - + playBookingRequest (SIMCRS::SIMCRS_Service& ioSIMCRS_Service, + const stdair::BookingRequestStruct& iBookingRequest) { + // Retrieve a list of travel solutions corresponding the given + // booking request. + stdair::OutboundPathLightList_T lOutboundPathList = + ioSIMCRS_Service.getTravelSolutions (iBookingRequest); + + // Hardcode a travel solution choice. + if (lOutboundPathList.empty() == false) { + stdair::OutboundPath* lChosenTravelSolution_ptr = lOutboundPathList.at(0); + + // Get the number of seats in the request. + const stdair::NbOfSeats_T& lNbOfSeats = iBookingRequest.getPartySize(); + + // Make a sale. + ioSIMCRS_Service.sell (*lChosenTravelSolution_ptr, lNbOfSeats); + } } } Modified: trunk/dsim/dsim/command/Simulator.hpp =================================================================== --- trunk/dsim/dsim/command/Simulator.hpp 2010-01-26 15:14:31 UTC (rev 54) +++ trunk/dsim/dsim/command/Simulator.hpp 2010-01-28 15:53:26 UTC (rev 55) @@ -27,7 +27,8 @@ static void simulate (SIMCRS::SIMCRS_Service&); /** Play a booking request event. */ - static void playBookingRequest (const stdair::BookingRequestStruct&); + static void playBookingRequest (SIMCRS::SIMCRS_Service&, + const stdair::BookingRequestStruct&); private: /** Constructors. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-01-26 15:14:37
|
Revision: 54 http://dsim.svn.sourceforge.net/dsim/?rev=54&view=rev Author: quannaus Date: 2010-01-26 15:14:31 +0000 (Tue, 26 Jan 2010) Log Message: ----------- [Dev] Added a hardcoded booking request event in the simulation. Modified Paths: -------------- trunk/dsim/dsim/command/Simulator.cpp trunk/dsim/dsim/command/Simulator.hpp Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-01-21 19:32:31 UTC (rev 53) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-01-26 15:14:31 UTC (rev 54) @@ -8,6 +8,7 @@ #include <exception> // StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/BookingRequestStruct.hpp> #include <stdair/service/Logger.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> @@ -17,7 +18,7 @@ namespace DSIM { - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// void Simulator::simulate (SIMCRS::SIMCRS_Service& ioSIMCRS_Service) { try { @@ -25,15 +26,26 @@ // DEBUG STDAIR_LOG_DEBUG ("The simulation is starting"); - // Airline code - stdair::AirlineCode_T lAirlineCode ("BA"); - + // TODO: remove this hardcoded section + // Hardcode a booking request in order to simulate a sale. + // Departure airport code + stdair::AirportCode_T lOrigin ("LHR"); + // Arrival airport code + stdair::AirportCode_T lDestination ("JFK"); + // Departure date + stdair::Date_T lDepartureDate (2010, 01, 19); + // Passenger type + stdair::PassengerType_T lPaxType ("L"); // Number of passengers in the travelling group stdair::PartySize_T lPartySize = 5; - - // Make a booking - ioSIMCRS_Service.sell (lAirlineCode, lPartySize); - + // Booking request + stdair::BookingRequestStruct lBookingRequest (lOrigin, lDestination, + lDepartureDate, + lPaxType, lPartySize); + + // Play booking request + playBookingRequest (lBookingRequest); + // DEBUG STDAIR_LOG_DEBUG ("The simulation has ended"); @@ -43,4 +55,10 @@ } } + // //////////////////////////////////////////////////////////////////// + void Simulator:: + playBookingRequest (const stdair::BookingRequestStruct& iBookingRequest) { + + } + } Modified: trunk/dsim/dsim/command/Simulator.hpp =================================================================== --- trunk/dsim/dsim/command/Simulator.hpp 2010-01-21 19:32:31 UTC (rev 53) +++ trunk/dsim/dsim/command/Simulator.hpp 2010-01-26 15:14:31 UTC (rev 54) @@ -8,6 +8,10 @@ #include <dsim/command/CmdAbstract.hpp> // Forward declarations +namespace stdair { + struct BookingRequestStruct; +} + namespace SIMCRS { class SIMCRS_Service; } @@ -22,6 +26,9 @@ /** Perform a simulation. */ static void simulate (SIMCRS::SIMCRS_Service&); + /** Play a booking request event. */ + static void playBookingRequest (const stdair::BookingRequestStruct&); + private: /** Constructors. */ Simulator() {} 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: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. |
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. |
From: <den...@us...> - 2010-01-20 20:11:06
|
Revision: 51 http://dsim.svn.sourceforge.net/dsim/?rev=51&view=rev Author: denis_arnaud Date: 2010-01-20 20:11:00 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Dev] Moved the Log service into the StdAir library. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/dsim/core/Makefile.am Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-01-20 17:24:13 UTC (rev 50) +++ trunk/dsim/configure.ac 2010-01-20 20:11:00 UTC (rev 51) @@ -406,6 +406,7 @@ stdair/bom/Makefile stdair/factory/Makefile stdair/config/Makefile + stdair/service/Makefile stdair/core/Makefile trademgen/Makefile trademgen/basic/Makefile Modified: trunk/dsim/dsim/core/Makefile.am =================================================================== --- trunk/dsim/dsim/core/Makefile.am 2010-01-20 17:24:13 UTC (rev 50) +++ trunk/dsim/dsim/core/Makefile.am 2010-01-20 20:11:00 UTC (rev 51) @@ -20,9 +20,8 @@ $(top_builddir)/dsim/command/libcmd.la \ $(top_builddir)/dsim/service/libsvc.la libdsim_la_LDFLAGS = \ - $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ + $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ + $(top_builddir)/stdair/core/libstdair.la \ + $(top_builddir)/airsched/core/libairsched.la \ + $(top_builddir)/simcrs/core/libsimcrs.la \ -version-info $(GENERIC_LIBRARY_VERSION) - -# Header files -#pkginclude_HEADERS = $(service_h_sources) -#nobase_nodist_pkginclude_HEADERS = $(top_builddir)/dsim/config.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-20 17:24:20
|
Revision: 50 http://dsim.svn.sourceforge.net/dsim/?rev=50&view=rev Author: denis_arnaud Date: 2010-01-20 17:24:13 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Dev] Removed the BasChronometer class, as it is now given by the StdAir library. Modified Paths: -------------- trunk/dsim/dsim/basic/sources.mk trunk/dsim/dsim/service/DSIM_Service.cpp Removed Paths: ------------- trunk/dsim/dsim/basic/BasChronometer.cpp trunk/dsim/dsim/basic/BasChronometer.hpp Deleted: trunk/dsim/dsim/basic/BasChronometer.cpp =================================================================== --- trunk/dsim/dsim/basic/BasChronometer.cpp 2010-01-19 18:41:41 UTC (rev 49) +++ trunk/dsim/dsim/basic/BasChronometer.cpp 2010-01-20 17:24:13 UTC (rev 50) @@ -1,50 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <cassert> -// Dsim -#include <dsim/basic/BasChronometer.hpp> -#include <dsim/service/Logger.hpp> - -namespace DSIM { - - // ////////////////////////////////////////////////////////////////////// - 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()); - - /*DSIM_LOG_DEBUG ("Elapsed: " << lElapsedTime - << "; (micros): " - << lElapsedTimeInMicroSeconds / 1e6);*/ - - // The elapsed time given in return is expressed in seconds - return (lElapsedTimeInMicroSeconds / 1e6); - } - -} Deleted: trunk/dsim/dsim/basic/BasChronometer.hpp =================================================================== --- trunk/dsim/dsim/basic/BasChronometer.hpp 2010-01-19 18:41:41 UTC (rev 49) +++ trunk/dsim/dsim/basic/BasChronometer.hpp 2010-01-20 17:24:13 UTC (rev 50) @@ -1,40 +0,0 @@ -#ifndef __DSIM_COM_BAS_BASCHRONOMETER_HPP -#define __DSIM_COM_BAS_BASCHRONOMETER_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// Boost Date-Time (http://boost.org/doc/html/date_time/posix_time.html) -#include <boost/date_time/posix_time/posix_time.hpp> - -namespace DSIM { - - /** 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 // __DSIM_COM_BAS_BASCHRONOMETER_HPP Modified: trunk/dsim/dsim/basic/sources.mk =================================================================== --- trunk/dsim/dsim/basic/sources.mk 2010-01-19 18:41:41 UTC (rev 49) +++ trunk/dsim/dsim/basic/sources.mk 2010-01-20 17:24:13 UTC (rev 50) @@ -1,5 +1,3 @@ bas_h_sources = $(top_srcdir)/dsim/basic/BasConst_General.hpp \ - $(top_srcdir)/dsim/basic/BasConst_DSIM_Service.hpp \ - $(top_srcdir)/dsim/basic/BasChronometer.hpp -bas_cc_sources = $(top_srcdir)/dsim/basic/BasConst.cpp \ - $(top_srcdir)/dsim/basic/BasChronometer.cpp + $(top_srcdir)/dsim/basic/BasConst_DSIM_Service.hpp +bas_cc_sources = $(top_srcdir)/dsim/basic/BasConst.cpp Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-19 18:41:41 UTC (rev 49) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-20 17:24:13 UTC (rev 50) @@ -7,11 +7,12 @@ // Boost #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/ptime.hpp> +// StdAir +#include <stdair/basic/BasChronometer.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> // Dsim #include <dsim/basic/BasConst_DSIM_Service.hpp> -#include <dsim/basic/BasChronometer.hpp> #include <dsim/command/Simulator.hpp> #include <dsim/factory/FacDsimServiceContext.hpp> #include <dsim/service/DSIM_ServiceContext.hpp> @@ -96,14 +97,14 @@ lDSIM_ServiceContext.getSIMCRS_Service(); // Delegate the booking to the dedicated command - BasChronometer lSimulationChronometer; + stdair::BasChronometer lSimulationChronometer; lSimulationChronometer.start(); Simulator::simulate (lSIMCRS_Service); const double lSimulationMeasure = lSimulationChronometer.elapsed(); // DEBUG DSIM_LOG_DEBUG ("Simulation: " << lSimulationMeasure << " - " - << lDSIM_ServiceContext.display()); + << lDSIM_ServiceContext.display()); } catch (const std::exception& error) { DSIM_LOG_ERROR ("Exception: " << error.what()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-19 18:41:47
|
Revision: 49 http://dsim.svn.sourceforge.net/dsim/?rev=49&view=rev Author: denis_arnaud Date: 2010-01-19 18:41:41 +0000 (Tue, 19 Jan 2010) Log Message: ----------- [Test] Updated the MPI CFLAGS according to the new M4 macro files for OpenMPI and MPICH2. Modified Paths: -------------- trunk/dsim/test/boost/mpi/Makefile.am Modified: trunk/dsim/test/boost/mpi/Makefile.am =================================================================== --- trunk/dsim/test/boost/mpi/Makefile.am 2010-01-19 15:15:45 UTC (rev 48) +++ trunk/dsim/test/boost/mpi/Makefile.am 2010-01-19 18:41:41 UTC (rev 49) @@ -22,17 +22,17 @@ # mpi_SOURCES = mpi.cpp -mpi_CXXFLAGS = $(BOOST_CFLAGS) $(MPICH2_CFLAGS) +mpi_CXXFLAGS = $(BOOST_CFLAGS) $(MPIGEN_CFLAGS) mpi_LDFLAGS = $(BOOST_LIBS) $(BOOST_MPI_LIB) mpi_LDADD = mpi_p2p_SOURCES = mpi_p2p.cpp -mpi_p2p_CXXFLAGS = $(BOOST_CFLAGS) $(MPICH2_CFLAGS) +mpi_p2p_CXXFLAGS = $(BOOST_CFLAGS) $(MPIGEN_CFLAGS) mpi_p2p_LDFLAGS = $(BOOST_LIBS) $(BOOST_MPI_LIB) mpi_p2p_LDADD = mpi_p2p_nb_SOURCES = mpi_p2p_nb.cpp -mpi_p2p_nb_CXXFLAGS = $(BOOST_CFLAGS) $(MPICH2_CFLAGS) +mpi_p2p_nb_CXXFLAGS = $(BOOST_CFLAGS) $(MPIGEN_CFLAGS) mpi_p2p_nb_LDFLAGS = $(BOOST_LIBS) $(BOOST_MPI_LIB) mpi_p2p_nb_LDADD = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-19 15:15:52
|
Revision: 48 http://dsim.svn.sourceforge.net/dsim/?rev=48&view=rev Author: denis_arnaud Date: 2010-01-19 15:15:45 +0000 (Tue, 19 Jan 2010) Log Message: ----------- [Test] Added the original C version of the Levenshtein distance test program. Added Paths: ----------- trunk/dsim/test/boost/spirit/levenshtein.c Added: trunk/dsim/test/boost/spirit/levenshtein.c =================================================================== --- trunk/dsim/test/boost/spirit/levenshtein.c (rev 0) +++ trunk/dsim/test/boost/spirit/levenshtein.c 2010-01-19 15:15:45 UTC (rev 48) @@ -0,0 +1,168 @@ +/* + Levenshtein.c v2003-05-10 + Python extension computing Levenshtein distances, string similarities, + median strings and other goodies. + + Copyright (C) 2002-2003 David Necas (Yeti) <ye...@ph...>. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. +*/ + +/* + * Levenshtein distance between string1 and string2. + * + * Replace cost is normally 1, and 2 with nonzero xcost. + */ +size_t lev_distance (size_t len1, const unsigned char* string1, + size_t len2, const unsigned char* string2, + size_t xcost) { + size_t i; + size_t *row; /* we only need to keep one row of costs */ + size_t *end; + size_t half; + + /* strip common prefix */ + while (len1 > 0 && len2 > 0 && *string1 == *string2) { + len1--; + len2--; + string1++; + string2++; + } + + /* strip common suffix */ + while (len1 > 0 && len2 > 0 && string1[len1-1] == string2[len2-1]) { + len1--; + len2--; + } + + /* catch trivial cases */ + if (len1 == 0) + return len2; + if (len2 == 0) + return len1; + + /* make the inner cycle (i.e. string2) the longer one */ + if (len1 > len2) { + size_t nx = len1; + const unsigned char *sx = string1; + len1 = len2; + len2 = nx; + string1 = string2; + string2 = sx; + } + /* check len1 == 1 separately */ + if (len1 == 1) { + if (xcost) + return len2 + 1 - 2*(memchr(string2, *string1, len2) != NULL); + else + return len2 - (memchr(string2, *string1, len2) != NULL); + } + len1++; + len2++; + half = len1 >> 1; + + /* initalize first row */ + row = (size_t*)malloc(len2*sizeof(size_t)); + if (!row) + return (size_t)(-1); + end = row + len2 - 1; + for (i = 0; i < len2 - (xcost ? 0 : half); i++) + row[i] = i; + + /* go through the matrix and compute the costs. yes, this is an extremely + * obfuscated version, but also extremely memory-conservative and + * relatively fast. + */ + if (xcost) { + for (i = 1; i < len1; i++) { + size_t *p = row + 1; + const unsigned char char1 = string1[i - 1]; + const unsigned char *char2p = string2; + size_t D = i; + size_t x = i; + while (p <= end) { + if (char1 == *(char2p++)) + x = --D; + else + x++; + D = *p; + D++; + if (x > D) + x = D; + *(p++) = x; + } + } + } + else { + /* in this case we don't have to scan two corner triangles (of size len1/2) + * in the matrix because no best path can go throught them. note this + * breaks when len1 == len2 == 2 so the memchr() special case above is + * necessary */ + row[0] = len1 - half - 1; + for (i = 1; i < len1; i++) { + size_t *p; + const unsigned char char1 = string1[i - 1]; + const unsigned char *char2p; + size_t D, x; + /* skip the upper triangle */ + if (i >= len1 - half) { + size_t offset = i - (len1 - half); + size_t c3; + + char2p = string2 + offset; + p = row + offset; + c3 = *(p++) + (char1 != *(char2p++)); + x = *p; + x++; + D = x; + if (x > c3) + x = c3; + *(p++) = x; + } + else { + p = row + 1; + char2p = string2; + D = x = i; + } + /* skip the lower triangle */ + if (i <= half + 1) + end = row + len2 + i - half - 2; + /* main */ + while (p <= end) { + size_t c3 = --D + (char1 != *(char2p++)); + x++; + if (x > c3) + x = c3; + D = *p; + D++; + if (x > D) + x = D; + *(p++) = x; + } + /* lower triangle sentinel */ + if (i <= half) { + size_t c3 = --D + (char1 != *char2p); + x++; + if (x > c3) + x = c3; + *p = x; + } + } + } + + i = *end; + free(row); + return i; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-16 22:48:37
|
Revision: 47 http://dsim.svn.sourceforge.net/dsim/?rev=47&view=rev Author: denis_arnaud Date: 2010-01-16 22:48:31 +0000 (Sat, 16 Jan 2010) Log Message: ----------- [Conf] Improved the M4 macro files for MySQL, SOCI, Boost, MPICH2 and OpenMPI. Modified Paths: -------------- trunk/dsim/configure.ac Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-01-07 19:49:16 UTC (rev 46) +++ trunk/dsim/configure.ac 2010-01-16 22:48:31 UTC (rev 47) @@ -169,21 +169,22 @@ AC_SUBST(PYTHON_ADD_LIBS) # ----------------------------------------------------------- -# MPICH2: http://www.mcs.anl.gov/research/projects/mpich2 -# Note: Boost.MPI depends on MPICH2, rather than on OpenMPI +# OpenMPI: http://www.open-mpi.org # ----------------------------------------------------------- -AX_MPICH2 -AC_SUBST(MPICH2_VERSION) -AC_SUBST(MPICH2_CFLAGS) -AC_SUBST(MPICH2_LIBS) +#AX_OPENMPI +#AC_SUBST(MPIGEN_VERSION) +#AC_SUBST(MPIGEN_CFLAGS) +#AC_SUBST(MPIGEN_LIBS) # ----------------------------------------------------------- -# OpenMPI: http://www.open-mpi.org +# MPICH2: http://www.mcs.anl.gov/research/projects/mpich2 +# Note: Boost.MPI depends on MPICH2 by default, rather than +# on OpenMPI # ----------------------------------------------------------- -#AX_OPENMPI -AC_SUBST(OPENMPI_VERSION) -AC_SUBST(OPENMPI_CFLAGS) -AC_SUBST(OPENMPI_LIBS) +AX_MPICH2 +AC_SUBST(MPIGEN_VERSION) +AC_SUBST(MPIGEN_CFLAGS) +AC_SUBST(MPIGEN_LIBS) # --------------------------------------------------------------- # Support for Boost (Extension of the STL): http://www.boost.org @@ -518,6 +519,26 @@ ) AC_OUTPUT +# OpenMPI +if test "x$HAVE_OPENMPI" = "x1"; then + OPENMPI_OUTPUT=" - OPENMPI ........... : + o OPENMPI_VERSION . : ${MPIGEN_VERSION} + o OPENMPI_CFLAGS .. : ${MPIGEN_CFLAGS} + o OPENMPI_LIBS .... : ${MPIGEN_LIBS}" +else + OPENMPI_OUTPUT=" - OPENMPI ........... : No" +fi + +# MPICH2 +if test "x$HAVE_MPICH2" = "x1"; then + MPICH2_OUTPUT=" - MPICH2 ............ : + o MPICH2_VERSION .. : ${MPIGEN_VERSION} + o MPICH2_CFLAGS ... : ${MPIGEN_CFLAGS} + o MPICH2_LIBS ..... : ${MPIGEN_LIBS}" +else + MPICH2_OUTPUT=" - MPICH2 ............ : No" +fi + echo " ------------------------------------------------------------------------------ $PACKAGE-$VERSION library configuration: @@ -565,21 +586,15 @@ o GSL_CFLAGS ...... : ${GSL_CFLAGS} o GSL_LIBS ........ : ${GSL_LIBS} - - OPENMPI ........... : - o OPENMPI_VERSION . : ${OPENMPI_VERSION} - o OPENMPI_CFLAGS .. : ${OPENMPI_CFLAGS} - o OPENMPI_LIBS .... : ${OPENMPI_LIBS} +${OPENMPI_OUTPUT} - - MPICH2 ............ : - o MPICH2_VERSION .. : ${MPICH2_VERSION} - o MPICH2_CFLAGS ... : ${MPICH2_CFLAGS} - o MPICH2_LIBS ..... : ${MPICH2_LIBS} +${MPICH2_OUTPUT} - - Python ........... : - o PYTHON_VERSION . : ${PYTHON_VERSION} - o PYTHON_CFLAGS .. : ${PYTHON_CFLAGS} - o PYTHON_LIBS .... : ${PYTHON_LIBS} - o PYTHON_ADD_LIBS : ${PYTHON_ADD_LIBS} + - Python ............ : + o PYTHON_VERSION .. : ${PYTHON_VERSION} + o PYTHON_CFLAGS ... : ${PYTHON_CFLAGS} + o PYTHON_LIBS ..... : ${PYTHON_LIBS} + o PYTHON_ADD_LIBS . : ${PYTHON_ADD_LIBS} - Boost ............. : o BOOST_VERSION ... : ${BOOST_VERSION} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-07 19:49:26
|
Revision: 46 http://dsim.svn.sourceforge.net/dsim/?rev=46&view=rev Author: denis_arnaud Date: 2010-01-07 19:49:16 +0000 (Thu, 07 Jan 2010) Log Message: ----------- [Conf] Updated the version. Modified Paths: -------------- trunk/dsim/configure.ac Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-01-04 10:53:16 UTC (rev 45) +++ trunk/dsim/configure.ac 2010-01-07 19:49:16 UTC (rev 46) @@ -1,8 +1,8 @@ # Process this file with autoconf to produce a configure script #------------------------------------------------------------------- AC_PREREQ(2.59) -AC_COPYRIGHT([Copyright (C) 2007-2010 Amadeus DEV-ORI <da...@am...>]) -AC_INIT([DSIM],[0.1.0],[da...@am...],[dsim]) +AC_COPYRIGHT([Copyright (C) 2007-2010 Denis Arnaud <den...@us...>]) +AC_INIT([DSIM],[99.99.99],[den...@us...],[dsim]) AC_CONFIG_HEADER([stdair/config.h]) AC_CONFIG_SRCDIR([stdair/basic/BasConst.cpp]) AC_CONFIG_AUX_DIR([config]) @@ -16,7 +16,7 @@ AC_SUBST(RPM_RELEASE) # Shared library versioning for the main library -GENERIC_LIBRARY_VERSION="2:1:0" +GENERIC_LIBRARY_VERSION="99:99:99" # | | | # +------+ | +---+ # | | | This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-01-04 10:53:23
|
Revision: 45 http://dsim.svn.sourceforge.net/dsim/?rev=45&view=rev Author: quannaus Date: 2010-01-04 10:53:16 +0000 (Mon, 04 Jan 2010) Log Message: ----------- [Dev] Some small changes in the type definition. Modified Paths: -------------- trunk/dsim/dsim/command/Simulator.cpp Modified: trunk/dsim/dsim/command/Simulator.cpp =================================================================== --- trunk/dsim/dsim/command/Simulator.cpp 2010-01-03 17:04:17 UTC (rev 44) +++ trunk/dsim/dsim/command/Simulator.cpp 2010-01-04 10:53:16 UTC (rev 45) @@ -6,6 +6,8 @@ #include <string> #include <vector> #include <exception> +// STDAIR +#include <stdair/STDAIR_Types.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> // Dsim @@ -23,10 +25,10 @@ DSIM_LOG_DEBUG ("The simulation is starting"); // Airline code - std::string lAirlineCode ("LH"); + stdair::AirlineCode_T lAirlineCode ("BA"); // Number of passengers in the travelling group - SIMCRS::PartySize_T lPartySize = 5; + stdair::PartySize_T lPartySize = 5; // Make a booking ioSIMCRS_Service.sell (lAirlineCode, lPartySize); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-03 17:04:44
|
Revision: 44 http://dsim.svn.sourceforge.net/dsim/?rev=44&view=rev Author: denis_arnaud Date: 2010-01-03 17:04:17 +0000 (Sun, 03 Jan 2010) Log Message: ----------- [Test] Added a Boost.MPI tutorial sample (asynchronous P2P communication). Modified Paths: -------------- trunk/dsim/test/boost/mpi/Makefile.am Added Paths: ----------- trunk/dsim/test/boost/mpi/mpi_p2p_nb.cpp Property Changed: ---------------- trunk/dsim/test/boost/mpi/ Property changes on: trunk/dsim/test/boost/mpi ___________________________________________________________________ Modified: svn:ignore - .deps .libs Makefile.in Makefile mpi_c mpi mpi_p2p + .deps .libs Makefile.in Makefile mpi_c mpi mpi_p2p mpi_p2p_nb Modified: trunk/dsim/test/boost/mpi/Makefile.am =================================================================== --- trunk/dsim/test/boost/mpi/Makefile.am 2010-01-01 18:55:18 UTC (rev 43) +++ trunk/dsim/test/boost/mpi/Makefile.am 2010-01-03 17:04:17 UTC (rev 44) @@ -9,7 +9,7 @@ EXTRA_DIST = pympi.py # -check_PROGRAMS = mpi_c mpi mpi_p2p +check_PROGRAMS = mpi_c mpi mpi_p2p mpi_p2p_nb # mpi_c must be compiled with mpic++ @@ -31,3 +31,8 @@ mpi_p2p_LDFLAGS = $(BOOST_LIBS) $(BOOST_MPI_LIB) mpi_p2p_LDADD = +mpi_p2p_nb_SOURCES = mpi_p2p_nb.cpp +mpi_p2p_nb_CXXFLAGS = $(BOOST_CFLAGS) $(MPICH2_CFLAGS) +mpi_p2p_nb_LDFLAGS = $(BOOST_LIBS) $(BOOST_MPI_LIB) +mpi_p2p_nb_LDADD = + Added: trunk/dsim/test/boost/mpi/mpi_p2p_nb.cpp =================================================================== --- trunk/dsim/test/boost/mpi/mpi_p2p_nb.cpp (rev 0) +++ trunk/dsim/test/boost/mpi/mpi_p2p_nb.cpp 2010-01-03 17:04:17 UTC (rev 44) @@ -0,0 +1,37 @@ +// STL +#include <iostream> +#include <string> +// Boost.MPI +#include <boost/mpi.hpp> +#include <boost/serialization/string.hpp> + + +// ///////////////////////// M A I N /////////////////////////// +int main (int argc, char* argv[]) { + boost::mpi::environment env (argc, argv); + boost::mpi::communicator world; + + if (world.rank() == 0) { + boost::mpi::request reqs[2]; + std::string msg; + const std::string outMsg = "Hello"; + reqs[0] = world.isend (1, 0, outMsg); + reqs[1] = world.irecv (1, 1, msg); + boost::mpi::wait_all (reqs, reqs+2); + + std::cout << msg << "!" << std::endl; + + } else { + boost::mpi::request reqs[2]; + std::string msg; + const std::string outMsg = "world"; + reqs[0] = world.irecv (0, 0, msg); + reqs[1] = world.isend (0, 1, outMsg); + boost::mpi::wait_all (reqs, reqs+2); + + std::cout << msg << ", "; + // std::cout.flush(); + } + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-01 18:55:24
|
Revision: 43 http://dsim.svn.sourceforge.net/dsim/?rev=43&view=rev Author: denis_arnaud Date: 2010-01-01 18:55:18 +0000 (Fri, 01 Jan 2010) Log Message: ----------- [Struct] The parsing of the input schedule file is now done during the initialisation. 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 2009-12-31 13:33:35 UTC (rev 42) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-01-01 18:55:18 UTC (rev 43) @@ -5,8 +5,10 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STL -#include <ostream> +#include <iosfwd> #include <string> +// StdAir +#include <stdair/STDAIR_Types.hpp> // Dsim #include <dsim/DSIM_Types.hpp> @@ -27,8 +29,9 @@ public: // ////////// Constructors and destructors ////////// /** Constructor. - @param std::ostream& Output log stream (for instance, std::cout). */ - DSIM_Service (const std::string&, std::ostream& ioLogStream); + @param std::ostream& Output log stream (for instance, std::cout). + @param const stdair::Filename_T& Filename of the input schedule file. */ + DSIM_Service (std::ostream& ioLogStream, const stdair::Filename_T&); /** Destructor. */ ~DSIM_Service(); @@ -41,8 +44,10 @@ /** Default copy constructor. */ DSIM_Service (const DSIM_Service&); - /** Initialise. */ - void init (const std::string&, std::ostream& ioLogStream); + /** 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&); /** Finalise. */ void finalise (); Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2009-12-31 13:33:35 UTC (rev 42) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-01 18:55:18 UTC (rev 43) @@ -3,6 +3,7 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> +#include <ostream> // Boost #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/ptime.hpp> @@ -21,15 +22,14 @@ // ////////////////////////////////////////////////////////////////////// DSIM_Service:: - DSIM_Service (const std::string& iScheduleInputFilename, - std::ostream& ioLogStream) + DSIM_Service (std::ostream& ioLogStream, + const stdair::Filename_T& iScheduleInputFilename) : _dsimServiceContext (NULL) { - init (iScheduleInputFilename, ioLogStream); + init (ioLogStream, iScheduleInputFilename); } // ////////////////////////////////////////////////////////////////////// - DSIM_Service::DSIM_Service () - : _dsimServiceContext (NULL) { + DSIM_Service::DSIM_Service () : _dsimServiceContext (NULL) { assert (false); } @@ -51,8 +51,8 @@ } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::init (const std::string& iScheduleInputFilename, - std::ostream& ioLogStream) { + void DSIM_Service::init (std::ostream& ioLogStream, + const stdair::Filename_T& iScheduleInputFilename) { // Set the log file logInit (LOG::DEBUG, ioLogStream); @@ -65,6 +65,10 @@ // configuration file). // Initialise the SIMCRS service handler const SIMCRS::CRSCode_T lCRSCode = "1S"; + + // Note that the (Boost.)Smart Pointer keeps track of the references + // 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, iScheduleInputFilename)); Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2009-12-31 13:33:35 UTC (rev 42) +++ trunk/dsim/test/dsim/simulate.cpp 2010-01-01 18:55:18 UTC (rev 43) @@ -26,7 +26,7 @@ logOutputFile.clear(); // Initialise the list of classes/buckets - DSIM::DSIM_Service dsimService (lScheduleInputFilename, logOutputFile); + DSIM::DSIM_Service dsimService (logOutputFile, lScheduleInputFilename); // Perform a simulation dsimService.simulate(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-31 13:33:44
|
Revision: 42 http://dsim.svn.sourceforge.net/dsim/?rev=42&view=rev Author: denis_arnaud Date: 2009-12-31 13:33:35 +0000 (Thu, 31 Dec 2009) Log Message: ----------- [Test] Added tests for the Boost.Filesystem library. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/boost/Makefile.am trunk/dsim/test/boost/accumulators/Makefile.am trunk/dsim/test/boost/asio/Makefile.am trunk/dsim/test/boost/mpl/Makefile.am trunk/dsim/test/boost/serialization/Makefile.am trunk/dsim/test/boost/signals/Makefile.am Added Paths: ----------- trunk/dsim/test/boost/filesystem/ trunk/dsim/test/boost/filesystem/Makefile.am trunk/dsim/test/boost/filesystem/file_size.cpp trunk/dsim/test/boost/filesystem/fstream_test.cpp trunk/dsim/test/boost/filesystem/lpath.hpp trunk/dsim/test/boost/filesystem/operations_test.cpp trunk/dsim/test/boost/filesystem/path_test.cpp trunk/dsim/test/boost/filesystem/process_jam_log.cpp trunk/dsim/test/boost/filesystem/simple_ls.cpp trunk/dsim/test/boost/filesystem/tiny_xml.cpp trunk/dsim/test/boost/filesystem/tiny_xml.hpp trunk/dsim/test/boost/filesystem/utf8_codecvt_facet.cpp trunk/dsim/test/boost/filesystem/utf8_codecvt_facet.hpp trunk/dsim/test/boost/filesystem/utf8_codecvt_facet_base.cpp trunk/dsim/test/boost/filesystem/wide_test.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/configure.ac 2009-12-31 13:33:35 UTC (rev 42) @@ -499,6 +499,7 @@ test/boost/asio/httpd/Makefile test/boost/asio/logd/Makefile test/boost/asio/logger/Makefile + test/boost/filesystem/Makefile test/boost/mpi/Makefile test/boost/mpl/Makefile test/boost/spirit/Makefile Modified: trunk/dsim/test/boost/Makefile.am =================================================================== --- trunk/dsim/test/boost/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/test/boost/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -5,6 +5,6 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = accumulators asio mpi mpl serialization signals spirit +SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit EXTRA_DIST = Modified: trunk/dsim/test/boost/accumulators/Makefile.am =================================================================== --- trunk/dsim/test/boost/accumulators/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/test/boost/accumulators/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -1,4 +1,4 @@ -## test/architecture sub-directory +## test/boost/accumulators sub-directory include $(top_srcdir)/Makefile.common MAINTAINERCLEANFILES = Makefile.in Modified: trunk/dsim/test/boost/asio/Makefile.am =================================================================== --- trunk/dsim/test/boost/asio/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/test/boost/asio/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -1,4 +1,4 @@ -## test/asio sub-directory +## test/boost/asio sub-directory include $(top_srcdir)/Makefile.common ## Property changes on: trunk/dsim/test/boost/filesystem ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile simple_ls file_size process_jam_log path_test wide_test fstream_test operations_test Copied: trunk/dsim/test/boost/filesystem/Makefile.am (from rev 41, trunk/dsim/test/boost/mpl/Makefile.am) =================================================================== --- trunk/dsim/test/boost/filesystem/Makefile.am (rev 0) +++ trunk/dsim/test/boost/filesystem/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,57 @@ +## test/boost/filesystem sub-directory +include $(top_srcdir)/Makefile.common + +# +MAINTAINERCLEANFILES = Makefile.in + +# +SUBDIRS = + +EXTRA_DIST = + +# +check_PROGRAMS = simple_ls file_size process_jam_log \ + path_test wide_test operations_test fstream_test + +# +simple_ls_SOURCES = simple_ls.cpp +simple_ls_CXXFLAGS = $(BOOST_CFLAGS) +simple_ls_LDADD = +simple_ls_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +file_size_SOURCES = file_size.cpp +file_size_CXXFLAGS = $(BOOST_CFLAGS) +file_size_LDADD = +file_size_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +process_jam_log_SOURCES = tiny_xml.hpp tiny_xml.cpp process_jam_log.cpp +process_jam_log_CXXFLAGS = $(BOOST_CFLAGS) +process_jam_log_LDADD = +process_jam_log_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +path_test_SOURCES = path_test.cpp +path_test_CXXFLAGS = $(BOOST_CFLAGS) +path_test_LDADD = +path_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +wide_test_SOURCES = wide_test.cpp +wide_test_CXXFLAGS = $(BOOST_CFLAGS) +wide_test_LDADD = +wide_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +operations_test_SOURCES = operations_test.cpp +operations_test_CXXFLAGS = $(BOOST_CFLAGS) +operations_test_LDADD = +operations_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +fstream_test_SOURCES = fstream_test.cpp +fstream_test_CXXFLAGS = $(BOOST_CFLAGS) +fstream_test_LDADD = +fstream_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + Added: trunk/dsim/test/boost/filesystem/file_size.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/file_size.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/file_size.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,38 @@ +// file_size program -------------------------------------------------------// +// Copyright Beman Dawes, 2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/filesystem for documentation. +// STL +#include <iostream> +// Boost +#include <boost/filesystem/operations.hpp> + +namespace fs = boost::filesystem; + +// ////////////////////// M A I N /////////////////////// +int main( int argc, char* argv[] ) { + + if ( argc != 2 ) { + std::cout << "Usage: file_size path" << std::endl; + return 1; + } + + std::cout << "sizeof(intmax_t) is " << sizeof(boost::intmax_t) << std::endl; + + fs::path p( argv[1], fs::native ); + + if (fs::exists (p) == false) { + std::cout << "not found: " << argv[1] << std::endl; + return 1; + } + + if (fs::is_regular (p) == false) { + std::cout << "not a regular file: " << argv[1] << std::endl; + return 1; + } + + std::cout << "size of " << argv[1] << " is " << fs::file_size(p) << std::endl; + return 0; +} Added: trunk/dsim/test/boost/filesystem/fstream_test.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/fstream_test.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/fstream_test.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,177 @@ +// fstream_test.cpp --------------------------------------------------------// +// Copyright Beman Dawes 2002. +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// See library home page at http://www.boost.org/libs/filesystem +// STL +#include <string> +#include <iostream> +#include <cstdio> // for std::remove +// Boost +#include <boost/config/warning_disable.hpp> +// See deprecated_test for tests of deprecated features +#define BOOST_FILESYSTEM_NO_DEPRECATED +#include <boost/filesystem/config.hpp> + +# ifdef BOOST_FILESYSTEM_NARROW_ONLY +# include "lpath.hpp" +# endif + +#include <boost/filesystem/fstream.hpp> +#include <boost/filesystem/operations.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include "utf8_codecvt_facet.hpp" + +namespace fs = boost::filesystem; + +#ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::remove; } +#endif + + +namespace { + + bool cleanup = true; + + template< class Path > + void test( const Path & p ) { +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 1\n"; + fs::filebuf fb; + fb.open( p, std::ios_base::in ); + BOOST_TEST( fb.is_open() == fs::exists( p ) ); + } + { + std::cout << " in test 2\n"; + fs::filebuf fb1; + fb1.open( p, std::ios_base::out ); + BOOST_TEST( fb1.is_open() ); + } + { + std::cout << " in test 3\n"; + fs::filebuf fb2; + fb2.open( p, std::ios_base::in ); + BOOST_TEST( fb2.is_open() ); + } +# else + std::cout << "<note>\n"; + std::cout << + "VC++6.0 does not support boost::filesystem open()\n"; +# endif + { + std::cout << " in test 4\n"; + fs::ifstream tfs( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 4.1\n"; + fs::ifstream tfs( p / p.filename() ); // should fail + BOOST_TEST( !tfs.is_open() ); + } + { + std::cout << " in test 5\n"; + fs::ifstream tfs( p, std::ios_base::in ); + BOOST_TEST( tfs.is_open() ); + } +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 6\n"; + fs::ifstream tfs; + tfs.open( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 7\n"; + fs::ifstream tfs; + tfs.open( p, std::ios_base::in ); + BOOST_TEST( tfs.is_open() ); + } +# endif + { + std::cout << " in test 8\n"; + fs::ofstream tfs( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 9\n"; + fs::ofstream tfs( p, std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 10\n"; + fs::ofstream tfs; + tfs.open( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 11\n"; + fs::ofstream tfs; + tfs.open( p, std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# endif + { + std::cout << " in test 12\n"; + fs::fstream tfs( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 13\n"; + fs::fstream tfs( p, std::ios_base::in|std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 14\n"; + fs::fstream tfs; + tfs.open( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 15\n"; + fs::fstream tfs; + tfs.open( p, std::ios_base::in|std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# endif + + if ( cleanup ) fs::remove( p ); + + } // test +} // unnamed namespace + +int main( int argc, char*[] ) +{ + if ( argc > 1 ) cleanup = false; + + // test fs::path + std::cout << "path tests:\n"; + test( fs::path( "fstream_test_foo" ) ); + +#ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // So that tests are run with known encoding, use Boost UTF-8 codecvt + std::locale global_loc = std::locale(); + std::locale loc( global_loc, new fs::detail::utf8_codecvt_facet ); + fs::wpath_traits::imbue( loc ); + + // test fs::wpath + // x2780 is circled 1 against white background == e2 9e 80 in UTF-8 + // x2781 is circled 2 against white background == e2 9e 81 in UTF-8 + std::cout << "\nwpath tests:\n"; + test( fs::wpath( L"fstream_test_\x2780" ) ); + + // test user supplied basic_path + const long lname[] = { 'f', 's', 'r', 'e', 'a', 'm', '_', 't', 'e', 's', + 't', '_', 'l', 'p', 'a', 't', 'h', 0 }; + std::cout << "\nlpath tests:\n"; + // test( user::lpath( lname ) ); + +#endif + + return ::boost::report_errors(); +} Added: trunk/dsim/test/boost/filesystem/lpath.hpp =================================================================== --- trunk/dsim/test/boost/filesystem/lpath.hpp (rev 0) +++ trunk/dsim/test/boost/filesystem/lpath.hpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,101 @@ +// Boost lpath.hpp ---------------------------------------------------------// + +// Copyright Beman Dawes 2005 + +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +#include <boost/filesystem/path.hpp> +#include <cwchar> // for std::mbstate_t +#include <string> +#include <ios> // for std::streamoff + +namespace std +{ + // Note well: this specialization is meant only to support wide_test.cpp. + // It is not fully functional, fully correct, or efficient. + template<> struct char_traits<long> + { + typedef long char_type; + typedef long int_type; + typedef streamoff off_type; + typedef streampos pos_type; + typedef mbstate_t state_type; + static void assign(char_type& c1, const char_type& c2){c1=c2;} + static bool eq(const char_type& c1, const char_type& c2){return c1==c2;} + static bool lt(const char_type& c1, const char_type& c2){return c1<c2;} + static int compare(const char_type* s1, const char_type* s2, size_t n) + { + const char_type* e = s1 + n; + for ( ;s1 != e && *s1 == *s2; ++s1, ++s2 ) {} + return s1 == e ? 0 : (*s1<*s2 ? -1 : 1); + } + static size_t length(const char_type* s) + { const char_type* b=s; for(;*s!=0L;++s){} return s-b; } + + static const char_type* find(const char_type* /*s*/, size_t /*n*/, const char_type& /*a*/) + { return 0; } + + // copy semantics will do for wide_test + static char_type* move(char_type* s1, const char_type* s2, size_t n) + { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; } + + static char_type* copy(char_type* s1, const char_type* s2, size_t n) + { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; } + + static char_type* assign(char_type* s, size_t n, char_type a) + { char_type* b=s; for(char_type* e=s+n;s!=e;++s) *s=a; return b; } + + static int_type not_eof(const int_type& c); + static char_type to_char_type(const int_type& c); + static int_type to_int_type(const char_type& c); + static bool eq_int_type(const int_type& c1, const int_type& c2); + static int_type eof(); + }; +} + +namespace user +{ + typedef std::basic_string<long> lstring; + struct lpath_traits; + typedef boost::filesystem::basic_path<lstring, lpath_traits> lpath; + + struct lpath_traits + { + typedef lstring internal_string_type; + typedef std::string external_string_type; + + static external_string_type to_external( const lpath &, + const internal_string_type & src ) + { + external_string_type tmp; + for ( internal_string_type::const_iterator it( src.begin() ); + it != src.end(); ++it ) + { + tmp += static_cast<external_string_type::value_type>(*it); + } + return tmp; + } + + static internal_string_type to_internal( const external_string_type & src ) + { + internal_string_type tmp; + for ( external_string_type::const_iterator it( src.begin() ); + it != src.end(); ++it ) tmp += *it; + return tmp; + } + }; + +} // namespace user + +namespace boost +{ + namespace filesystem + { + template<> struct is_basic_path<user::lpath> + { static const bool value = true; }; + } +} Added: trunk/dsim/test/boost/filesystem/operations_test.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/operations_test.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/operations_test.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,942 @@ +// Boost operations_test.cpp -----------------------------------------------// +// Copyright Beman Dawes 2002. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See library home page at http://www.boost.org/libs/filesystem +// STL +#include <fstream> +#include <iostream> +#include <string> +#include <cstring> // for strncmp, etc. +#include <ctime> +#include <cstdlib> // for system() +// Boost +#include <boost/config/warning_disable.hpp> +// See deprecated_test for tests of deprecated features +#define BOOST_FILESYSTEM_NO_DEPRECATED +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/convenience.hpp> +#include <boost/cerrno.hpp> +namespace fs = boost::filesystem; + +#include <boost/config.hpp> +#include <boost/detail/lightweight_test.hpp> + +using boost::system::error_code; +using boost::system::system_category; +using boost::system::system_error; + +#ifndef BOOST_FILESYSTEM_NARROW_ONLY +# define BOOST_BND(BOOST_FUNC_TO_DO) BOOST_FUNC_TO_DO<fs::path> +#else +# define BOOST_BND(BOOST_FUNC_TO_DO) BOOST_FUNC_TO_DO +#endif + +// VC++ 7.0 and earlier has a serious namespace bug that causes a clash +// between boost::filesystem::is_empty and the unrelated type trait +// boost::is_empty. +#if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 +# define BOOST_FS_IS_EMPTY fs::is_empty +#else +# define BOOST_FS_IS_EMPTY fs::_is_empty +#endif + +# ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::asctime; using ::gmtime; using ::localtime; + using ::difftime; using ::time; using ::tm; using ::mktime; using ::system; } +# endif + +#ifdef BOOST_WINDOWS_API +# include <windows.h> +#endif + +#define CHECK_EXCEPTION(Functor,Expect) throws_fs_error(Functor,Expect,__LINE__) + +namespace +{ + typedef int errno_t; + std::string platform( BOOST_PLATFORM ); + bool report_throws; + fs::directory_iterator end_itr; + + unsigned short language_id; // 0 except for Windows + + const char * temp_dir_name = "temp_fs_test_dir"; + + void create_file( const fs::path & ph, const std::string & contents ) + { + std::ofstream f( ph.file_string().c_str() ); + if ( !f ) + throw fs::filesystem_error( "operations_test create_file", + ph, error_code(errno, system_category) ); + if ( !contents.empty() ) f << contents; + } + + void verify_file( const fs::path & ph, const std::string & expected ) + { + std::ifstream f( ph.file_string().c_str() ); + if ( !f ) + throw fs::filesystem_error( "operations_test verify_file", + ph, error_code(errno, system_category) ); + std::string contents; + f >> contents; + if ( contents != expected ) + throw fs::filesystem_error( "operations_test verify_file contents \"" + + contents + "\" != \"" + expected + "\"", ph, error_code() ); + } + + template< typename F > + bool throws_fs_error( F func, errno_t en, int line ) + { + try { func(); } + + catch ( const fs::filesystem_error & ex ) + { + if ( report_throws ) + { + // use the what() convenience function to display exceptions + std::cout << "\n" << ex.what() << "\n"; + } + if ( en == 0 + || en == ex.code().default_error_condition().value() ) return true; + std::cout + << "\nWarning: line " << line + << " exception reports default_error_condition().value() " << ex.code().default_error_condition().value() + << ", should be " << en + << "\n value() is " << ex.code().value() + << std::endl; + return true; + } + return false; + } + + // compile-only two argument "do-the-right-thing" tests + // verifies that all overload combinations compile without error + void do_not_call() + { + fs::path p; + std::string s; + const char * a = 0; + fs::copy_file( p, p ); + fs::copy_file( s, p ); + fs::copy_file( a, p ); + fs::copy_file( p, s ); + fs::copy_file( p, a ); + fs::copy_file( s, s ); + fs::copy_file( a, s ); + fs::copy_file( s, a ); + fs::copy_file( a, a ); + } + + void exception_tests() + { + bool exception_thrown; + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( std::runtime_error x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + // the stdcxx standard library apparently appends additional info + // to what(), so check only the initial portion: + BOOST_TEST( std::strncmp( x.what(), + "boost::filesystem::create_directory", + sizeof("boost::filesystem::create_directory")-1 ) == 0 ); + } + BOOST_TEST( exception_thrown ); + + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( system_error x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + BOOST_TEST( std::strcmp( x.what(), + "boost::filesystem::create_directory: The system cannot find the path specified" ) == 0 ); + } + BOOST_TEST( exception_thrown ); + + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( fs::filesystem_error x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + { + bool ok ( std::strcmp( x.what(), + "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir\\foo\\bar\"" ) == 0 ); + BOOST_TEST( ok ); + if ( !ok ) + { + std::cout << "what returns \"" << x.what() << "\"" << std::endl; + } + } + } + BOOST_TEST( exception_thrown ); + + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( const fs::filesystem_error & x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + { + bool ok ( std::strcmp( x.what(), + "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir\\foo\\bar\"" ) == 0 ); + BOOST_TEST( ok ); + if ( !ok ) + { + std::cout << "what returns \"" << x.what() << "\"" << std::endl; + } + } + } + BOOST_TEST( exception_thrown ); + } + + void bad_file_size() + { + fs::file_size( " No way, Jose" ); + } + + void bad_directory_size() + { + fs::file_size( fs::current_path<fs::path>() ); + } + + fs::path bad_create_directory_path; + void bad_create_directory() + { + fs::create_directory( bad_create_directory_path ); + } + + void bad_equivalent() + { + fs::equivalent( "no-such-path", "another-not-present-path" ); + } + + fs::path bad_remove_dir; + void bad_remove() + { + fs::remove( bad_remove_dir ); + } + + class renamer + { + public: + renamer( const fs::path & p1, const fs::path & p2 ) + : from(p1), to(p2) {} + void operator()() + { + fs::rename( from, to ); + } + private: + fs::path from; + fs::path to; + }; + +} // unnamed namespace + +// main ------------------------------------------------------------------------------// + +int main( int argc, char * argv[] ) +{ + if ( argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='t' ) report_throws = true; + + // The choice of platform is make at runtime rather than compile-time + // so that compile errors for all platforms will be detected even though + // only the current platform is runtime tested. +# if defined( BOOST_POSIX_API ) + platform = "POSIX"; +# elif defined( BOOST_WINDOWS_API ) + platform = "Windows"; +# if !defined(__MINGW32__) && !defined(__CYGWIN__) + language_id = ::GetUserDefaultUILanguage(); +# else + language_id = 0x0409; // Assume US English +# endif +# else + platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" ) + ? "Windows" + : "POSIX"; +# endif + std::cout << "API is " << platform << std::endl; + + exception_tests(); + + std::cout << "\ninitial_path<path>().string() is\n \"" + << fs::initial_path<fs::path>().string() + << "\"\n"; + std::cout << "\ninitial_path<fs::path>().file_string() is\n \"" + << fs::initial_path<fs::path>().file_string() + << "\"\n\n"; + BOOST_TEST( fs::initial_path<fs::path>().is_complete() ); + BOOST_TEST( fs::current_path<fs::path>().is_complete() ); + BOOST_TEST( fs::initial_path<fs::path>().string() + == fs::current_path<fs::path>().string() ); + + BOOST_TEST( fs::complete( "" ).empty() ); + BOOST_TEST( fs::complete( "/" ).string() == fs::initial_path<fs::path>().root_path().string() ); + BOOST_TEST( fs::complete( "foo" ).string() == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::complete( "/foo" ).string() == fs::initial_path<fs::path>().root_path().string()+"foo" ); + BOOST_TEST( fs::complete( "foo", fs::path( "//net/bar" ) ).string() + == "//net/bar/foo" ); + + // predicate and status tests + BOOST_TEST( fs::exists( "/" ) ); + fs::path ng( " no-way, Jose" ); + BOOST_TEST( !fs::exists( ng ) ); + BOOST_TEST( !fs::is_directory( ng ) ); + BOOST_TEST( !fs::is_regular_file( ng ) ); + BOOST_TEST( !fs::is_symlink( ng ) ); + fs::file_status stat( fs::status( ng ) ); + BOOST_TEST( fs::status_known( stat ) ); + BOOST_TEST( !fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + stat = fs::status( "" ); + BOOST_TEST( fs::status_known( stat ) ); + BOOST_TEST( !fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + + fs::path dir( fs::initial_path<fs::path>() / temp_dir_name ); + + if ( fs::exists( dir ) ) + fs::remove_all( dir ); // remove residue from prior failed tests + BOOST_TEST( !fs::exists( dir ) ); + + // create a directory, then check it for consistency + // take extra care to report problems, since if this fails + // many subsequent tests will fail + try + { + fs::create_directory( dir ); + } + + catch ( const fs::filesystem_error & x ) + { + std::cout << x.what() << "\n\n" + "***** Creating directory " << dir.string() << " failed. *****\n" + "***** This is a serious error that will prevent further tests *****\n" + "***** from returning useful results. Further testing is aborted. *****\n\n"; + return 1; + } + + catch ( ... ) + { + std::cout << "\n\n" + "***** Creating directory " << dir.string() << " failed. *****\n" + "***** This is a serious error that will prevent further tests *****\n" + "***** from returning useful results. Further testing is aborted. *****\n\n"; + return 1; + } + + BOOST_TEST( fs::exists( dir ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( dir ) ); + BOOST_TEST( fs::is_directory( dir ) ); + BOOST_TEST( !fs::is_regular_file( dir ) ); + BOOST_TEST( !fs::is_other( dir ) ); + BOOST_TEST( !fs::is_symlink( dir ) ); + stat = fs::status( dir ); + BOOST_TEST( fs::exists( stat ) ); + BOOST_TEST( fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + + // Windows only tests + if ( platform == "Windows" ) + { + BOOST_TEST( !fs::exists( fs::path( "//share-not" ) ) ); + BOOST_TEST( !fs::exists( fs::path( "//share-not/" ) ) ); + BOOST_TEST( !fs::exists( fs::path( "//share-not/foo" ) ) ); + BOOST_TEST( !fs::exists( "tools/jam/src/:sys:stat.h" ) ); // !exists() if ERROR_INVALID_NAME + BOOST_TEST( !fs::exists( ":sys:stat.h" ) ); // !exists() if ERROR_INVALID_PARAMETER + BOOST_TEST( !fs::exists( "1:/" ) ); + BOOST_TEST( dir.string().size() > 1 + && dir.string()[1] == ':' ); // verify path includes drive + + BOOST_TEST( fs::system_complete( "" ).empty() ); + BOOST_TEST( fs::system_complete( "/" ).string() + == fs::initial_path<fs::path>().root_path().string() ); + BOOST_TEST( fs::system_complete( "foo" ).string() + == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::system_complete( "/foo" ).string() + == fs::initial_path<fs::path>().root_path().string()+"foo" ); + BOOST_TEST( fs::complete( fs::path( "c:/" ) ).string() + == "c:/" ); + BOOST_TEST( fs::complete( fs::path( "c:/foo" ) ).string() + == "c:/foo" ); + + BOOST_TEST( fs::system_complete( fs::path( fs::initial_path<fs::path>().root_name() ) ).string() == fs::initial_path<fs::path>().string() ); + BOOST_TEST( fs::system_complete( fs::path( fs::initial_path<fs::path>().root_name() + + "foo" ) ).string() == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::system_complete( fs::path( "c:/" ) ).string() + == "c:/" ); + BOOST_TEST( fs::system_complete( fs::path( "c:/foo" ) ).string() + == "c:/foo" ); + BOOST_TEST( fs::system_complete( fs::path( "//share" ) ).string() + == "//share" ); + } // Windows + + else if ( platform == "POSIX" ) + { + BOOST_TEST( fs::system_complete( "" ).empty() ); + BOOST_TEST( fs::initial_path<fs::path>().root_path().string() == "/" ); + BOOST_TEST( fs::system_complete( "/" ).string() == "/" ); + BOOST_TEST( fs::system_complete( "foo" ).string() + == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::system_complete( "/foo" ).string() + == fs::initial_path<fs::path>().root_path().string()+"foo" ); + } // POSIX + + // the bound functions should throw, so CHECK_EXCEPTION() should return true + BOOST_TEST( CHECK_EXCEPTION( bad_file_size, ENOENT ) ); + + // test path::exception members + try { fs::file_size( ng ); } // will throw + + catch ( const fs::filesystem_error & ex ) + { + BOOST_TEST( ex.path1().string() == " no-way, Jose" ); + } + // several functions give unreasonable results if uintmax_t isn't 64-bits + std::cout << "sizeof(boost::uintmax_t) = " << sizeof(boost::uintmax_t) << '\n'; + BOOST_TEST( sizeof( boost::uintmax_t ) >= 8 ); + + // set the current directory, then check it for consistency + fs::path original_dir = fs::current_path<fs::path>(); + BOOST_TEST( dir != original_dir ); + fs::current_path( dir ); + BOOST_TEST( fs::current_path<fs::path>() == dir ); + BOOST_TEST( fs::current_path<fs::path>() != original_dir ); + fs::current_path( original_dir ); + BOOST_TEST( fs::current_path<fs::path>() == original_dir ); + BOOST_TEST( fs::current_path<fs::path>() != dir ); + // make sure the overloads work + fs::current_path( dir.string().c_str() ); + BOOST_TEST( fs::current_path<fs::path>() == dir ); + BOOST_TEST( fs::current_path<fs::path>() != original_dir ); + fs::current_path( original_dir.string() ); + BOOST_TEST( fs::current_path<fs::path>() == original_dir ); + BOOST_TEST( fs::current_path<fs::path>() != dir ); + + // make some reasonable assuptions for testing purposes + fs::space_info spi( fs::space( dir ) ); + BOOST_TEST( spi.capacity > 1000000 ); + BOOST_TEST( spi.free > 1000 ); + BOOST_TEST( spi.capacity > spi.free ); + BOOST_TEST( spi.free >= spi.available ); + + // it is convenient to display space, but older VC++ versions choke +# if !defined(BOOST_MSVC) || _MSC_VER >= 1300 // 1300 == VC++ 7.0 + std::cout << " capacity = " << spi.capacity << '\n'; + std::cout << " free = " << spi.free << '\n'; + std::cout << "available = " << spi.available << '\n'; +# endif + + if ( platform == "Windows" ) + BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, ENOENT ) ); + else + BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, 0 ) ); + BOOST_TEST( !fs::create_directory( dir ) ); + + BOOST_TEST( !fs::is_symlink( dir ) ); + BOOST_TEST( !fs::is_symlink( "nosuchfileordirectory" ) ); + + fs::path d1( dir / "d1" ); + BOOST_TEST( fs::create_directory( d1 ) ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::is_directory( d1 ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( d1 ) ); + +// boost::function_requires< boost::InputIteratorConcept< fs::directory_iterator > >(); + + bool dir_itr_exception(false); + try { fs::directory_iterator it( "" ); } + catch ( const fs::filesystem_error & ) { dir_itr_exception = true; } + BOOST_TEST( dir_itr_exception ); + + dir_itr_exception = false; + try { fs::directory_iterator it( "nosuchdirectory" ); } + catch ( const fs::filesystem_error & ) { dir_itr_exception = true; } + BOOST_TEST( dir_itr_exception ); + + dir_itr_exception = false; + try + { + error_code ec; + fs::directory_iterator it( "nosuchdirectory", ec ); + BOOST_TEST( ec ); + BOOST_TEST( ec == fs::detail::not_found_error() ); + } + catch ( const fs::filesystem_error & ) { dir_itr_exception = true; } + BOOST_TEST( !dir_itr_exception ); + + { + // probe query function overloads + fs::directory_iterator dir_itr( dir ); + BOOST_TEST( fs::is_directory( *dir_itr ) ); + BOOST_TEST( fs::is_directory( dir_itr->status() ) ); + BOOST_TEST( fs::is_directory( fs::symlink_status(*dir_itr) ) ); + BOOST_TEST( fs::is_directory( dir_itr->symlink_status() ) ); + BOOST_TEST( dir_itr->path().filename() == "d1" ); + } + + // create a second directory named d2 + fs::path d2( dir / "d2" ); + fs::create_directory(d2 ); + BOOST_TEST( fs::exists( d2 ) ); + BOOST_TEST( fs::is_directory( d2 ) ); + + // test the basic operation of directory_iterators, and test that + // stepping one iterator doesn't affect a different iterator. + { + fs::directory_iterator dir_itr( dir ); + BOOST_TEST( fs::exists(dir_itr->status()) ); + BOOST_TEST( fs::is_directory(dir_itr->status()) ); + BOOST_TEST( !fs::is_regular_file(dir_itr->status()) ); + BOOST_TEST( !fs::is_other(dir_itr->status()) ); + BOOST_TEST( !fs::is_symlink(dir_itr->status()) ); + + fs::directory_iterator dir_itr2( dir ); + BOOST_TEST( dir_itr->path().filename() == "d1" + || dir_itr->path().filename() == "d2" ); + BOOST_TEST( dir_itr2->path().filename() == "d1" || dir_itr2->path().filename() == "d2" ); + if ( dir_itr->path().filename() == "d1" ) + { + BOOST_TEST( (++dir_itr)->path().filename() == "d2" ); + BOOST_TEST( dir_itr2->path().filename() == "d1" ); + BOOST_TEST( (++dir_itr2)->path().filename() == "d2" ); + } + else + { + BOOST_TEST( dir_itr->path().filename() == "d2" ); + BOOST_TEST( (++dir_itr)->path().filename() == "d1" ); + BOOST_TEST( (dir_itr2)->path().filename() == "d2" ); + BOOST_TEST( (++dir_itr2)->path().filename() == "d1" ); + } + BOOST_TEST( ++dir_itr == fs::directory_iterator() ); + BOOST_TEST( dir_itr2 != fs::directory_iterator() ); + BOOST_TEST( ++dir_itr2 == fs::directory_iterator() ); + } + + { // *i++ must work to meet the standard's InputIterator requirements + fs::directory_iterator dir_itr( dir ); + BOOST_TEST( dir_itr->path().filename() == "d1" + || dir_itr->path().filename() == "d2" ); + if ( dir_itr->path().filename() == "d1" ) + { + BOOST_TEST( (*dir_itr++).path().filename() == "d1" ); + BOOST_TEST( dir_itr->path().filename() == "d2" ); + } + else + { + // Check C++98 input iterator requirements + BOOST_TEST( (*dir_itr++).path().filename() == "d2" ); + // input iterator requirements in the current WP would require this check: + // BOOST_TEST( implicit_cast<std::string const&>(*dir_itr++).filename() == "d1" ); + + BOOST_TEST( dir_itr->path().filename() == "d1" ); + } + + // test case reported in comment to SourceForge bug tracker [937606] + fs::directory_iterator it( dir ); + const fs::path p1 = *it++; + BOOST_TEST( it != fs::directory_iterator() ); + const fs::path p2 = *it++; + BOOST_TEST( p1 != p2 ); + BOOST_TEST( it == fs::directory_iterator() ); + } + + // Windows has a tricky special case when just the root-name is given, + // causing the rest of the path to default to the current directory. + // Reported as S/F bug [ 1259176 ] + if ( platform == "Windows" ) + { + fs::path root_name_path( fs::current_path<fs::path>().root_name() ); + fs::directory_iterator it( root_name_path ); + BOOST_TEST( it != fs::directory_iterator() ); + BOOST_TEST( fs::exists( *it ) ); + BOOST_TEST( it->path().parent_path() == root_name_path ); + bool found(false); + do + { + if ( it->path().filename() == temp_dir_name ) found = true; + } while ( ++it != fs::directory_iterator() ); + BOOST_TEST( found ); + } + + // create an empty file named "f0" + fs::path file_ph( dir / "f0"); + create_file( file_ph, "" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( file_ph ) ); + BOOST_TEST( fs::file_size( file_ph ) == 0 ); + bad_create_directory_path = file_ph; + BOOST_TEST( CHECK_EXCEPTION( bad_create_directory, EEXIST ) ); + stat = fs::status( file_ph ); + BOOST_TEST( fs::status_known( stat ) ); + BOOST_TEST( fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + + // create a file named "f1" + file_ph = dir / "f1"; + create_file( file_ph, "foobar1" ); + + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + BOOST_TEST( fs::file_size( file_ph ) == 7 ); + verify_file( file_ph, "foobar1" ); + + // equivalence tests + BOOST_TEST( CHECK_EXCEPTION( bad_equivalent, ENOENT ) ); + BOOST_TEST( fs::equivalent( file_ph, dir / "f1" ) ); + BOOST_TEST( fs::equivalent( dir, d1 / ".." ) ); + BOOST_TEST( !fs::equivalent( file_ph, dir ) ); + BOOST_TEST( !fs::equivalent( dir, file_ph ) ); + BOOST_TEST( !fs::equivalent( d1, d2 ) ); + BOOST_TEST( !fs::equivalent( dir, ng ) ); + BOOST_TEST( !fs::equivalent( ng, dir ) ); + BOOST_TEST( !fs::equivalent( file_ph, ng ) ); + BOOST_TEST( !fs::equivalent( ng, file_ph ) ); + + // hard link tests + fs::path from_ph( dir / "f3" ); + BOOST_TEST( !fs::exists( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + bool create_hard_link_ok(true); + try { fs::create_hard_link( file_ph, from_ph ); } + catch ( const fs::filesystem_error & ex ) + { + create_hard_link_ok = false; + std::cout + << "create_hard_link() attempt failed\n" + << "filesystem_error.what() reports: " << ex.what() << '\n' + << "create_hard_link() may not be supported on this file system\n"; + } + + if ( create_hard_link_ok ) + { + std::cout << "create_hard_link(\"" << file_ph << "\", \"" + << from_ph << "\") succeeded\n"; + BOOST_TEST( fs::exists( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( fs::equivalent( from_ph, file_ph ) ); + } + + error_code ec; + BOOST_TEST( fs::create_hard_link( fs::path("doesnotexist"), + fs::path("shouldnotwork"), ec ) ); + BOOST_TEST( ec ); + + // symbolic link tests + from_ph = dir / "f4"; + BOOST_TEST( !fs::exists( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + bool create_symlink_ok(true); + try { fs::create_symlink( file_ph, from_ph ); } + catch ( const fs::filesystem_error & ex ) + { + create_symlink_ok = false; + std::cout + << "create_symlink() attempt failed\n" + << "filesystem_error.what() reports: " << ex.what() << '\n' + << "create_symlink() may not be supported on this file system\n"; + } + + if ( create_symlink_ok ) + { + std::cout << "create_symlink() succeeded\n"; + BOOST_TEST( fs::exists( from_ph ) ); + BOOST_TEST( fs::is_symlink( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( fs::equivalent( from_ph, file_ph ) ); + stat = fs::symlink_status( from_ph ); + BOOST_TEST( fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( fs::is_symlink( stat ) ); + } + + ec = error_code(); + BOOST_TEST( fs::create_symlink( "doesnotexist", "", ec ) ); + BOOST_TEST( ec ); + + // there was an inital bug in directory_iterator that caused premature + // close of an OS handle. This block will detect regression. + { + fs::directory_iterator di; + { di = fs::directory_iterator( dir ); } + BOOST_TEST( ++di != fs::directory_iterator() ); + } + + // copy_file() tests + std::cout << "begin copy_file test..." << std::endl; + fs::copy_file( file_ph, d1 / "f2" ); + std::cout << "copying complete" << std::endl; + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::is_directory( d1 / "f2" ) ); + verify_file( d1 / "f2", "foobar1" ); + + bool copy_ex_ok = false; + try { fs::copy_file( file_ph, d1 / "f2" ); } + catch ( const fs::filesystem_error & ) { copy_ex_ok = true; } + BOOST_TEST( copy_ex_ok ); + + copy_ex_ok = false; + try { fs::copy_file( file_ph, d1 / "f2", fs::copy_option::fail_if_exists ); } + catch ( const fs::filesystem_error & ) { copy_ex_ok = true; } + BOOST_TEST( copy_ex_ok ); + + copy_ex_ok = true; + try { fs::copy_file( file_ph, d1 / "f2", fs::copy_option::overwrite_if_exists ); } + catch ( const fs::filesystem_error & ) { copy_ex_ok = false; } + BOOST_TEST( copy_ex_ok ); + + std::cout << "copy_file test complete" << std::endl; + + // rename() test case numbers refer to operations.htm#rename table + + // [case 1] make sure can't rename() a non-existent file + BOOST_TEST( !fs::exists( d1 / "f99" ) ); + BOOST_TEST( !fs::exists( d1 / "f98" ) ); + renamer n1a( d1 / "f99", d1 / "f98" ); + BOOST_TEST( CHECK_EXCEPTION( n1a, ENOENT ) ); + renamer n1b( fs::path(""), d1 / "f98" ); + BOOST_TEST( CHECK_EXCEPTION( n1b, ENOENT ) ); + + // [case 2] rename() target.empty() + renamer n2( file_ph, "" ); + BOOST_TEST( CHECK_EXCEPTION( n2, ENOENT ) ); + + // [case 3] make sure can't rename() to an existent file or directory + BOOST_TEST( fs::exists( dir / "f1" ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + renamer n3a( dir / "f1", d1 / "f2" ); + BOOST_TEST( CHECK_EXCEPTION( n3a, EEXIST ) ); + // several POSIX implementations (cygwin, openBSD) report ENOENT instead of EEXIST, + // so we don't verify error type on the above test. + renamer n3b( dir, d1 ); + BOOST_TEST( CHECK_EXCEPTION( n3b, 0 ) ); + + // [case 4A] can't rename() file to a nonexistent parent directory + BOOST_TEST( !fs::is_directory( dir / "f1" ) ); + BOOST_TEST( !fs::exists( dir / "d3/f3" ) ); + renamer n4a( dir / "f1", dir / "d3/f3" ); + BOOST_TEST( CHECK_EXCEPTION( n4a, ENOENT ) ); + + // [case 4B] rename() file in same directory + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d1 / "f50" ) ); + fs::rename( d1 / "f2", d1 / "f50" ); + BOOST_TEST( !fs::exists( d1 / "f2" ) ); + BOOST_TEST( fs::exists( d1 / "f50" ) ); + fs::rename( d1 / "f50", d1 / "f2" ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d1 / "f50" ) ); + + // [case 4C] rename() file d1/f2 to d2/f3 + fs::rename( d1 / "f2", d2 / "f3" ); + BOOST_TEST( !fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d2 / "f2" ) ); + BOOST_TEST( fs::exists( d2 / "f3" ) ); + BOOST_TEST( !fs::is_directory( d2 / "f3" ) ); + verify_file( d2 / "f3", "foobar1" ); + fs::rename( d2 / "f3", d1 / "f2" ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + + // [case 5A] rename() directory to nonexistent parent directory + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( !fs::exists( dir / "d3/d5" ) ); + BOOST_TEST( !fs::exists( dir / "d3" ) ); + renamer n5a( d1, dir / "d3/d5" ); + BOOST_TEST( CHECK_EXCEPTION( n5a, ENOENT ) ); + + // [case 5B] rename() on directory + fs::path d3( dir / "d3" ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d3 ) ); + fs::rename( d1, d3 ); + BOOST_TEST( !fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d3 ) ); + BOOST_TEST( fs::is_directory( d3 ) ); + BOOST_TEST( !fs::exists( d1 / "f2" ) ); + BOOST_TEST( fs::exists( d3 / "f2" ) ); + fs::rename( d3, d1 ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d3 ) ); + + // [case 5C] rename() rename and move d1 to d2 / "d20" + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( !fs::exists( d2 / "d20" ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + fs::rename( d1, d2 / "d20" ); + BOOST_TEST( !fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d2 / "d20" ) ); + BOOST_TEST( fs::exists( d2 / "d20" / "f2" ) ); + fs::rename( d2 / "d20", d1 ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( !fs::exists( d2 / "d20" ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + + // remove() file + file_ph = dir / "shortlife"; + BOOST_TEST( !fs::exists( file_ph ) ); + create_file( file_ph, "" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::remove( file_ph ) ); + BOOST_TEST( !fs::exists( file_ph ) ); + BOOST_TEST( !fs::remove( "no-such-file" ) ); + BOOST_TEST( !fs::remove( "no-such-directory/no-such-file" ) ); + + // remove() directory + d1 = dir / "shortlife_dir"; + BOOST_TEST( !fs::exists( d1 ) ); + fs::create_directory( d1 ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::is_directory( d1 ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( d1 ) ); + bad_remove_dir = dir; + BOOST_TEST( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) ); + BOOST_TEST( fs::remove( d1 ) ); + BOOST_TEST( !fs::exists( d1 ) ); + + if ( create_symlink_ok ) // only if symlinks supported + { + // remove() dangling symbolic link + fs::path link( "dangling_link" ); + fs::remove( link ); // remove any residue from past tests + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( !fs::exists( link ) ); + fs::create_symlink( "nowhere", link ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( fs::is_symlink( link ) ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + + // remove() self-refering symbolic link + link = "link_to_self"; + fs::remove( link ); // remove any residue from past tests + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( !fs::exists( link ) ); + fs::create_symlink( link, link ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + + // remove() cyclic symbolic link + link = "link_to_a"; + fs::path link2( "link_to_b" ); + fs::remove( link ); // remove any residue from past tests + fs::remove( link2 ); // remove any residue from past tests + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( !fs::exists( link ) ); + fs::create_symlink( link, link2 ); + fs::create_symlink( link2, link ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( fs::remove( link2 ) ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( !fs::exists( link2 ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + + // remove() symbolic link to file + file_ph = "link_target"; + fs::remove( file_ph ); // remove any residue from past tests + BOOST_TEST( !fs::exists( file_ph ) ); + create_file( file_ph, "" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + link = "non_dangling_link"; + fs::create_symlink( file_ph, link ); + BOOST_TEST( fs::exists( link ) ); + BOOST_TEST( !fs::is_directory( link ) ); + BOOST_TEST( fs::is_regular_file( link ) ); + BOOST_TEST( fs::is_symlink( link ) ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( fs::remove( file_ph ) ); + BOOST_TEST( !fs::exists( file_ph ) ); + } + + // write time tests + + file_ph = dir / "foobar2"; + create_file( file_ph, "foobar2" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + BOOST_TEST( fs::file_size( file_ph ) == 7 ); + verify_file( file_ph, "foobar2" ); + + // Some file system report last write time as local (FAT), while + // others (NTFS) report it as UTC. The C standard does not specify + // if time_t is local or UTC. + + std::time_t ft = fs::last_write_time( file_ph ); + std::cout << "\nUTC last_write_time() for a file just created is " + << std::asctime(std::gmtime(&ft)) << std::endl; + + std::tm * tmp = std::localtime( &ft ); + std::cout << "\nYear is " << tmp->tm_year << std::endl; + --tmp->tm_year; + std::cout << "Change year to " << tmp->tm_year << std::endl; + fs::last_write_time( file_ph, std::mktime( tmp ) ); + std::time_t ft2 = fs::last_write_time( file_ph ); + std::cout << "last_write_time() for the file is now " + << std::asctime(std::gmtime(&ft2)) << std::endl; + BOOST_TEST( ft != fs::last_write_time( file_ph ) ); + + + std::cout << "\nReset to current time" << std::endl; + fs::last_write_time( file_ph, ft ); + double time_diff = std::difftime( ft, fs::last_write_time( file_ph ) ); + std::cout + << "original last_write_time() - current last_write_time() is " + << time_diff << " seconds" << std::endl; + BOOST_TEST( time_diff >= -60.0 && time_diff <= 60.0 ); + + // post-test cleanup + BOOST_TEST( fs::remove_all( dir ) != 0 ); + // above was added just to simplify testing, but it ended up detecting + // a bug (failure to close an internal search handle). + BOOST_TEST( !fs::exists( dir ) ); + BOOST_TEST( fs::remove_all( dir ) == 0 ); + + return ::boost::report_errors(); +} // main + Added: trunk/dsim/test/boost/filesystem/path_test.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/path_test.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/path_test.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,1366 @@ +// path_test program -------------------------------------------------------// +// Copyright Beman Dawes 2002 +// Copyright Vladimir Prus 2002 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// See library home page at http://www.boost.org/libs/filesystem +// basic_path's stem(), extension(), and replace_extension() tests are based +// on basename(), extension(), and change_extension() tests from the original +// convenience_test.cpp by Vladimir Prus. +// See deprecated_test for tests of deprecated features +#define BOOST_FILESYSTEM_NO_DEPRECATED +// STL +#include <iostream> +#include <sstream> +#include <string> +#include <vector> +#include <cstring> +#include <cassert> +// Boost +#include <boost/filesystem/operations.hpp> +#include <boost/utility.hpp> + +namespace fs = boost::filesystem; +using boost::filesystem::path; + + +#include <boost/detail/lightweight_test.hpp> + +#define PATH_CHECK( a, b ) check( a, b, __LINE__ ) +#define DIR_CHECK( a, b ) check_dir( a, b, __LINE__ ) +#define CHECK_EQUAL( a,b ) check_equal( a, b, __LINE__ ) + + +namespace { + + std::string platform( BOOST_PLATFORM ); + + void check( const fs::path & source, + const std::string & expected, int line ) + { + if ( source.string()== expected ) return; + + ++::boost::detail::test_errors(); + + std::cout << '(' << line << ") source.string(): \"" << source.string() + << "\" != expected: \"" << expected + << "\"" << std::endl; + } + + void check_dir( const fs::path & source, + const std::string & expected, int line ) + { + if ( source.directory_string()== expected ) return; + + ++::boost::detail::test_errors(); + + std::cout << '(' << line << ") source.directory_string(): \"" + << source.directory_string() + << "\" != expected: \"" << expected + << "\"" << std::endl; + } + + void check_equal( const std::string & value, + const std::string & expected, int line ) + { + if ( value == expected ) return; + + ++::boost::detail::test_errors(); + + std::cout << '(' << line << ") value: \"" << value + << "\" != expected: \"" << expected + << "\"" << std::endl; + } + + + void exception_tests() + { + const std::string str_1("string-1"); + boost::system::error_code ec( 12345, boost::system::system_category); + try { throw fs::filesystem_error( str_1, ec ); } + catch ( const fs::filesystem_error & ex ) + { + //std::cout << ex.what() << "*" << std::endl; + //BOOST_TEST( std::strcmp( ex.what(), + // "string-1: Unknown error" ) == 0 ); + BOOST_TEST( ex.code() == ec ); + } + + try { throw fs::filesystem_error( str_1, "p1", "p2", ec ); } + catch ( const fs::filesystem_error & ex ) + { + //std::cout << ex.what() << "*" << std::endl; + //BOOST_TEST( std::strcmp( ex.what(), + // "string-1: Unknown error: \"p1\", \"p2\"" ) == 0 ); + BOOST_TEST( ex.code() == ec ); + BOOST_TEST( ex.path1().string() == "p1" ); + BOOST_TEST( ex.path2().string() == "p2" ); + } + } + + + // name_function_tests ---------------------------------------------------// + + void name_function_tests() + { + std::cout << "name_function_tests..." << std::endl; + + BOOST_TEST( fs::portable_posix_name( std::string( "x" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "x" ) ) ); + BOOST_TEST( fs::portable_name( std::string( "x" ) ) ); + BOOST_TEST( fs::portable_directory_name( std::string( "x" ) ) ); + BOOST_TEST( fs::portable_file_name( std::string( "x" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "." ) ) ); + BOOST_TEST( fs::windows_name( std::string( "." ) ) ); + BOOST_TEST( fs::portable_name( std::string( "." ) ) ); + BOOST_TEST( fs::portable_directory_name( std::string( "." ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "." ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( ".." ) ) ); + BOOST_TEST( fs::windows_name( std::string( ".." ) ) ); + BOOST_TEST( fs::portable_name( std::string( ".." ) ) ); + BOOST_TEST( fs::portable_directory_name( std::string( ".." ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( ".." ) ) ); + + BOOST_TEST( !fs::native( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_posix_name( std::string( "" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "" ) ) ); + + BOOST_TEST( !fs::native( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_posix_name( std::string( " " ) ) ); + BOOST_TEST( !fs::windows_name( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_name( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( " " ) ) ); + + BOOST_TEST( !fs::portable_posix_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( ":" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "-" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "-" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "-" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "-" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "-" ) ) ); + + BOOST_TEST( !fs::portable_posix_name( std::string( "foo bar" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "foo bar" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( " bar" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( "foo " ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "foo bar" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo bar" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "foo bar" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( fs::portable_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( fs::portable_file_name( std::string( "foo.bar" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( fs::portable_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "foo.barf" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( ".foo" ) ) ); + BOOST_TEST( fs::windows_name( std::string( ".foo" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( ".foo" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( ".foo" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( ".foo" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::windows_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "foo." ) ) ); + } + +} // unnamed namespace + +int main( int, char*[] ) +{ + // The choice of platform is make at runtime rather than compile-time + // so that compile errors for all platforms will be detected even though + // only the current platform is runtime tested. + platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" ) + ? "Windows" + : "POSIX"; + std::cout << "Platform is " << platform << '\n'; + + path p1( "fe/fi/fo/fum" ); + path p2( p1 ); + path p3; + BOOST_TEST( p1.string() != p3.string() ); + + // check each overload + BOOST_TEST( p1 != p3 ); + BOOST_TEST( p1 != p3.string() ); + BOOST_TEST( p1 != p3.string().c_str() ); + BOOST_TEST( p1.string() != p3 ); + BOOST_TEST( p1.string().c_str() != p3 ); + + p3 = p2; + BOOST_TEST( p1.string() == p3.string() ); + + // check each overload + BOOST_TEST( p1 == p3 ); + BOOST_TEST( p1 == p3.string() ); + BOOST_TEST( p1 == p3.string().c_str() ); + BOOST_TEST( p1.string() == p3 ); + BOOST_TEST( p1.string().c_str() == p3 ); + + path p4( "foobar" ); + BOOST_TEST( p4.string() == "foobar" ); + p4 = p4; // self-assignment + BOOST_TEST( p4.string() == "foobar" ); + + if ( platform == "Windows" ) + { + path p10 ("c:\\file"); + path p11 ("c:/file"); + // check each overload + BOOST_TEST( p10.string() == p11.string() ); + BOOST_TEST( p10 == p11 ); + BOOST_TEST( p10 == p11.string() ); + BOOST_TEST( p10 == p11.string().c_str() ); + BOOST_TEST( p10.string() == p11 ); + BOOST_TEST( p10.string().c_str() == p11 ); + BOOST_TEST( p10 == "c:\\file" ); + BOOST_TEST( p10 == "c:/file" ); + BOOST_TEST( p11 == "c:\\file" ); + BOOST_TEST( p11 == "c:/file" ); + BOOST_TEST( "c:\\file" == p10 ); + BOOST_TEST( "c:/file" == p10 ); + BOOST_TEST( "c:\\file" == p11 ); + BOOST_TEST( "c:/file" == p11 ); + } + + exception_tests(); + name_function_tests(); + + // These verify various overloads don't cause compiler errors + + fs::exists( p1 ); + fs::exists( "foo" ); + fs::exists( std::string( "foo" ) ); + + fs::exists( p1 / path( "foo" ) ); + fs::exists( p1 / "foo" ); + fs::ex... [truncated message content] |