You can subscribe to this list here.
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(5) |
Aug
|
Sep
|
Oct
(51) |
Nov
(8) |
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(32) |
Feb
(47) |
Mar
(6) |
Apr
(19) |
May
(7) |
Jun
(19) |
Jul
(39) |
Aug
(51) |
Sep
(39) |
Oct
(18) |
Nov
(10) |
Dec
(27) |
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <den...@us...> - 2010-02-07 19:43:36
|
Revision: 120 http://stdair.svn.sourceforge.net/stdair/?rev=120&view=rev Author: denis_arnaud Date: 2010-02-07 19:43:30 +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/stdair/stdair/Makefile.am trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/bom/BomRoot.cpp trunk/stdair/stdair/bom/BomRoot.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/service/STDAIR_Service.cpp Added Paths: ----------- trunk/stdair/stdair/command/CmdAbstract.cpp trunk/stdair/stdair/command/CmdAbstract.hpp trunk/stdair/stdair/command/DBManagerForAirlines.cpp trunk/stdair/stdair/command/DBManagerForAirlines.hpp trunk/stdair/stdair/command/Makefile.am trunk/stdair/stdair/command/sources.mk Property Changed: ---------------- trunk/stdair/stdair/command/ Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/Makefile.am 2010-02-07 19:43:30 UTC (rev 120) @@ -6,7 +6,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic bom dbadaptor factory config service core +SUBDIRS = basic bom dbadaptor factory command config service core #EXTRA_DIST = config_msvc.h EXTRA_DIST = Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -14,7 +14,7 @@ // Forward declarations class BomRoot; - + class Inventory; /** Interface for the STDAIR Services. */ class STDAIR_Service { @@ -43,6 +43,12 @@ ~STDAIR_Service(); + /** Retrieve the Inventory corresponding to the given airline code + (Inventory key). + <br>If not existing, a ObjectNotFoundException exception is thrown. */ + Inventory& getInventory (const AirlineCode_T& iAirlineCode) const; + + // ///////////////// Getters /////////////////// /** Get a reference on the BomRoot object. <br>If the service context has not been initialised, that @@ -51,6 +57,17 @@ return _bomRoot; } + public: + // /////// Construction and Destruction helper methods /////// + /** Retrieve the Inventory corresponding to the given airline code + (Inventory key). + <br>If not existing, a ObjectNotFoundException exception is thrown. */ + Inventory& createInventory (const AirlineCode_T& iAirlineCode) const; + + /** Add the airline-specific AirlineFeature object to its AirlineFeatureSet + parent. */ + void addAirlineFeature (const AirlineCode_T& iAirlineCode) const; + private: // /////// Construction and Destruction helper methods /////// @@ -76,6 +93,10 @@ in order to secure the access to the corresponding resources. */ void init (); + /** Initialise the AirlineFeatureSet object, and attach it to the + BomRoot. */ + void initAirlineFeatureSet (); + /** Finalise. */ void finalise (); Modified: trunk/stdair/stdair/bom/BomRoot.cpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/bom/BomRoot.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -70,4 +70,10 @@ return oNetwork_ptr; } + // //////////////////////////////////////////////////////////////////// + AirlineFeatureSet& BomRoot::getAirlineFeatureSet() const { + assert (_airlineFeatureSet != NULL); + return *_airlineFeatureSet; + } + } Modified: trunk/stdair/stdair/bom/BomRoot.hpp =================================================================== --- trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/bom/BomRoot.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -117,10 +117,7 @@ NetworkMap_T getNetworkMap () const; /** Get the reference of the AirlineFeatureSet object. */ - const AirlineFeatureSet& getAirlineFeatureSet() const { - assert (_airlineFeatureSet != NULL); - return *_airlineFeatureSet; - } + AirlineFeatureSet& getAirlineFeatureSet() const; /** Retrieve, if existing, the Inventory corresponding to the given airline code (Inventory key). @@ -135,7 +132,7 @@ public: // //////////// Setters ////////////// /** Set the reference to the AirlineFeatureSet object. */ - void setAirlineFeatureSet (const AirlineFeatureSet* ioAirlineFeatureSet_ptr){ + void setAirlineFeatureSet (AirlineFeatureSet* ioAirlineFeatureSet_ptr) { _airlineFeatureSet = ioAirlineFeatureSet_ptr; } @@ -161,7 +158,7 @@ BomStructure_T& _bomRootStructure; /** Set of all AirlineFeatures.*/ - const AirlineFeatureSet* _airlineFeatureSet; + AirlineFeatureSet* _airlineFeatureSet; }; } Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -33,7 +33,10 @@ // ////////////////////////////////////////////////////////////////////// const std::string BookingRequestStruct::describe() const { - return ""; + std::ostringstream oStr; + oStr << _origin << " - " << _destination << " " << _departureDate + << " " << _paxType << " " << _partySize; + return oStr.str(); } } Property changes on: trunk/stdair/stdair/command ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile Added: trunk/stdair/stdair/command/CmdAbstract.cpp =================================================================== --- trunk/stdair/stdair/command/CmdAbstract.cpp (rev 0) +++ trunk/stdair/stdair/command/CmdAbstract.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,9 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/command/CmdAbstract.hpp> + +namespace stdair { + +} Added: trunk/stdair/stdair/command/CmdAbstract.hpp =================================================================== --- trunk/stdair/stdair/command/CmdAbstract.hpp (rev 0) +++ trunk/stdair/stdair/command/CmdAbstract.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,17 @@ +#ifndef __STDAIR_CMD_CMDABSTRACT_HPP +#define __STDAIR_CMD_CMDABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// + +namespace stdair { + + /** Base class for the Command layer. */ + class CmdAbstract { + public: + + }; + +} +#endif // __STDAIR_CMD_CMDABSTRACT_HPP Added: trunk/stdair/stdair/command/DBManagerForAirlines.cpp =================================================================== --- trunk/stdair/stdair/command/DBManagerForAirlines.cpp (rev 0) +++ trunk/stdair/stdair/command/DBManagerForAirlines.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,167 @@ +// ////////////////////////////////////////////////////////////////////// +// 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> +// Stdair +#include <stdair/command/DBManagerForAirlines.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + void DBManagerForAirlines:: + prepareSelectStatement (DBSession_T& ioSociSession, + DBRequestStatement_T& ioSelectStatement, + 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 DBManagerForAirlines:: + prepareSelectOnAirlineCodeStatement (DBSession_T& ioSociSession, + DBRequestStatement_T& ioSelectStatement, + const AirlineCode_T& iAirlineCode, + 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 DBManagerForAirlines:: + iterateOnStatement (DBRequestStatement_T& ioStatement, + 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 DBManagerForAirlines::updateAirlineInDB (DBSession_T& ioSociSession, + const 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) + 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 DBManagerForAirlines::retrieveAirline (DBSession_T& ioSociSession, + const AirlineCode_T& iAirlineCode, + AirlineStruct& ioAirline) { + bool oHasRetrievedAirline = false; + + try { + + // Prepare the SQL request corresponding to the select statement + DBRequestStatement_T lSelectStatement (ioSociSession); + 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/stdair/stdair/command/DBManagerForAirlines.hpp =================================================================== --- trunk/stdair/stdair/command/DBManagerForAirlines.hpp (rev 0) +++ trunk/stdair/stdair/command/DBManagerForAirlines.hpp 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,74 @@ +#ifndef __DSIM_CMD_DBMANAGERFORAIRLINES_HPP +#define __DSIM_CMD_DBMANAGERFORAIRLINES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/command/CmdAbstract.hpp> + +namespace stdair { + + // Forward declarations + struct AirlineStruct; + + /** Class building the Business Object Model (BOM) from data retrieved + from the database. */ + class DBManagerForAirlines : public CmdAbstract { + public: + /** Update the fields of the database row + corresponding to the given BOM object. + @parameter DBSession_T& + @parameter AirlineStruct& . */ + static void updateAirlineInDB (DBSession_T&, const 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 DBSession_T& + @parameter const AirlineCode_T& + @parameter AirlineStruct& . */ + static bool retrieveAirline (DBSession_T&, const AirlineCode_T&, + AirlineStruct&); + + + public: + /** Prepare (parse and put in cache) the SQL statement. + @parameter DBSession_T& + @parameter DBRequestStatement_T& + @parameter AirlineStruct& . */ + static void prepareSelectStatement (DBSession_T&, DBRequestStatement_T&, + AirlineStruct&); + + /** Iterate on the SQL statement. + <br>The SQL has to be already prepared. + @parameter DBRequestStatement_T& + @parameter AirlineStruct& . */ + static bool iterateOnStatement (DBRequestStatement_T&, AirlineStruct&); + + + private: + /** Prepare (parse and put in cache) the SQL statement. + @parameter DBSession_T& + @parameter DBRequestStatement_T& + @parameter const AirlineCode_T& + @parameter AirlineStruct& */ + static void prepareSelectOnAirlineCodeStatement (DBSession_T&, + DBRequestStatement_T&, + const AirlineCode_T&, + AirlineStruct&); + + + private: + // /////////////////// Constructors and Destructors ////////////// + /** Default constructors. As all the methods are static, there is no + need to use those constructors. */ + DBManagerForAirlines () {} + DBManagerForAirlines (const DBManagerForAirlines&) {} + /** Destructor. */ + ~DBManagerForAirlines () {} + }; + +} +#endif // __DSIM_CMD_DBMANAGERFORAIRLINES_HPP Added: trunk/stdair/stdair/command/Makefile.am =================================================================== --- trunk/stdair/stdair/command/Makefile.am (rev 0) +++ trunk/stdair/stdair/command/Makefile.am 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,16 @@ +## command sub-directory +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +# +noinst_LTLIBRARIES = libcmd.la + +libcmd_la_SOURCES = $(cmd_h_sources) $(cmd_cc_sources) +libcmd_la_CXXFLAGS = $(BOOST_CFLAGS) $(SOCI_CFLAGS) +libcmd_la_LIBADD = +libcmd_la_LDFLAGS = $(BOOST_LIBS) $(SOCI_LIBS) + + +# Header files +pkgincludedir = $(includedir)/stdair/command +pkginclude_HEADERS = $(cmd_h_sources) Added: trunk/stdair/stdair/command/sources.mk =================================================================== --- trunk/stdair/stdair/command/sources.mk (rev 0) +++ trunk/stdair/stdair/command/sources.mk 2010-02-07 19:43:30 UTC (rev 120) @@ -0,0 +1,6 @@ +cmd_h_sources = \ + $(top_srcdir)/stdair/command/CmdAbstract.hpp \ + $(top_srcdir)/stdair/command/DBManagerForAirlines.hpp +cmd_cc_sources = \ + $(top_srcdir)/stdair/command/CmdAbstract.cpp \ + $(top_srcdir)/stdair/command/DBManagerForAirlines.cpp Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/core/Makefile.am 2010-02-07 19:43:30 UTC (rev 120) @@ -18,6 +18,7 @@ $(top_builddir)/stdair/bom/libbom.la \ $(top_builddir)/stdair/dbadaptor/libdba.la \ $(top_builddir)/stdair/factory/libfac.la \ + $(top_builddir)/stdair/command/libcmd.la \ $(top_builddir)/stdair/service/libsvc.la libstdair_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-07 02:48:33 UTC (rev 119) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-07 19:43:30 UTC (rev 120) @@ -7,8 +7,13 @@ #include <stdair/basic/BasChronometer.hpp> #include <stdair/bom/BomManager.hpp> // for display() #include <stdair/bom/BomRoot.hpp> -#include <stdair/bom/Inventory.hpp> // Child of BomRoot, needed for creation of BomRoot -#include <stdair/bom/Network.hpp> // Child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/AirlineFeatureSet.hpp> +#include <stdair/bom/AirlineFeature.hpp> +// Inventory: child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Inventory.hpp> +// Network: child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Network.hpp> +#include <stdair/bom/FlightDate.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/service/Logger.hpp> @@ -35,6 +40,9 @@ // The root of the BOM tree, on which all of the other BOM objects // will be attached, is being created with the STDAIR_Service constructor. + // Initialise the AirlineFeatureSet object, and attach it to the BomRoot + initAirlineFeatureSet (); + // Set the log file logInit (iLogParams); @@ -49,6 +57,9 @@ // The root of the BOM tree, on which all of the other BOM objects // will be attached, is being created with the STDAIR_Service constructor. + // Initialise the AirlineFeatureSet object, and attach it to the BomRoot + initAirlineFeatureSet (); + // Set the log file logInit (iLogParams); @@ -78,12 +89,92 @@ // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::init () { } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::initAirlineFeatureSet () { + // Initialise the set of required airline features + stdair::AirlineFeatureSet& lAirlineFeatureSet = + stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>(); + + // Set the AirlineFeatureSet for the BomRoot. + _bomRoot.setAirlineFeatureSet (&lAirlineFeatureSet); + } // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service:: + addAirlineFeature (const AirlineCode_T& iAirlineCode) const { + + // Initialise an AirlineFeature object + stdair::AirlineFeatureKey_T lAirlineFeatureKey (iAirlineCode); + stdair::AirlineFeature& lAirlineFeature = stdair::FacBomContent:: + instance().create<stdair::AirlineFeature> (lAirlineFeatureKey); + + // Retrieve the AirlineFeatureSet object + stdair::AirlineFeatureSet& lAirlineFeatureSet = + _bomRoot.getAirlineFeatureSet(); + + // Add the AirlineFeature object to its AirlineFeatureSet parent + stdair::FacBomContent:: + linkWithParent<stdair::AirlineFeature> (lAirlineFeature, + lAirlineFeatureSet); + } + + // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::finalise () { - // std::cout << "In STDAIR_Service destructor, before cleaning" << std::endl; + //std::cout << "In STDAIR_Service destructor, before cleaning" << std::endl; FacSupervisor::cleanAll(); - // std::cout << "In STDAIR_Service destructor, after cleaning" << std::endl; + //std::cout << "In STDAIR_Service destructor, after cleaning" << std::endl; } + // ////////////////////////////////////////////////////////////////////// + Inventory& STDAIR_Service:: + getInventory (const AirlineCode_T& iAirlineCode) const { + + Inventory* lInventory_ptr = _bomRoot.getInventory (iAirlineCode); + if (lInventory_ptr == NULL) { + throw ObjectNotFoundException(); + } + assert (lInventory_ptr != NULL); + + return *lInventory_ptr; + } + + // ////////////////////////////////////////////////////////////////////// + Inventory& STDAIR_Service:: + createInventory (const AirlineCode_T& iAirlineCode) const { + Inventory* lInventory_ptr = _bomRoot.getInventory (iAirlineCode); + + // If there is no Inventory object for that airline already, create one + if (lInventory_ptr == NULL) { + const stdair::InventoryKey_T lInventoryKey (iAirlineCode); + + // Instantiate an Inventory object with the given airline code + lInventory_ptr = + &stdair::FacBomContent::instance(). + create<stdair::Inventory> (lInventoryKey); + assert (lInventory_ptr != NULL); + + // Link the created inventory with the bom root. + stdair::FacBomContent::linkWithParent<stdair::Inventory> (*lInventory_ptr, + _bomRoot); + + // Set the AirlineFeature for the inventory. + const stdair::AirlineFeatureSet& lAirlineFeatureSet = + _bomRoot.getAirlineFeatureSet (); + const stdair::AirlineFeature* lAirlineFeature_ptr = + lAirlineFeatureSet.getAirlineFeature (iAirlineCode); + + // TODO: throw an exception? + if (lAirlineFeature_ptr == NULL) { + STDAIR_LOG_ERROR (lAirlineFeatureSet.display() + << "Needed airline code: " << iAirlineCode); + } + + lInventory_ptr->setAirlineFeature (lAirlineFeature_ptr); + } + assert (lInventory_ptr != NULL); + + return *lInventory_ptr; + } + } 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:48:39
|
Revision: 119 http://stdair.svn.sourceforge.net/stdair/?rev=119&view=rev Author: denis_arnaud Date: 2010-02-07 02:48:33 +0000 (Sun, 07 Feb 2010) Log Message: ----------- [DB] Added support for database administration, as well as a sample table (for airline description). Modified Paths: -------------- trunk/stdair/configure.ac Modified: trunk/stdair/configure.ac =================================================================== --- trunk/stdair/configure.ac 2010-02-07 02:34:52 UTC (rev 118) +++ trunk/stdair/configure.ac 2010-02-07 02:48:33 UTC (rev 119) @@ -278,6 +278,16 @@ o BOOST_PO_LIB .... : ${BOOST_PROGRAM_OPTIONS_LIB} o BOOST_FS_LIB .... : ${BOOST_FILESYSTEM_LIB} + - MySQL ............. : + o MYSQL_version ... : ${MYSQL_VERSION} + o MYSQL_CFLAGS .... : ${MYSQL_CFLAGS} + o MYSQL_LIBS ...... : ${MYSQL_LIBS} + + - SOCI .............. : + o SOCI_version .... : ${SOCI_VERSION} + o SOCI_CFLAGS ..... : ${SOCI_CFLAGS} + o SOCI_LIBS ....... : ${SOCI_LIBS} + - CPPUNIT ........... : o CPPUNIT_VERSION . : ${CPPUNIT_VERSION} o CPPUNIT_CFLAGS .. : ${CPPUNIT_CFLAGS} 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:34:59
|
Revision: 118 http://stdair.svn.sourceforge.net/stdair/?rev=118&view=rev Author: denis_arnaud Date: 2010-02-07 02:34:52 +0000 (Sun, 07 Feb 2010) Log Message: ----------- [DB] Added support for database administration, as well as a sample table (for airline description). Modified Paths: -------------- trunk/stdair/configure.ac trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/core/Makefile.am Modified: trunk/stdair/configure.ac =================================================================== --- trunk/stdair/configure.ac 2010-02-07 02:14:43 UTC (rev 117) +++ trunk/stdair/configure.ac 2010-02-07 02:34:52 UTC (rev 118) @@ -1,8 +1,8 @@ # Process this file with autoconf to produce a configure script #------------------------------------------------------------------- AC_PREREQ(2.59) -AC_COPYRIGHT([Copyright (C) 2007-2009 Denis Arnaud <den...@us...>]) -AC_INIT([STDAIR],[0.1.0],[den...@us...],[stdair]) +AC_COPYRIGHT([Copyright (C) 2007-2010 Denis Arnaud <den...@us...>]) +AC_INIT([STDAIR],[99.99.99],[den...@us...],[stdair]) AC_CONFIG_HEADER([stdair/config.h]) AC_CONFIG_SRCDIR([stdair/bom/BomKey.hpp]) AC_CONFIG_AUX_DIR([config]) @@ -15,7 +15,7 @@ AC_SUBST(RPM_RELEASE) # Shared library versioning -GENERIC_LIBRARY_VERSION="0:1:0" +GENERIC_LIBRARY_VERSION="99:99:99" # | | | # +------+ | +---+ # | | | @@ -117,7 +117,22 @@ AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) AC_SUBST(BOOST_FILESYSTEM_LIB) +# -------------------------------------------------------------------- +# Support for MySQL (C client API): http://www.mysql.org +# -------------------------------------------------------------------- +AX_MYSQL +AC_SUBST(MYSQL_VERSION) +AC_SUBST(MYSQL_CFLAGS) +AC_SUBST(MYSQL_LIBS) +# -------------------------------------------------------------------- +# Support for SOCI http://soci.sourceforge.net +# -------------------------------------------------------------------- +AX_SOCI +AC_SUBST(SOCI_VERSION) +AC_SUBST(SOCI_CFLAGS) +AC_SUBST(SOCI_LIBS) + # ------------------------------------------------------------------- # Support for documentation # ------------------------------------------------------------------- @@ -189,6 +204,7 @@ stdair/Makefile stdair/basic/Makefile stdair/bom/Makefile + stdair/dbadaptor/Makefile stdair/factory/Makefile stdair/service/Makefile stdair/core/Makefile Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-02-07 02:14:43 UTC (rev 117) +++ trunk/stdair/stdair/Makefile.am 2010-02-07 02:34:52 UTC (rev 118) @@ -6,7 +6,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic bom factory config service core +SUBDIRS = basic bom dbadaptor factory config service core #EXTRA_DIST = config_msvc.h EXTRA_DIST = Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-02-07 02:14:43 UTC (rev 117) +++ trunk/stdair/stdair/core/Makefile.am 2010-02-07 02:34:52 UTC (rev 118) @@ -21,7 +21,7 @@ $(top_builddir)/stdair/service/libsvc.la libstdair_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ - $(BOOST_FILESYSTEM_LIB) \ + $(BOOST_FILESYSTEM_LIB) $(SOCI_LIBS) \ -version-info $(GENERIC_LIBRARY_VERSION) # 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:14:50
|
Revision: 117 http://stdair.svn.sourceforge.net/stdair/?rev=117&view=rev Author: denis_arnaud Date: 2010-02-07 02:14:43 +0000 (Sun, 07 Feb 2010) Log Message: ----------- [DB] Now fully support database storage (with a simple example for airline names). Modified Paths: -------------- trunk/stdair/stdair/bom/AirlineStruct.cpp trunk/stdair/stdair/bom/AirlineStruct.hpp trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/service/DBSessionManager.cpp Added Paths: ----------- trunk/stdair/stdair/dbadaptor/ trunk/stdair/stdair/dbadaptor/DbaAbstract.cpp trunk/stdair/stdair/dbadaptor/DbaAbstract.hpp trunk/stdair/stdair/dbadaptor/DbaAirline.cpp trunk/stdair/stdair/dbadaptor/DbaAirline.hpp trunk/stdair/stdair/dbadaptor/Makefile.am trunk/stdair/stdair/dbadaptor/sources.mk Modified: trunk/stdair/stdair/bom/AirlineStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.cpp 2010-02-06 17:57:52 UTC (rev 116) +++ trunk/stdair/stdair/bom/AirlineStruct.cpp 2010-02-07 02:14:43 UTC (rev 117) @@ -13,7 +13,6 @@ // //////////////////////////////////////////////////////////////////// AirlineStruct::AirlineStruct () { - assert (false); } // //////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/AirlineStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-06 17:57:52 UTC (rev 116) +++ trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-07 02:14:43 UTC (rev 117) @@ -58,12 +58,13 @@ // //////////// Constructors & Destructor /////////////// /** Main constructor. */ AirlineStruct (const AirlineCode_T&, const std::string& iAirlineName); + /** Default constructor. */ + AirlineStruct (); + /** Default copy constructor. */ + AirlineStruct (const AirlineStruct&); /** Destructor. */ ~AirlineStruct (); - /** Default copy constructor. */ - AirlineStruct (const AirlineStruct&); - /** Default constructor, not to be used. */ - AirlineStruct (); + private: // ///////////////////// Attributes ////////////////////// Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-02-06 17:57:52 UTC (rev 116) +++ trunk/stdair/stdair/core/Makefile.am 2010-02-07 02:14:43 UTC (rev 117) @@ -16,10 +16,12 @@ libstdair_la_LIBADD = \ $(top_builddir)/stdair/basic/libbas.la \ $(top_builddir)/stdair/bom/libbom.la \ + $(top_builddir)/stdair/dbadaptor/libdba.la \ $(top_builddir)/stdair/factory/libfac.la \ $(top_builddir)/stdair/service/libsvc.la libstdair_la_LDFLAGS = \ - $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ + $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ + $(BOOST_FILESYSTEM_LIB) \ -version-info $(GENERIC_LIBRARY_VERSION) # Property changes on: trunk/stdair/stdair/dbadaptor ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile Added: trunk/stdair/stdair/dbadaptor/DbaAbstract.cpp =================================================================== --- trunk/stdair/stdair/dbadaptor/DbaAbstract.cpp (rev 0) +++ trunk/stdair/stdair/dbadaptor/DbaAbstract.cpp 2010-02-07 02:14:43 UTC (rev 117) @@ -0,0 +1,9 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/dbadaptor/DbaAbstract.hpp> + +namespace stdair { + +} Added: trunk/stdair/stdair/dbadaptor/DbaAbstract.hpp =================================================================== --- trunk/stdair/stdair/dbadaptor/DbaAbstract.hpp (rev 0) +++ trunk/stdair/stdair/dbadaptor/DbaAbstract.hpp 2010-02-07 02:14:43 UTC (rev 117) @@ -0,0 +1,76 @@ +#ifndef __STDAIR_DBA_DBAABSTRACT_HPP +#define __STDAIR_DBA_DBAABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> + +namespace stdair { + + /** Base class for the Database Adaptor (DBA) layer. */ + class DbaAbstract { + public: + + /** Destructor. */ + virtual ~DbaAbstract() {} + + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + virtual void toStream (std::ostream& ioOut) const {} + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + virtual void fromStream (std::istream& ioIn) {} + + protected: + /** Protected Default Constructor to ensure this class is abtract. */ + DbaAbstract() {} + }; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (p653) of his book "The C++ Standard Library: A Tutorial + and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_ostream<charT, traits>& +operator<< (std::basic_ostream<charT, traits>& ioOut, + const stdair::DbaAbstract& iDba) { + /** + string stream: + - with same format + - without special field width + */ + std::basic_ostringstream<charT,traits> ostr; + ostr.copyfmt (ioOut); + ostr.width (0); + + // Fill string stream + iDba.toStream (ostr); + + // Print string stream + ioOut << ostr.str(); + + return ioOut; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (pp655-657) of his book "The C++ Standard Library: + A Tutorial and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_istream<charT, traits>& +operator>> (std::basic_istream<charT, traits>& ioIn, + stdair::DbaAbstract& ioDba) { + // Fill Dba object with input stream + ioDba.fromStream (ioIn); + return ioIn; +} + +#endif // __STDAIR_DBA_DBAABSTRACT_HPP Added: trunk/stdair/stdair/dbadaptor/DbaAirline.cpp =================================================================== --- trunk/stdair/stdair/dbadaptor/DbaAirline.cpp (rev 0) +++ trunk/stdair/stdair/dbadaptor/DbaAirline.cpp 2010-02-07 02:14:43 UTC (rev 117) @@ -0,0 +1,42 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <exception> +#include <string> +// Stdair +#include <stdair/bom/AirlineStruct.hpp> +#include <stdair/dbadaptor/DbaAirline.hpp> +#include <stdair/service/Logger.hpp> + +namespace soci { + + // ////////////////////////////////////////////////////////////////////// + void type_conversion<stdair::AirlineStruct>:: + from_base (values const& iAirlineValues, indicator /* ind */, + stdair::AirlineStruct& ioAirline) { + /* + iata_code, name + */ + ioAirline.setAirlineCode (iAirlineValues.get<std::string> ("iata_code")); + // The city code will be set to the default value (empty string) + // when the column is null + ioAirline.setAirlineName (iAirlineValues.get<std::string> ("name", "")); + } + + // ////////////////////////////////////////////////////////////////////// + void type_conversion<stdair::AirlineStruct>:: + to_base (const stdair::AirlineStruct& iAirline, values& ioAirlineValues, + indicator& ioIndicator) { + const indicator lNameIndicator = + iAirline.getAirlineName().empty() ? i_null : i_ok; + ioAirlineValues.set ("iata_code", iAirline.getAirlineCode()); + ioAirlineValues.set ("name", iAirline.getAirlineName(), lNameIndicator); + ioIndicator = i_ok; + } + +} + +namespace stdair { + +} Added: trunk/stdair/stdair/dbadaptor/DbaAirline.hpp =================================================================== --- trunk/stdair/stdair/dbadaptor/DbaAirline.hpp (rev 0) +++ trunk/stdair/stdair/dbadaptor/DbaAirline.hpp 2010-02-07 02:14:43 UTC (rev 117) @@ -0,0 +1,37 @@ +#ifndef __STDAIR_DBA_DBAAIRLINE_HPP +#define __STDAIR_DBA_DBAAIRLINE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// SOCI +#include <soci/core/soci.h> + +// Forward declarations +namespace stdair { + struct AirlineStruct; +} + +namespace soci { + + /** Specify how the AirlineStruct struct can be converted to (resp. from) + values stored into (resp. retrieved from) database, using the SOCI + framework. */ + template <> + struct type_conversion<stdair::AirlineStruct> { + + typedef values base_type; + + /** Fill an Airline object from the database values. */ + static void from_base (values const& iAirlineValues, + indicator /* ind */, + stdair::AirlineStruct& ioAirline); + + + /** Fill the database values from an Airline object. */ + static void to_base (const stdair::AirlineStruct& iAirline, + values& ioAirlineValues, + indicator& ioIndicator); + }; +} +#endif // __STDAIR_DBA_DBAAIRLINE_HPP Added: trunk/stdair/stdair/dbadaptor/Makefile.am =================================================================== --- trunk/stdair/stdair/dbadaptor/Makefile.am (rev 0) +++ trunk/stdair/stdair/dbadaptor/Makefile.am 2010-02-07 02:14:43 UTC (rev 117) @@ -0,0 +1,16 @@ +## dbadaptor sub-directory +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +# +noinst_LTLIBRARIES= libdba.la + +libdba_la_SOURCES= $(dba_h_sources) $(dba_cc_sources) +libdba_la_CXXFLAGS = $(SOCI_CFLAGS) +libdba_la_LIBADD = +libdba_la_LDFLAGS = $(SOCI_LIBS) + + +# Header files +pkgincludedir = $(includedir)/stdair/dbadaptor +pkginclude_HEADERS = $(dba_h_sources) Added: trunk/stdair/stdair/dbadaptor/sources.mk =================================================================== --- trunk/stdair/stdair/dbadaptor/sources.mk (rev 0) +++ trunk/stdair/stdair/dbadaptor/sources.mk 2010-02-07 02:14:43 UTC (rev 117) @@ -0,0 +1,6 @@ +dba_h_sources = \ + $(top_srcdir)/stdair/dbadaptor/DbaAbstract.hpp \ + $(top_srcdir)/stdair/dbadaptor/DbaAirline.hpp +dba_cc_sources = \ + $(top_srcdir)/stdair/dbadaptor/DbaAbstract.cpp \ + $(top_srcdir)/stdair/dbadaptor/DbaAirline.cpp Modified: trunk/stdair/stdair/service/DBSessionManager.cpp =================================================================== --- trunk/stdair/stdair/service/DBSessionManager.cpp 2010-02-06 17:57:52 UTC (rev 116) +++ trunk/stdair/stdair/service/DBSessionManager.cpp 2010-02-07 02:14:43 UTC (rev 117) @@ -51,7 +51,7 @@ const std::string lDBSessionConnectionString (oStr.str()); // Instanciate the database session: nothing else is performed at that stage - _dbSession = new DBSession_T(); + _dbSession = new DBSession_T; try { 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:57:58
|
Revision: 116 http://stdair.svn.sourceforge.net/stdair/?rev=116&view=rev Author: denis_arnaud Date: 2010-02-06 17:57:52 +0000 (Sat, 06 Feb 2010) Log Message: ----------- [DB] Added support for database management (still a little work to do). Modified Paths: -------------- trunk/stdair/test/samples/Makefile.am Added Paths: ----------- trunk/stdair/test/samples/demand01.csv Modified: trunk/stdair/test/samples/Makefile.am =================================================================== --- trunk/stdair/test/samples/Makefile.am 2010-02-06 17:51:39 UTC (rev 115) +++ trunk/stdair/test/samples/Makefile.am 2010-02-06 17:57:52 UTC (rev 116) @@ -6,6 +6,8 @@ ## SUBDIRS = -EXTRA_DIST = schedule01.csv schedule02.csv +EXTRA_DIST = demand01.csv \ + rm01.csv rm02.csv rm03.csv rm04.csv \ + schedule01.csv schedule02.csv ## Added: trunk/stdair/test/samples/demand01.csv =================================================================== --- trunk/stdair/test/samples/demand01.csv (rev 0) +++ trunk/stdair/test/samples/demand01.csv 2010-02-06 17:57:52 UTC (rev 116) @@ -0,0 +1,4 @@ +// Demand: Origin; Destination; PreferedDepartureDate; Mean; StdDev; +NCE; JFK; 2011-01-15; 50; 0; +NCE; LHR; 2011-01-15; 300; 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:52:21
|
Revision: 115 http://stdair.svn.sourceforge.net/stdair/?rev=115&view=rev Author: denis_arnaud Date: 2010-02-06 17:51:39 +0000 (Sat, 06 Feb 2010) Log Message: ----------- [DB] Added support for database management (still a little work to do). Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/bom/TravelSolutionStruct.hpp trunk/stdair/stdair/bom/sources.mk trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/factory/FacSupervisor.hpp trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Logger.hpp trunk/stdair/stdair/service/Makefile.am trunk/stdair/stdair/service/STDAIR_Service.cpp trunk/stdair/stdair/service/sources.mk Added Paths: ----------- trunk/stdair/stdair/bom/AirlineStruct.cpp trunk/stdair/stdair/bom/AirlineStruct.hpp trunk/stdair/stdair/service/DBSessionManager.cpp trunk/stdair/stdair/service/DBSessionManager.hpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -8,6 +8,7 @@ #include <boost/shared_ptr.hpp> // StdAir #include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> namespace stdair { @@ -24,10 +25,20 @@ 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 BasLogParams& Parameters for the output log stream. */ STDAIR_Service (const BasLogParams&); + /** Constructor. + <br>The init() method is called; see the corresponding documentation + for more details. + <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 database requests can use the corresponding access. + @param const BasLogParams& Parameters for the output log stream. + @param const BasDBParams& Parameters for the database session. */ + STDAIR_Service (const BasLogParams&, const BasDBParams&); + /** Destructor. */ ~STDAIR_Service(); @@ -51,11 +62,16 @@ /** Initialise the log. */ void logInit (const BasLogParams&); + /** Initialise the database session. */ + void dbInit (const BasDBParams&); + /** Initialise. <br>The static instance of the log service (Logger object) is created. + <br>The static instance of the database session manager + (DBSessionManager object) is created. <br>The static instance of the FacSupervisor object, itself referencing all the other objects (factories and BOM), is created. - <br>As those two objects are static, there is no need to store them + <br>As those three objects are static, there is no need to store them in any service context. However, some lock mechanism may be needed in order to secure the access to the corresponding resources. */ void init (); Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -14,6 +14,12 @@ #include <boost/tuple/tuple.hpp> #include <boost/shared_ptr.hpp> +// Forward declarations +namespace soci { + class session; + class statement; +} + namespace stdair { // Forward declarations @@ -29,6 +35,9 @@ class NonInitialisedLogServiceException : public RootException { }; + class NonInitialisedDBSessionManagerException : public RootException { + }; + class NonInitialisedServiceException : public RootException { }; @@ -38,6 +47,12 @@ class ObjectNotFoundException : public RootException { }; + class SQLDatabaseException : public RootException { + }; + + class SQLDatabaseConnectionImpossibleException : public SQLDatabaseException { + }; + class DocumentNotFoundException : public RootException { }; @@ -59,6 +74,12 @@ } // //////// Type definitions ///////// + /** Database session handler. */ + typedef soci::session DBSession_T; + + /** Database request statement handler. */ + typedef soci::statement DBRequestStatement_T; + /** Define the type for durations (e.g., elapsed in-flight time). */ typedef boost::posix_time::time_duration Duration_T; Added: trunk/stdair/stdair/bom/AirlineStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.cpp (rev 0) +++ trunk/stdair/stdair/bom/AirlineStruct.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,50 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <istream> +#include <ostream> +#include <sstream> +// StdAir +#include <stdair/bom/AirlineStruct.hpp> + +namespace stdair { + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::AirlineStruct () { + assert (false); + } + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::AirlineStruct (const AirlineStruct& iAirlineStruct) + : _code (iAirlineStruct._code), _name (iAirlineStruct._name) { + } + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::AirlineStruct (const AirlineCode_T& iAirlineCode, + const std::string& iAirlineName) + : _code (iAirlineCode), _name (iAirlineName) { + } + + // //////////////////////////////////////////////////////////////////// + AirlineStruct::~AirlineStruct () { + } + + // ////////////////////////////////////////////////////////////////////// + void AirlineStruct::toStream (std::ostream& ioOut) const { + ioOut << describe(); + } + + // ////////////////////////////////////////////////////////////////////// + void AirlineStruct::fromStream (std::istream& ioIn) { + } + + // ////////////////////////////////////////////////////////////////////// + const std::string AirlineStruct::describe() const { + std::ostringstream oStr; + oStr << _code << " " << _name; + return oStr.str(); + } + +} Added: trunk/stdair/stdair/bom/AirlineStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/AirlineStruct.hpp (rev 0) +++ trunk/stdair/stdair/bom/AirlineStruct.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,78 @@ +#ifndef __STDAIR_BOM_AIRLINESTRUCT_HPP +#define __STDAIR_BOM_AIRLINESTRUCT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +#include <string> +#include <vector> +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/bom/StructAbstract.hpp> + +namespace stdair { + + /** Structure holding parameters describing an airline. */ + struct AirlineStruct : public StructAbstract { + public: + // /////////// Getters /////////////// + /** Get the airline code. */ + const AirlineCode_T& getAirlineCode() const { + return _code; + } + + /** Get the airline name. */ + const std::string& getAirlineName() const { + return _name; + } + + // /////////// Setters /////////////// + /** Set the airline code. */ + void setAirlineCode (const AirlineCode_T& iAirlineCode) { + _code = iAirlineCode; + } + + /** Set the airline name. */ + void setAirlineName (const std::string& iAirlineName) { + _name = iAirlineName; + } + + + public: + // /////////// Display support method ///////////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn); + + /** Display of the structure. */ + const std::string describe() const; + + + public: + // //////////// Constructors & Destructor /////////////// + /** Main constructor. */ + AirlineStruct (const AirlineCode_T&, const std::string& iAirlineName); + /** Destructor. */ + ~AirlineStruct (); + /** Default copy constructor. */ + AirlineStruct (const AirlineStruct&); + /** Default constructor, not to be used. */ + AirlineStruct (); + + private: + // ///////////////////// Attributes ////////////////////// + /** Airline code. */ + AirlineCode_T _code; + + /** Airline name. */ + std::string _name; + }; + +} +#endif // __STDAIR_BOM_AIRLINESTRUCT_HPP Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -13,6 +13,7 @@ #include <stdair/bom/BookingClassTypes.hpp> namespace stdair { + // Forward declarations class OutboundPath; @@ -42,8 +43,8 @@ const std::string describe() const; + public: // //////////// Constructors & Destructor /////////////// - public: /** Main constructor. */ TravelSolutionStruct (OutboundPath&, const BookingClassSTLList_T&); /** Destructor. */ @@ -54,7 +55,7 @@ TravelSolutionStruct (); private: - // Attributes + // ///////////////////// Attributes ////////////////////// /** The outbound path associated to this solution.*/ OutboundPath* _outboundPath_ptr; Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-06 17:51:39 UTC (rev 115) @@ -85,6 +85,7 @@ $(top_srcdir)/stdair/bom/TravelSolutionStruct.hpp \ $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ + $(top_srcdir)/stdair/bom/AirlineStruct.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp bom_cc_sources = \ $(top_srcdir)/stdair/bom/BomRootKey.cpp \ @@ -133,4 +134,5 @@ $(top_srcdir)/stdair/bom/DoWStruct.cpp \ $(top_srcdir)/stdair/bom/TravelSolutionStruct.cpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.cpp \ + $(top_srcdir)/stdair/bom/AirlineStruct.cpp \ $(top_srcdir)/stdair/bom/BomManager.cpp Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -8,6 +8,7 @@ #include <stdair/factory/FacBomContent.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/service/Logger.hpp> +#include <stdair/service/DBSessionManager.hpp> namespace stdair { @@ -75,9 +76,18 @@ // Clean the static instance of the log service Logger::clean(); } + + // ////////////////////////////////////////////////////////////////////// + void FacSupervisor::cleanDBSessionManager() { + // Clean the static instance of the database session manager + DBSessionManager::clean(); + } // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanAll () { + // Clean the static instance of the database session manager + cleanDBSessionManager(); + // Clean the static instance of the log service cleanLoggerService(); Modified: trunk/stdair/stdair/factory/FacSupervisor.hpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -56,6 +56,9 @@ /** Delete the static instance of the Logger object. */ static void cleanLoggerService(); + /** Delete the static instance of the DBSessionManager object. */ + static void cleanDBSessionManager(); + /** Clean the static instance. <br>As the static instance (singleton) is deleted, all the other registered objects will be deleted in turn. */ Added: trunk/stdair/stdair/service/DBSessionManager.cpp =================================================================== --- trunk/stdair/stdair/service/DBSessionManager.cpp (rev 0) +++ trunk/stdair/stdair/service/DBSessionManager.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,117 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <string> +#include <sstream> +// SOCI +#include <soci/core/soci.h> +#include <soci/backends/mysql/soci-mysql.h> +// StdAir +#include <stdair/basic/BasDBParams.hpp> +#include <stdair/service/DBSessionManager.hpp> +#include <stdair/service/Logger.hpp> + +namespace stdair { + + DBSessionManager* DBSessionManager::_instance = NULL; + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::DBSessionManager () : _dbSession (NULL) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::DBSessionManager (const DBSessionManager&) + : _dbSession (NULL) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::DBSessionManager (const BasDBParams& iDBParams) + : _dbSession (NULL) { + dbInit (iDBParams); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager::~DBSessionManager () { + // std::cout << "In DBSessionManager destructor" << std::endl; + dbFinalise(); + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::dbInit (const BasDBParams& iDBParams) { + + // Database parameters + std::ostringstream oStr; + oStr << "db=" << iDBParams.getDBName() << " user=" << iDBParams.getUser() + << " password=" << iDBParams.getPassword() + << " port=" << iDBParams.getPort() << " host=" << iDBParams.getHost(); + const std::string lDBSessionConnectionString (oStr.str()); + + // Instanciate the database session: nothing else is performed at that stage + _dbSession = new DBSession_T(); + + try { + + // Open the connection to the database + _dbSession->open (soci::mysql, lDBSessionConnectionString); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error while opening a connection to database: " + << lException.what()); + STDAIR_LOG_ERROR ("Database parameters used:" + << " db=" << iDBParams.getDBName() + << " user=" << iDBParams.getUser() + << " port=" << iDBParams.getPort() + << " host=" << iDBParams.getHost()); + throw SQLDatabaseConnectionImpossibleException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::dbFinalise () { + delete _dbSession; _dbSession = NULL; + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::init (const BasDBParams& iDBParams) { + // Sanity check + if (_instance != NULL) { + STDAIR_LOG_ERROR ("Error: the DB session has already been initialised"); + assert (false); + } + assert (_instance == NULL); + + _instance = new DBSessionManager (iDBParams); + } + + // ////////////////////////////////////////////////////////////////////// + DBSessionManager& DBSessionManager::instance() { + if (_instance == NULL) { + throw NonInitialisedDBSessionManagerException(); + } + assert (_instance != NULL); + return *_instance; + } + + // ////////////////////////////////////////////////////////////////////// + void DBSessionManager::clean() { + //std::cout<< "In DBSessionManager::clean(),before static instance deletion" + // << std::endl; + delete _instance; _instance = NULL; + //std::cout<< "In DBSessionManager::clean(),after static instance deletion" + // << std::endl; + } + + // ////////////////////////////////////////////////////////////////////// + DBSession_T& DBSessionManager::getDBSession() const { + if (_dbSession == NULL) { + throw NonInitialisedDBSessionManagerException(); + } + assert (_dbSession != NULL); + return *_dbSession; + } + +} Added: trunk/stdair/stdair/service/DBSessionManager.hpp =================================================================== --- trunk/stdair/stdair/service/DBSessionManager.hpp (rev 0) +++ trunk/stdair/stdair/service/DBSessionManager.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -0,0 +1,69 @@ +#ifndef __STDAIR_SVC_DBSESSIONMANAGER_HPP +#define __STDAIR_SVC_DBSESSIONMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + // Forward declarations + struct BasDBParams; + + /** Class holding the database session. + <br>Note that the database access is handled by the SOCI library. */ + class DBSessionManager { + // Friend classes + friend class FacSupervisor; + friend class STDAIR_Service; + + public: + /** Return the static DBSessionManager instance. */ + static DBSessionManager& instance(); + + /** Retrieve the database session handler, held by the static instance + of DBSessionManager. */ + DBSession_T& getDBSession() const; + + + private: + /** Default constructors are private so that only the required + constructor can be used. */ + DBSessionManager (const BasDBParams&); + /** Default constructor. It must not be used. */ + DBSessionManager (); + /** Default copy constructor. It must not be used. */ + DBSessionManager (const DBSessionManager&); + /** Destructor. */ + ~DBSessionManager (); + + /** Initialise the (MySQL) database connection for the static + DBSessionManager instance. */ + void dbInit (const BasDBParams&); + + /** Close the (MySQL) database connection attached to the static + DBSessionManager instance. */ + void dbFinalise (); + + + private: + /** Initialise the static DBSessionManager instance. + <br>The (MySQL) database connection is initialised. */ + static void init (const BasDBParams&); + + /** Delete the static DBSessionManager instance.*/ + static void clean(); + + + private: + /** Instance object.*/ + static DBSessionManager* _instance; + + /** Database session handler. */ + DBSession_T* _dbSession; + }; + +} +#endif // __STDAIR_SVC_DBSESSIONMANAGER_HPP Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/Logger.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -1,8 +1,7 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// Stdair Logger -//#include <stdair/factory/FacSupervisor.hpp> +// StdAir Logger #include <stdair/service/Logger.hpp> namespace stdair { @@ -20,7 +19,7 @@ } // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const stdair::BasLogParams& iLogParams) + Logger::Logger (const BasLogParams& iLogParams) : _level (iLogParams._logLevel), _logStream (iLogParams._logStream) { } Modified: trunk/stdair/stdair/service/Logger.hpp =================================================================== --- trunk/stdair/stdair/service/Logger.hpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/Logger.hpp 2010-02-06 17:51:39 UTC (rev 115) @@ -46,6 +46,7 @@ class Logger { // Friend classes friend class FacSupervisor; + friend class STDAIR_Service; public: /** Main log entry. */ @@ -58,9 +59,6 @@ } } - /** Initialise the static Logger instance. */ - static void init (const stdair::BasLogParams&); - /** Return the static Logger instance. */ static Logger& instance(); @@ -68,7 +66,7 @@ private: /** Default constructors are private so that only the required constructor can be used. */ - Logger (const stdair::BasLogParams&); + Logger (const BasLogParams&); /** Default constructor. It must not be used. */ Logger (); /** Default copy constructor. It must not be used. */ @@ -76,6 +74,13 @@ /** Destructor. */ ~Logger (); + // TODO: migrate all the XXXXXX_Service to the new way to initialise + // Logger, and get rid of that 'public:' interface + public: + /** Initialise the static Logger instance. */ + static void init (const BasLogParams&); + + private: /** Delete the static Logger instance.*/ static void clean(); Modified: trunk/stdair/stdair/service/Makefile.am =================================================================== --- trunk/stdair/stdair/service/Makefile.am 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/Makefile.am 2010-02-06 17:51:39 UTC (rev 115) @@ -6,7 +6,8 @@ noinst_LTLIBRARIES= libsvc.la libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) -libsvc_la_CXXFLAGS = +libsvc_la_CXXFLAGS = $(SOCI_CFLAGS) $(MYSQL_CFLAGS) +libsvc_la_LDFLAGS = $(SOCI_LIBS) $(MYSQL_LIBS) # Header files pkgincludedir = $(includedir)/stdair/service Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-02-06 17:51:39 UTC (rev 115) @@ -12,6 +12,7 @@ #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/service/Logger.hpp> +#include <stdair/service/DBSessionManager.hpp> #include <stdair/STDAIR_Service.hpp> namespace stdair { @@ -29,7 +30,7 @@ } // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) + STDAIR_Service::STDAIR_Service (const BasLogParams& iLogParams) : _bomRoot (FacBomContent::instance().create<BomRoot>()) { // The root of the BOM tree, on which all of the other BOM objects // will be attached, is being created with the STDAIR_Service constructor. @@ -42,6 +43,23 @@ } // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const BasLogParams& iLogParams, + const BasDBParams& iDBParams) + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { + // The root of the BOM tree, on which all of the other BOM objects + // will be attached, is being created with the STDAIR_Service constructor. + + // Set the log file + logInit (iLogParams); + + // Create a database session + dbInit (iDBParams); + + // Initialise the (remaining of the) context + init (); + } + + // ////////////////////////////////////////////////////////////////////// STDAIR_Service::~STDAIR_Service () { // Delete/Clean all the objects from memory finalise(); @@ -53,6 +71,11 @@ } // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::dbInit (const BasDBParams& iDBParams) { + DBSessionManager::init (iDBParams); + } + + // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::init () { } Modified: trunk/stdair/stdair/service/sources.mk =================================================================== --- trunk/stdair/stdair/service/sources.mk 2010-02-06 13:33:54 UTC (rev 114) +++ trunk/stdair/stdair/service/sources.mk 2010-02-06 17:51:39 UTC (rev 115) @@ -1,3 +1,7 @@ -svc_h_sources = $(top_srcdir)/stdair/service/Logger.hpp -svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp \ - $(top_srcdir)/stdair/service/STDAIR_Service.cpp +svc_h_sources = \ + $(top_srcdir)/stdair/service/Logger.hpp \ + $(top_srcdir)/stdair/service/DBSessionManager.hpp +svc_cc_sources = \ + $(top_srcdir)/stdair/service/Logger.cpp \ + $(top_srcdir)/stdair/service/DBSessionManager.cpp \ + $(top_srcdir)/stdair/service/STDAIR_Service.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-06 13:34:01
|
Revision: 114 http://stdair.svn.sourceforge.net/stdair/?rev=114&view=rev Author: denis_arnaud Date: 2010-02-06 13:33:54 +0000 (Sat, 06 Feb 2010) Log Message: ----------- [DB] Added support for database administration, as well as a sample table (for airline description). Added Paths: ----------- trunk/stdair/db/ trunk/stdair/db/admin/ trunk/stdair/db/admin/clean_a_table.sh trunk/stdair/db/admin/clean_all_tables.sh trunk/stdair/db/admin/count_a_table.sh trunk/stdair/db/admin/count_all_tables.sh trunk/stdair/db/admin/create_dsim_db.sh trunk/stdair/db/admin/create_dsim_tables.sql trunk/stdair/db/admin/create_dsim_user.sh trunk/stdair/db/admin/create_dsim_user.sql trunk/stdair/db/admin/dump_dsim_db_structure.sh trunk/stdair/db/admin/fill_dsim_tables.sql trunk/stdair/db/admin/load_dsim_data.sh trunk/stdair/db/data/ trunk/stdair/db/data/airlines.csv Added: trunk/stdair/db/admin/clean_a_table.sh =================================================================== --- trunk/stdair/db/admin/clean_a_table.sh (rev 0) +++ trunk/stdair/db/admin/clean_a_table.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,35 @@ +#!/bin/sh +# Parameters required +# - name of user +# - name of database +# - name of table +# - host +# - port + +# if [ "$1" = "" -o "$2" = "" ]; +if [ $# != 5 ] +then + echo "Usage: $0 <Username> <Database name> <table> <Database Host> <Port>" + echo "" + exit -1 +fi + +DB_USER="$1" +DB_PASSWD="${DB_USER}" +DB_NAME="$2" +DB_TABLE="$3" +DB_HOST="$4" +DB_PORT="$5" + +QUERY_DELETE="delete from ${DB_TABLE}" +QUERY_COUNT="select count(*) from ${DB_TABLE}" + +echo "Before:" +mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "${QUERY_COUNT}" ${DB_NAME} + +echo "Deleting all the rows from ${DB_NAME}.${DB_TABLE}" +mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "${QUERY_DELETE}" ${DB_NAME} + +echo "Result:" +mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "${QUERY_COUNT}" ${DB_NAME} + Added: trunk/stdair/db/admin/clean_all_tables.sh =================================================================== --- trunk/stdair/db/admin/clean_all_tables.sh (rev 0) +++ trunk/stdair/db/admin/clean_all_tables.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,80 @@ +#!/bin/sh +# +# Two parameters are optional: +# - the host server of the database +# - the port of the database +# + +if [ "$1" = "-h" -o "$1" = "--help" ]; +then + echo "Usage: $0 [<Database Server Hostname> [<Database Server Port>]]" + echo "" + exit -1 +fi + +## +# Database Server Hostname +DB_HOST="localhost" +if [ "$1" != "" ]; +then + DB_HOST="$1" +fi + +# Database Server Port +DB_PORT="3306" +if [ "$2" != "" ]; +then + DB_PORT="$2" +fi + +# Database User +DB_USER="dsim" + +# Database Password +DB_PASSWD="${DB_USER}" + +# Database Name +DB_NAME="dsim" + +# Count the number of elements of a given database table +function countElements() { + echo + echo "Number of elements for the '${DB_TABLE}' table" + SQL_QUERY="select count(*) from ${DB_TABLE}" + mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "${SQL_QUERY}" ${DB_NAME} +} + +# Delete all the elements of a given database table +function deleteAllElements() { + SQL_QUERY="delete from ${DB_TABLE}" + mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "${SQL_QUERY}" ${DB_NAME} +} + +# +TABLES="airlines" + +# Count rows +echo "Before:" +for table_name in ${TABLES} +do + DB_TABLE="${table_name}" + countElements +done + +# Delete tables +echo "Deletion..." +for table_name in ${TABLES} +do + DB_TABLE="${table_name}" + deleteAllElements +done +echo "Done" + +## After deleting elements (sanity check) +echo +echo "After:" +for table_name in ${TABLES} +do + DB_TABLE="${table_name}" + countElements +done Property changes on: trunk/stdair/db/admin/clean_all_tables.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/stdair/db/admin/count_a_table.sh =================================================================== --- trunk/stdair/db/admin/count_a_table.sh (rev 0) +++ trunk/stdair/db/admin/count_a_table.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,26 @@ +#!/bin/sh +# Parameters required +# - name of user +# - name of database +# - name of table +# - host +# - port + +# if [ "$1" = "" -o "$2" = "" ]; +if [ $# != 5 ] +then + echo "Usage: $0 <Username> <Database name> <table> <Database Host> <Port>" + echo "" + exit -1 +fi + +DB_USER="$1" +DB_PASSWD="${DB_USER}" +DB_NAME="$2" +DB_TABLE="$3" +DB_HOST="$4" +DB_PORT="$5" +QUERY_COUNT="select count(*) from ${DB_TABLE}" + +echo "The ${DB_NAME}.${DB_TABLE} table contains that many rows:" +mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "${QUERY_COUNT}" ${DB_NAME} \ No newline at end of file Added: trunk/stdair/db/admin/count_all_tables.sh =================================================================== --- trunk/stdair/db/admin/count_all_tables.sh (rev 0) +++ trunk/stdair/db/admin/count_all_tables.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Two parameters are optional: +# - the host server of the database +# - the port of the database +# + +if [ "$1" = "-h" -o "$1" = "--help" ]; +then + echo "Usage: $0 [<Database Server Hostname> [<Database Server Port>]]" + echo "" + exit -1 +fi + +## +# Database Server Hostname +DB_HOST="localhost" +if [ "$1" != "" ]; +then + DB_HOST="$1" +fi + +# Database Server Port +DB_PORT="3306" +if [ "$2" != "" ]; +then + DB_PORT="$2" +fi + +# Database User +DB_USER="dsim" + +# Database Password +DB_PASSWD="${DB_USER}" + +# Database Name +DB_NAME="dsim" + +# Count the number of elements of a given database table +function countElements() { + echo + echo "Number of elements for the '${DB_TABLE}' table" + SQL_QUERY="select count(*) from ${DB_TABLE}" + mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "${SQL_QUERY}" ${DB_NAME} +} + +# +TABLES="airlines" + +# Count rows +for table_name in ${TABLES} +do + DB_TABLE="${table_name}" + countElements +done Property changes on: trunk/stdair/db/admin/count_all_tables.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/stdair/db/admin/create_dsim_db.sh =================================================================== --- trunk/stdair/db/admin/create_dsim_db.sh (rev 0) +++ trunk/stdair/db/admin/create_dsim_db.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Three parameters are optional: +# - the name of the database (on the MySQL server) +# - the host server of the database +# - the port of the database +# + +# Database Name +DB_NAME="dsim" + +# Database server (host) +DB_HOST="localhost" + +# Database server port +DB_PORT="3306" + +if [ "$1" != "" ]; then + DB_NAME=$1 +fi + +if [ "$2" != "" ]; then + DB_HOST=$2 +fi + +if [ "$3" != "" ]; then + DB_PORT=$3 +fi + + +if [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-H" ]; then + echo "Usage: $0 [ <Name of Database> <Host> <Port> ]" + echo "" + exit -1 +fi + +# +echo "Accessing MySQL database hosted on $DB_HOST:$DB_PORT to create database '${DB_NAME}'." +echo "To create a database, username and password of an administrator-like MySQL account" +echo "are required. On most of MySQL databases, the 'root' MySQL account has all" +echo "the administrative rights, but you may want to use a less-privileged MySQL" +echo "administrator account. Type the username of administrator followed by " +echo "[Enter]. To discontinue, type CTRL-C." +read userinput_adminname + +echo "Type $userinput_adminname's password followed by [Enter]" +read -s userinput_pw + +# Database user +DB_USER=${userinput_adminname} + +# Database password +DB_PASSWD=${userinput_pw} + +# +SQL_STATEMENT="create database if not exists ${DB_NAME} default character set utf8 collate utf8_unicode_ci" + +# +echo "The database '${DB_NAME}' will be created:" +mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} mysql -e "${SQL_STATEMENT}" Property changes on: trunk/stdair/db/admin/create_dsim_db.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/stdair/db/admin/create_dsim_tables.sql =================================================================== --- trunk/stdair/db/admin/create_dsim_tables.sql (rev 0) +++ trunk/stdair/db/admin/create_dsim_tables.sql 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,41 @@ +-- MySQL dump 10.11 +-- +-- Host: localhost Database: dsim +-- ------------------------------------------------------ +-- Server version 5.0.67 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `airlines` +-- + +DROP TABLE IF EXISTS `airlines`; +SET @saved_cs_client = @@character_set_client; +SET character_set_client = utf8; +CREATE TABLE `airlines` ( + `iata_code` char(2) NOT NULL, + `name` varchar(100) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=utf8; +SET character_set_client = @saved_cs_client; + +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2009-02-09 0:52:34 Added: trunk/stdair/db/admin/create_dsim_user.sh =================================================================== --- trunk/stdair/db/admin/create_dsim_user.sh (rev 0) +++ trunk/stdair/db/admin/create_dsim_user.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,65 @@ +#!/bin/sh +# +# Three parameters are optional: +# - the name of the database (on the MySQL server) +# - the host server of the database +# - the port of the database +# + +# Database Name +DB_NAME="mysql" + +# Database server (host) +DB_HOST="localhost" + +# Database server port +DB_PORT="3306" + +if [ "$1" != "" ]; then + DB_NAME=$1 +fi + +if [ "$2" != "" ]; then + DB_HOST=$2 +fi + +if [ "$3" != "" ]; then + DB_PORT=$3 +fi + + +if [ "$1" = "--help" -o "$1" = "-h" -o "$1" = "-H" ]; then + echo "Usage: $0 [ <Name of Database> <Host> <Port> ]" + echo "" + exit -1 +fi + +# +echo "Accessing MySQL database hosted on $DB_HOST:$DB_PORT to create database '${DB_NAME}'." +echo "To create a database, username and password of an administrator-like MySQL account" +echo "are required. On most of MySQL databases, the 'root' MySQL account has all" +echo "the administrative rights, but you may want to use a less-privileged MySQL" +echo "administrator account. Type the username of administrator followed by " +echo "[Enter]. To discontinue, type CTRL-C." +read userinput_adminname + +echo "Type $userinput_adminname's password followed by [Enter]" +read -s userinput_pw + +# Database user +DB_USER=${userinput_adminname} + +# Database password +DB_PASSWD=${userinput_pw} + +# +createDSimUser() { + echo "Creating the DSim user within the database:" + mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} ${DB_NAME} < ${SQL_FILE} + mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} -e "flush privileges" +} + +# Creating the DSim user +SQL_FILE="create_dsim_user.sql" +createDSimUser + Property changes on: trunk/stdair/db/admin/create_dsim_user.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/stdair/db/admin/create_dsim_user.sql =================================================================== --- trunk/stdair/db/admin/create_dsim_user.sql (rev 0) +++ trunk/stdair/db/admin/create_dsim_user.sql 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,7 @@ + +insert into `user` (`Host`, `User`, `Password`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`) values +('%', 'dsim', '6b05771f692d78a8', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'N', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'Y', 'N', '', '', '', '', 0, 0, 0, 0), +('localhost', 'dsim', '6b05771f692d78a8', 'Y', 'Y', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'Y', 'N', 'N', 'Y', 'Y', 'N', 'N', 'Y', 'N', 'Y', 'N', 'N', 'Y', 'Y', 'Y', 'Y', 'N', '', '', '', '', 0, 0, 0, 0); + +flush privileges; + Added: trunk/stdair/db/admin/dump_dsim_db_structure.sh =================================================================== --- trunk/stdair/db/admin/dump_dsim_db_structure.sh (rev 0) +++ trunk/stdair/db/admin/dump_dsim_db_structure.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,51 @@ +#!/bin/sh +# +# Two parameters are required for this script: +# - the administrator username +# - the administrator password +# +# Two parameters are optional: +# - the host server of the database +# - the port of the database +# + +if [ "$1" = "" -o "$2" = "" -o "$1" = "-h" -o "$1" = "--help" ]; +then + echo "Usage: $0 <Admin Username> <Admin password> [<Database Server Hostname> [<Database Server Port>]]" + echo "" + exit -1 +fi + +## +# Database Server Hostname +DB_HOST="localhost" +if [ "$3" != "" ]; +then + DB_HOST="$3" +fi + +# Database Server Port +DB_PORT="3306" +if [ "$4" != "" ]; +then + DB_PORT="$4" +fi + +# Database User +DB_USER="$1" + +# Database Password +DB_PASSWD="$2" + +# Database Name +DB_NAME="geo_geonames" + +# Export Tool +EXPORTER=mysqldump + +# Dump file +DUMP_FILE="geo_geonames.sql" + +# +${EXPORTER} -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} \ + --no-data ${DB_NAME} > ${DUMP_FILE} Property changes on: trunk/stdair/db/admin/dump_dsim_db_structure.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/stdair/db/admin/fill_dsim_tables.sql =================================================================== --- trunk/stdair/db/admin/fill_dsim_tables.sql (rev 0) +++ trunk/stdair/db/admin/fill_dsim_tables.sql 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,13 @@ +-- +-- Note: that file is expected to be launched from the +-- $(top_srcdir)/db/admin sub-directory, as the CSV files are +-- to be found in $(top_srcdir)/db/data sub-directory +-- + +-- +-- Load the Airport and City geographical details into the MySQL table +-- +load data local infile '../data/airlines.csv' ignore +into table airlines +fields terminated by ',' enclosed by '' escaped by '\\' +ignore 1 lines; Added: trunk/stdair/db/admin/load_dsim_data.sh =================================================================== --- trunk/stdair/db/admin/load_dsim_data.sh (rev 0) +++ trunk/stdair/db/admin/load_dsim_data.sh 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,47 @@ +#!/bin/sh +# +# Two parameters are optional: +# - the host server of the database +# - the port of the database +# + +if [ "$1" = "-h" -o "$1" = "--help" ]; +then + echo "Usage: $0 [<Database Server Hostname> [<Database Server Port>]]" + echo "" + exit -1 +fi + +## +# Database Server Hostname +DB_HOST="localhost" +if [ "$1" != "" ]; +then + DB_HOST="$1" +fi + +# Database Server Port +DB_PORT="3306" +if [ "$2" != "" ]; +then + DB_PORT="$2" +fi + +# Database User +DB_USER="dsim" + +# Database Password +DB_PASSWD="dsim" + +# Database Name +DB_NAME="dsim" + +# Create the tables +SQL_FILE="create_dsim_tables.sql" +echo "Creating the tables for DSim:" +mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} ${DB_NAME} < ${SQL_FILE} + +# Load the data into the tables +SQL_FILE="fill_dsim_tables.sql" +echo "Load data into the tables of DSim:" +mysql -u ${DB_USER} --password=${DB_PASSWD} -P ${DB_PORT} -h ${DB_HOST} ${DB_NAME} < ${SQL_FILE} Property changes on: trunk/stdair/db/admin/load_dsim_data.sh ___________________________________________________________________ Added: svn:executable + * Added: trunk/stdair/db/data/airlines.csv =================================================================== --- trunk/stdair/db/data/airlines.csv (rev 0) +++ trunk/stdair/db/data/airlines.csv 2010-02-06 13:33:54 UTC (rev 114) @@ -0,0 +1,10 @@ +// Airlines: IATA Code, Full name, +BA, British Airways, +LH, Lufthansa, +AF, Air France, +KL, KLM, +IB, Iberia, +AA, American Airlines, +UA, United Airlines, +DL, Delta Airlines, +CO, Continental Airlines, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <qua...@us...> - 2010-02-03 15:11:12
|
Revision: 113 http://stdair.svn.sourceforge.net/stdair/?rev=113&view=rev Author: quannaus Date: 2010-02-03 15:11:00 +0000 (Wed, 03 Feb 2010) Log Message: ----------- [dev] Some small changes in the display. Modified Paths: -------------- trunk/stdair/stdair/bom/BookingClass.cpp trunk/stdair/stdair/bom/FlightDateKey.cpp Modified: trunk/stdair/stdair/bom/BookingClass.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingClass.cpp 2010-02-03 14:09:48 UTC (rev 112) +++ trunk/stdair/stdair/bom/BookingClass.cpp 2010-02-03 15:11:00 UTC (rev 113) @@ -44,12 +44,12 @@ // ////////////////////////////////////////////////////////////////////// const std::string BookingClass::describeKey() const { - return _bookingClassStructure.describeKey(); + return _key.describe(); } // ////////////////////////////////////////////////////////////////////// const std::string BookingClass::describeShortKey() const { - return _bookingClassStructure.describeShortKey(); + return _key.toString(); } } Modified: trunk/stdair/stdair/bom/FlightDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/FlightDateKey.cpp 2010-02-03 14:09:48 UTC (rev 112) +++ trunk/stdair/stdair/bom/FlightDateKey.cpp 2010-02-03 15:11:00 UTC (rev 113) @@ -34,7 +34,7 @@ // //////////////////////////////////////////////////////////////////// const std::string FlightDateKey_T::toString() const { std::ostringstream oStr; - oStr << _parentKey.toString() << _flightNumber << " " << _flightDate; + oStr << _flightNumber << ", " << _flightDate; return oStr.str(); } 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:10:01
|
Revision: 112 http://stdair.svn.sourceforge.net/stdair/?rev=112&view=rev Author: quannaus Date: 2010-02-03 14:09:48 +0000 (Wed, 03 Feb 2010) Log Message: ----------- [dev] Added some 'get' functions. Modified Paths: -------------- trunk/stdair/stdair/bom/AirportDateKey.cpp trunk/stdair/stdair/bom/BookingClass.hpp trunk/stdair/stdair/bom/BookingClassContent.cpp trunk/stdair/stdair/bom/BookingClassContent.hpp trunk/stdair/stdair/bom/BookingClassKey.hpp trunk/stdair/stdair/bom/BookingClassTypes.hpp trunk/stdair/stdair/bom/BookingRequestStruct.cpp trunk/stdair/stdair/bom/Network.cpp trunk/stdair/stdair/bom/Network.hpp trunk/stdair/stdair/bom/NetworkDate.cpp trunk/stdair/stdair/bom/NetworkDate.hpp trunk/stdair/stdair/bom/SegmentCabinKey.hpp trunk/stdair/stdair/bom/TravelSolutionStruct.cpp trunk/stdair/stdair/bom/TravelSolutionStruct.hpp trunk/stdair/stdair/bom/sources.mk Added Paths: ----------- trunk/stdair/stdair/bom/TravelSolutionTypes.hpp Modified: trunk/stdair/stdair/bom/AirportDateKey.cpp =================================================================== --- trunk/stdair/stdair/bom/AirportDateKey.cpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/AirportDateKey.cpp 2010-02-03 14:09:48 UTC (rev 112) @@ -36,7 +36,7 @@ // //////////////////////////////////////////////////////////////////// const std::string AirportDateKey_T::toString() const { std::ostringstream oStr; - oStr << _parentKey.toString() << " " << _origin; + oStr << _origin; return oStr.str(); } Modified: trunk/stdair/stdair/bom/BookingClass.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClass.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/BookingClass.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -37,89 +37,8 @@ BOM content child type. */ typedef BookingClass ContentChild_T; - public: - // /////////// Getters ///////////// - /** Get the FareFamily (parent class). */ - // FareFamily* getFareFamily() const { -// return _fareFamily; -// } - // ////// Getters from the parent class /////// -// /** Get the airline code (from the parent class). */ -// const AirlineCode_T& getAirlineCode() const; - -// /** Get the flight number (from the parent class). */ -// const FlightNumber_T& getFlightNumber() const; - -// /** Get the flight-date (from the parent class). */ -// const Date_T& getFlightDateDate() const; - -// /** Get the board point (from the parent class). */ -// const AirportCode_T& getBoardPoint () const; - -// /** Get the off point (from the parent class). */ -// const AirportCode_T& getOffPoint () const; - -// /** Get the board date (from the parent class). */ -// const Date_T& getBoardDate () const; - -// /** Get the cabin code (from the parent class). */ -// const CabinCode_T& getCabinCode () const; - -// /** Get the board time (from the parent class). */ -// const Duration_T& getBoardTime () const; - -// /** Get the off date (from the parent class). */ -// const Date_T& getOffDate () const; - -// /** Get the off time (from the parent class). */ -// const Duration_T& getOffTime () const; - -// /** Get the elapsed time (from the parent class). */ -// const Duration_T& getElapsedTime() const; - -// /** Get the distance (from the parent class). */ -// const Distance_T& getDistance() const; - -// /** Get the date off set (from the parent class). */ -// const DateOffSet_T getDateOffSet () const; - -// /** Get the time off set between board and off points (from the -// parent class). */ -// const Duration_T getTimeOffSet() const; - -// /** Retrieve, if existing, theOnD corresponding to the -// given OnDKey. -// <br>If not existing, return the NULL pointer. */ -// OnD* getOnD (const OnDKey_T& iOnDKey) const; - -// /** Get the size of the OnD list. */ -// const unsigned int getOnDListSize () const { -// return _onDList.size(); -// } - -// /** Get the list of OnDs related to this class. */ -// const OnDList_T& getOnDList() const { -// return _onDList; -// } - public: - // ///////// Setters ////////// - /** Set the Fare family (parent class). */ -// void setFareFamily (FareFamily& ioFareFamily) { -// _fareFamily = &ioFareFamily; -// } - - /** Reset the number of bookings to its intial state. */ - //void reset (); - -// /** Reset the booking fare. */ -// void resetFare(); - -// /** Reset the booking yield. */ -// void resetYield(); - - public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @param ostream& the output stream. */ @@ -140,46 +59,6 @@ at the same level). */ const std::string describeShortKey() const; - /** Give a description of the structure (for display purposes). */ - //const std::string describe() const; - - /** Get a string describing the solution (Fare, MatchIndicator...). */ - //const std::string describeSolution() const; - - public: - // ///////// Business Methods ////////// - /** Update the number of bookings. */ -// bool updateInventoryForReservation (const NbOfBookings_T&); - -// /** Update the number of cancellations. */ -// bool updateInventoryForCancellation (const NbOfCancellations_T&); - -// /** Update the number of no-shows. */ -// bool updateInventoryForNoShow (const NbOfNoShows_T&); - - -// /** Update the revenue of the booking. */ -// bool updateRevenue (const NbOfBookings_T&, const Fare_T&, -// const AnalysisStatus_T&); - -// /** Add the current censorship flag into the flag list. */ -// void addCurrentCensorshipFlagToTheFlagList(); - -// /** Build the Class-Segment code (for example:B-NCE-BKK->BNCEBKK). */ -// const std::string buildClassSegmentCode() const; - -// /** Insert a new OnD reference. */ -// void addOnD (OnD&); - -// /** Calculate the ratio of booking for this booking only -// (without OnD bookings). */ -// const BookingRatio_T calculateNetProductRatio(); - - protected: - /** Update some statistics of the SegmentCabin parent object.*/ -// void updateParentStatistics (const Revenue_T&, -// const NbOfBookings_T&) const; - private: /** Retrieve the BOM structure object. */ BomStructure_T& getBomStructure () { @@ -202,11 +81,6 @@ /** Reference structure. */ BomStructure_T& _bookingClassStructure; - /** Parent class: FareFamily. */ -// FareFamily* _fareFamily; - -// /** List of OnD references related to this bookingClass. */ -// OnDList_T _onDList; }; } Modified: trunk/stdair/stdair/bom/BookingClassContent.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassContent.cpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/BookingClassContent.cpp 2010-02-03 14:09:48 UTC (rev 112) @@ -41,17 +41,22 @@ BookingClassContent::~BookingClassContent () { } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// void BookingClassContent::setRemainingDemandMean(NbOfBookings_T& iMean) { _remainingDemandMean = iMean; _remainingProductDemandMean = iMean; } - // ////////////////////////////////////////////////////////////////////// + // //////////////////////////////////////////////////////////////////// void BookingClassContent::setRemainingDemandSD(NbOfBookings_T& iSD) { _remainingDemandSD = iSD; _remainingProductDemandSD = iSD; } + // //////////////////////////////////////////////////////////////////// + const AirlineCode_T BookingClassContent::getAirlineCode () const { + return _key.getAirlineCode(); + } + } Modified: trunk/stdair/stdair/bom/BookingClassContent.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassContent.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/BookingClassContent.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -142,6 +142,9 @@ return _remainingProductDemandSD; } + /** Get the airline code. */ + const AirlineCode_T getAirlineCode () const; + public: // /////////// Setters //////////// /** Set the booking limit. */ Modified: trunk/stdair/stdair/bom/BookingClassKey.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassKey.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/BookingClassKey.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -27,8 +27,15 @@ ~BookingClassKey_T (); // /////////// Getters ////////// - /** Get the cabin code. */ - const ClassCode_T& getClassCode () const; + /** Get the class code. */ + const ClassCode_T& getClassCode () const { + return _classCode; + } + + /** Get the airline code. */ + const AirlineCode_T getAirlineCode () const { + return _parentKey.getAirlineCode(); + } // /////////// Setters ///////////// void setParentKey (const ParentKey_T& iParentKey) { Modified: trunk/stdair/stdair/bom/BookingClassTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/BookingClassTypes.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/BookingClassTypes.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -31,6 +31,10 @@ /** Define the booking class map. */ typedef BomMap_T<BookingClass> BookingClassMap_T; + + /** Define the STL list of booking classes. */ + typedef std::vector<BookingClass*> BookingClassSTLList_T; + } #endif // __STDAIR_BOM_BOOKINGCLASSTYPES_HPP Modified: trunk/stdair/stdair/bom/BookingRequestStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/BookingRequestStruct.cpp 2010-02-03 14:09:48 UTC (rev 112) @@ -16,7 +16,10 @@ const AirportCode_T& iDestination, const Date_T& iDepartureDate, const PassengerType_T& iPaxType, - const NbOfSeats_T& iPartySize) { + const NbOfSeats_T& iPartySize) + : _origin (iOrigin), _destination (iDestination), + _departureDate (iDepartureDate), _paxType (iPaxType), + _partySize (iPartySize) { } // ////////////////////////////////////////////////////////////////////// Modified: trunk/stdair/stdair/bom/Network.cpp =================================================================== --- trunk/stdair/stdair/bom/Network.cpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/Network.cpp 2010-02-03 14:09:48 UTC (rev 112) @@ -14,7 +14,7 @@ // //////////////////////////////////////////////////////////////////// Network::Network (const BomKey_T& iKey, - BomStructure_T& ioNetworkStructure) + BomStructure_T& ioNetworkStructure) : NetworkContent (iKey), _networkStructure (ioNetworkStructure) { } @@ -59,10 +59,26 @@ } // ////////////////////////////////////////////////////////////////////// - NetworkDate* Network:: - getNetworkDate (const NetworkDateKey_T& iKey) const { + NetworkDate* Network::getNetworkDate (const NetworkDateKey_T& iKey) const { return _networkStructure.getContentChild (iKey); } + // ////////////////////////////////////////////////////////////////////// + NetworkDate* Network::getNetworkDate (const Date_T& iDate) const { + NetworkDate* oNetworkDate_ptr = NULL; + + NetworkDateMap_T lNetworkDateMap = getNetworkDateMap (); + + std::ostringstream ostr; + ostr << iDate; + NetworkDateMap_T::iterator itNetworkDate = lNetworkDateMap.find (ostr.str()); + + if (itNetworkDate != lNetworkDateMap.end()) { + oNetworkDate_ptr = itNetworkDate->second; + } + + return oNetworkDate_ptr; + } + } Modified: trunk/stdair/stdair/bom/Network.hpp =================================================================== --- trunk/stdair/stdair/bom/Network.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/Network.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -72,9 +72,14 @@ NetworkDateMap_T getNetworkDateMap () const; /** Retrieve, if existing, the NetworkDate corresponding to the - given network number and network date (NetworkDate key). + given NetworkDate key. <br>If not existing, return the NULL pointer. */ NetworkDate* getNetworkDate (const NetworkDateKey_T&) const; + + /** Retrieve, if existing, the NetworkDate corresponding to the + given Date . + <br>If not existing, return the NULL pointer. */ + NetworkDate* getNetworkDate (const Date_T&) const; private: Modified: trunk/stdair/stdair/bom/NetworkDate.cpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDate.cpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/NetworkDate.cpp 2010-02-03 14:09:48 UTC (rev 112) @@ -14,7 +14,7 @@ // //////////////////////////////////////////////////////////////////// NetworkDate::NetworkDate (const BomKey_T& iKey, - BomStructure_T& ioNetworkDateStructure) + BomStructure_T& ioNetworkDateStructure) : NetworkDateContent (iKey), _networkDateStructure (ioNetworkDateStructure) { } @@ -63,6 +63,21 @@ getAirportDate (const AirportDateKey_T& iKey) const { return _networkDateStructure.getContentChild (iKey); } + + // ////////////////////////////////////////////////////////////////////// + AirportDate* NetworkDate::getAirportDate (const AirportCode_T& iCode) const { + AirportDate* oAirportDate_ptr = NULL; + + AirportDateMap_T lAirportDateMap = getAirportDateMap (); + + AirportDateMap_T::iterator itAirportDate = lAirportDateMap.find (iCode); + + if (itAirportDate != lAirportDateMap.end()) { + oAirportDate_ptr = itAirportDate->second; + } + + return oAirportDate_ptr; + } } Modified: trunk/stdair/stdair/bom/NetworkDate.hpp =================================================================== --- trunk/stdair/stdair/bom/NetworkDate.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/NetworkDate.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -76,6 +76,11 @@ given airport-date key. <br>If not existing, return the NULL pointer. */ AirportDate* getAirportDate (const AirportDateKey_T&) const; + + /** Retrieve, if existing, the AirportDate corresponding to the + given airport-code. + <br>If not existing, return the NULL pointer. */ + AirportDate* getAirportDate (const AirportCode_T&) const; private: /** Retrieve the BOM structure object. */ Modified: trunk/stdair/stdair/bom/SegmentCabinKey.hpp =================================================================== --- trunk/stdair/stdair/bom/SegmentCabinKey.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/SegmentCabinKey.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -38,6 +38,11 @@ return _cabinCode; } + /** Get the airline code. */ + const AirlineCode_T getAirlineCode () const { + return _parentKey.getAirlineCode(); + } + // /////////// Setters ///////////// void setParentKey (const ParentKey_T& iParentKey) { _parentKey = iParentKey; Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.cpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.cpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.cpp 2010-02-03 14:09:48 UTC (rev 112) @@ -11,7 +11,38 @@ namespace stdair { + // //////////////////////////////////////////////////////////////////// + TravelSolutionStruct::TravelSolutionStruct () + : _outboundPath_ptr (NULL) { + assert (false); + } + + // //////////////////////////////////////////////////////////////////// + TravelSolutionStruct:: + TravelSolutionStruct (const TravelSolutionStruct& iTravelSolutionStruct) + : _outboundPath_ptr (iTravelSolutionStruct._outboundPath_ptr), + _bookingClassList (iTravelSolutionStruct._bookingClassList) { + } + + // //////////////////////////////////////////////////////////////////// + TravelSolutionStruct:: + TravelSolutionStruct (OutboundPath& ioOutboundPath, + const BookingClassSTLList_T& iBookingClassList) + : _outboundPath_ptr (&ioOutboundPath), + _bookingClassList (iBookingClassList) { + } + + // //////////////////////////////////////////////////////////////////// + TravelSolutionStruct::~TravelSolutionStruct () { + } + // ////////////////////////////////////////////////////////////////////// + OutboundPath& TravelSolutionStruct::getOutboundPath() const { + assert (_outboundPath_ptr != NULL); + return *_outboundPath_ptr; + } + + // ////////////////////////////////////////////////////////////////////// void TravelSolutionStruct::toStream (std::ostream& ioOut) const { ioOut << describe(); } Modified: trunk/stdair/stdair/bom/TravelSolutionStruct.hpp =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/TravelSolutionStruct.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -7,15 +7,28 @@ // STL #include <iosfwd> #include <string> +#include <vector> // StdAir #include <stdair/bom/StructAbstract.hpp> +#include <stdair/bom/BookingClassTypes.hpp> namespace stdair { - + // Forward declarations + class OutboundPath; + /** Structure holding the elements of a travel solution. */ struct TravelSolutionStruct : public StructAbstract { public: - + // /////////// Getters /////////////// + /** Get the OutboundPath. */ + OutboundPath& getOutboundPath() const; + + /** Get the list of booking classes. */ + const BookingClassSTLList_T& getBookingClassList () const { + return _bookingClassList; + } + + public: // /////////// Display support method ///////////// /** Dump a Business Object into an output stream. @param ostream& the output stream. */ @@ -28,9 +41,25 @@ /** Display of the structure. */ const std::string describe() const; - + + // //////////// Constructors & Destructor /////////////// + public: + /** Main constructor. */ + TravelSolutionStruct (OutboundPath&, const BookingClassSTLList_T&); + /** Destructor. */ + ~TravelSolutionStruct (); + /** Default copy constructor. */ + TravelSolutionStruct (const TravelSolutionStruct&); + /** Default constructor, not to be used. */ + TravelSolutionStruct (); + private: + // Attributes + /** The outbound path associated to this solution.*/ + OutboundPath* _outboundPath_ptr; + /** The list of booking classes which make the travel solution. */ + BookingClassSTLList_T _bookingClassList; }; } Copied: trunk/stdair/stdair/bom/TravelSolutionTypes.hpp (from rev 111, trunk/stdair/stdair/bom/BookingClassTypes.hpp) =================================================================== --- trunk/stdair/stdair/bom/TravelSolutionTypes.hpp (rev 0) +++ trunk/stdair/stdair/bom/TravelSolutionTypes.hpp 2010-02-03 14:09:48 UTC (rev 112) @@ -0,0 +1,22 @@ +// ////////////////////////////////////////////////////////////////////// +#ifndef __STDAIR_BOM_TRAVELSOLUTIONTYPES_HPP +#define __STDAIR_BOM_TRAVELSOLUTIONTYPES_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <map> +#include <vector> + +namespace stdair { + + // Forward declarations. + struct TravelSolutionStruct; + + /** Define the booking class list. */ + typedef std::vector<TravelSolutionStruct> TravelSolutionList_T; + +} +#endif // __STDAIR_BOM_TRAVELSOLUTIONTYPES_HPP + Modified: trunk/stdair/stdair/bom/sources.mk =================================================================== --- trunk/stdair/stdair/bom/sources.mk 2010-01-29 16:03:38 UTC (rev 111) +++ trunk/stdair/stdair/bom/sources.mk 2010-02-03 14:09:48 UTC (rev 112) @@ -83,6 +83,7 @@ $(top_srcdir)/stdair/bom/OptimizerStruct.hpp \ $(top_srcdir)/stdair/bom/DoWStruct.hpp \ $(top_srcdir)/stdair/bom/TravelSolutionStruct.hpp \ + $(top_srcdir)/stdair/bom/TravelSolutionTypes.hpp \ $(top_srcdir)/stdair/bom/BookingRequestStruct.hpp \ $(top_srcdir)/stdair/bom/BomManager.hpp bom_cc_sources = \ 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:03:44
|
Revision: 111 http://stdair.svn.sourceforge.net/stdair/?rev=111&view=rev Author: quannaus Date: 2010-01-29 16:03:38 +0000 (Fri, 29 Jan 2010) Log Message: ----------- [Dev] Moved the STDAIR_ServicePtr_T into STDAIR_Types.hpp Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/core/sources.mk Removed Paths: ------------- trunk/stdair/stdair/STDAIR_ServicePtr.hpp Deleted: trunk/stdair/stdair/STDAIR_ServicePtr.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_ServicePtr.hpp 2010-01-28 23:35:01 UTC (rev 110) +++ trunk/stdair/stdair/STDAIR_ServicePtr.hpp 2010-01-29 16:03:38 UTC (rev 111) @@ -1,19 +0,0 @@ -#ifndef __STDAIR_SVC_STDAIR_SERVICEPTR_HPP -#define __STDAIR_SVC_STDAIR_SERVICEPTR_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// Boost -#include <boost/shared_ptr.hpp> - -namespace stdair { - - // Forward declarations - class STDAIR_Service; - - /** Pointer on the STDAIR Service handler. */ - typedef boost::shared_ptr<STDAIR_Service> STDAIR_ServicePtr_T; - -} -#endif // __STDAIR_SVC_STDAIR_SERVICEPTR_HPP Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-28 23:35:01 UTC (rev 110) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-29 16:03:38 UTC (rev 111) @@ -12,9 +12,13 @@ #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/tuple/tuple.hpp> +#include <boost/shared_ptr.hpp> namespace stdair { + // Forward declarations + class STDAIR_Service; + // ///////// Exceptions /////////// class RootException : public std::exception { }; @@ -361,5 +365,8 @@ or C:\foo\bar). */ typedef std::string Filename_T; + /** Pointer on the STDAIR Service handler. */ + typedef boost::shared_ptr<STDAIR_Service> STDAIR_ServicePtr_T; + } #endif // __STDAIR_STDAIR_TYPES_HPP Modified: trunk/stdair/stdair/core/sources.mk =================================================================== --- trunk/stdair/stdair/core/sources.mk 2010-01-28 23:35:01 UTC (rev 110) +++ trunk/stdair/stdair/core/sources.mk 2010-01-29 16:03:38 UTC (rev 111) @@ -1,4 +1,3 @@ service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp \ - $(top_srcdir)/stdair/STDAIR_Service.hpp \ - $(top_srcdir)/stdair/STDAIR_ServicePtr.hpp + $(top_srcdir)/stdair/STDAIR_Service.hpp service_cc_sources = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-28 23:35:07
|
Revision: 110 http://stdair.svn.sourceforge.net/stdair/?rev=110&view=rev Author: denis_arnaud Date: 2010-01-28 23:35:01 +0000 (Thu, 28 Jan 2010) Log Message: ----------- There is now a separate header file for defining (smart) pointer on the STDAIR_Service. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/core/sources.mk Added Paths: ----------- trunk/stdair/stdair/STDAIR_ServicePtr.hpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 22:49:08 UTC (rev 109) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 23:35:01 UTC (rev 110) @@ -4,6 +4,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> // StdAir #include <stdair/basic/BasLogParams.hpp> Added: trunk/stdair/stdair/STDAIR_ServicePtr.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_ServicePtr.hpp (rev 0) +++ trunk/stdair/stdair/STDAIR_ServicePtr.hpp 2010-01-28 23:35:01 UTC (rev 110) @@ -0,0 +1,19 @@ +#ifndef __STDAIR_SVC_STDAIR_SERVICEPTR_HPP +#define __STDAIR_SVC_STDAIR_SERVICEPTR_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost +#include <boost/shared_ptr.hpp> + +namespace stdair { + + // Forward declarations + class STDAIR_Service; + + /** Pointer on the STDAIR Service handler. */ + typedef boost::shared_ptr<STDAIR_Service> STDAIR_ServicePtr_T; + +} +#endif // __STDAIR_SVC_STDAIR_SERVICEPTR_HPP Modified: trunk/stdair/stdair/core/sources.mk =================================================================== --- trunk/stdair/stdair/core/sources.mk 2010-01-28 22:49:08 UTC (rev 109) +++ trunk/stdair/stdair/core/sources.mk 2010-01-28 23:35:01 UTC (rev 110) @@ -1,3 +1,4 @@ service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp \ - $(top_srcdir)/stdair/STDAIR_Service.hpp + $(top_srcdir)/stdair/STDAIR_Service.hpp \ + $(top_srcdir)/stdair/STDAIR_ServicePtr.hpp service_cc_sources = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-28 22:49:16
|
Revision: 109 http://stdair.svn.sourceforge.net/stdair/?rev=109&view=rev Author: denis_arnaud Date: 2010-01-28 22:49:08 +0000 (Thu, 28 Jan 2010) Log Message: ----------- [Dev] Added a reference on the BomRoot in the STDAIR_Service. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Modified: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 15:49:36 UTC (rev 108) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-28 22:49:08 UTC (rev 109) @@ -9,6 +9,10 @@ namespace stdair { + // Forward declarations + class BomRoot; + + /** Interface for the STDAIR Services. */ class STDAIR_Service { public: @@ -26,6 +30,15 @@ ~STDAIR_Service(); + // ///////////////// Getters /////////////////// + /** Get a reference on the BomRoot object. + <br>If the service context has not been initialised, that + method throws an exception (failing assertion). */ + BomRoot& getBomRoot () const { + return _bomRoot; + } + + private: // /////// Construction and Destruction helper methods /////// /** Default constructor. */ @@ -47,6 +60,12 @@ /** Finalise. */ void finalise (); + + + private: + // /////////////// Attributes /////////////// + /** Root of the BOM tree. */ + BomRoot& _bomRoot; }; } #endif // __STDAIR_SVC_STDAIR_SERVICE_HPP Modified: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-01-28 15:49:36 UTC (rev 108) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-01-28 22:49:08 UTC (rev 109) @@ -6,24 +6,34 @@ // StdAir #include <stdair/basic/BasChronometer.hpp> #include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/Inventory.hpp> // Child of BomRoot, needed for creation of BomRoot +#include <stdair/bom/Network.hpp> // Child of BomRoot, needed for creation of BomRoot #include <stdair/factory/FacSupervisor.hpp> +#include <stdair/factory/FacBomContent.hpp> #include <stdair/service/Logger.hpp> #include <stdair/STDAIR_Service.hpp> namespace stdair { // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service () { + STDAIR_Service::STDAIR_Service () + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { assert (false); } // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service (const STDAIR_Service& iService) { + STDAIR_Service::STDAIR_Service (const STDAIR_Service& iService) + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { assert (false); } // ////////////////////////////////////////////////////////////////////// - STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) { + STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) + : _bomRoot (FacBomContent::instance().create<BomRoot>()) { + // The root of the BOM tree, on which all of the other BOM objects + // will be attached, is being created with the STDAIR_Service constructor. + // Set the log file logInit (iLogParams); @@ -44,8 +54,6 @@ // ////////////////////////////////////////////////////////////////////// void STDAIR_Service::init () { - // Create the static instance of the FacSupervisor object - FacSupervisor::instance(); } // ////////////////////////////////////////////////////////////////////// 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:49:49
|
Revision: 108 http://stdair.svn.sourceforge.net/stdair/?rev=108&view=rev Author: quannaus Date: 2010-01-28 15:49:36 +0000 (Thu, 28 Jan 2010) Log Message: ----------- [dev] Added the getAirlineCode fuction in Inventory. Modified Paths: -------------- trunk/stdair/stdair/bom/InventoryContent.hpp Modified: trunk/stdair/stdair/bom/InventoryContent.hpp =================================================================== --- trunk/stdair/stdair/bom/InventoryContent.hpp 2010-01-26 15:16:38 UTC (rev 107) +++ trunk/stdair/stdair/bom/InventoryContent.hpp 2010-01-28 15:49:36 UTC (rev 108) @@ -41,6 +41,11 @@ public: // ////////// Getters //////////// + /** Get the airline code. */ + const AirlineCode_T& getAirlineCode () const { + return _key.getAirlineCode(); + } + /** Get the inventory key. */ const BomKey_T& getKey() const { return _key; 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:16:47
|
Revision: 107 http://stdair.svn.sourceforge.net/stdair/?rev=107&view=rev Author: quannaus Date: 2010-01-26 15:16:38 +0000 (Tue, 26 Jan 2010) Log Message: ----------- [Dev] Changed some comments in the OutboundPathTypes file Modified Paths: -------------- trunk/stdair/stdair/bom/OutboundPathTypes.hpp Modified: trunk/stdair/stdair/bom/OutboundPathTypes.hpp =================================================================== --- trunk/stdair/stdair/bom/OutboundPathTypes.hpp 2010-01-26 15:15:40 UTC (rev 106) +++ trunk/stdair/stdair/bom/OutboundPathTypes.hpp 2010-01-26 15:16:38 UTC (rev 107) @@ -17,19 +17,19 @@ template <typename BOM> struct BomMap_T; class OutboundPath; - /** Define the booking class structure. */ + /** Define the outbound path structure. */ typedef OutboundPathStructure<OutboundPath> OutboundPathStructure_T; - /** Define the booking class structure list. */ + /** Define the outbound path structure list. */ typedef std::vector<OutboundPathStructure_T*> OutboundPathStructureList_T; - /** Define the booking class structure map. */ + /** Define the outbound path structure map. */ typedef std::map<const std::string, OutboundPathStructure_T*> OutboundPathStructureMap_T; - /** Define the booking class list. */ + /** Define the outbound path list. */ typedef BomList_T<OutboundPath> OutboundPathList_T; - /** Define the booking class map. */ + /** Define the outbound path map. */ typedef BomMap_T<OutboundPath> OutboundPathMap_T; typedef std::vector<std::vector<stdair::OutboundPath*> >OutboundPathListList_T; 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:15:47
|
Revision: 106 http://stdair.svn.sourceforge.net/stdair/?rev=106&view=rev Author: quannaus Date: 2010-01-26 15:15:40 +0000 (Tue, 26 Jan 2010) Log Message: ----------- A small change in the schedule file to make it up to date. Modified Paths: -------------- trunk/stdair/test/samples/schedule01.csv Modified: trunk/stdair/test/samples/schedule01.csv =================================================================== --- trunk/stdair/test/samples/schedule01.csv 2010-01-22 20:03:36 UTC (rev 105) +++ trunk/stdair/test/samples/schedule01.csv 2010-01-26 15:15:40 UTC (rev 106) @@ -3,6 +3,6 @@ // ElapsedTime; LegCabins; // LegCabins: CabinCode; Capacity; // Segments: Specific; -BA; 117; 2009-01-15; 2009-01-28; 1111100; LHR; JFK; 08:20; 11:00; 07:40; Y; 300; 0; Y; YM; -BA; 117; 2009-01-15; 2009-01-28; 0000011; LHR; JFK; 09:20; 12:00; 07:40; Y; 200; 0; Y; YM; +BA; 117; 2010-01-15; 2010-01-28; 1111100; LHR; JFK; 08:20; 11:00; 07:40; Y; 300; 0; Y; YM; +BA; 117; 2010-01-15; 2010-01-28; 0000011; LHR; JFK; 09:20; 12:00; 07:40; Y; 200; 0; Y; YM; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-22 20:03:44
|
Revision: 105 http://stdair.svn.sourceforge.net/stdair/?rev=105&view=rev Author: denis_arnaud Date: 2010-01-22 20:03:36 +0000 (Fri, 22 Jan 2010) Log Message: ----------- [Dev] Fixed the warning message about the Logger object instantiation. Modified Paths: -------------- trunk/stdair/stdair/service/Logger.cpp Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-22 19:47:29 UTC (rev 104) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-22 20:03:36 UTC (rev 105) @@ -10,12 +10,12 @@ Logger* Logger::_instance = NULL; // ////////////////////////////////////////////////////////////////////// - Logger::Logger () : _logStream (std::cout), _level (LOG::DEBUG) { + Logger::Logger () : _level (LOG::DEBUG), _logStream (std::cout) { assert (false); } // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const Logger&) : _logStream (std::cout), _level (LOG::DEBUG) { + Logger::Logger (const Logger&) : _level (LOG::DEBUG), _logStream (std::cout) { assert (false); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-22 19:47:36
|
Revision: 104 http://stdair.svn.sourceforge.net/stdair/?rev=104&view=rev Author: denis_arnaud Date: 2010-01-22 19:47:29 +0000 (Fri, 22 Jan 2010) Log Message: ----------- [Dev] Added a STDAIR_Service, wrapper around both the static Logger instance and the stdair::FacSupervisor one. Modified Paths: -------------- trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/basic/Makefile.am trunk/stdair/stdair/bom/Makefile.am trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/core/sources.mk trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/factory/FacSupervisor.hpp trunk/stdair/stdair/factory/Makefile.am trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Makefile.am trunk/stdair/stdair/service/sources.mk Added Paths: ----------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -13,5 +13,5 @@ # Header files -nobase_pkginclude_HEADERS = $(service_h_sources) +#nobase_pkginclude_HEADERS = $(service_h_sources) #nobase_nodist_pkginclude_HEADERS = $(top_builddir)/@PACKAGE@/config.h Added: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp (rev 0) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-22 19:47:29 UTC (rev 104) @@ -0,0 +1,52 @@ +#ifndef __STDAIR_SVC_STDAIR_SERVICE_HPP +#define __STDAIR_SVC_STDAIR_SERVICE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/basic/BasLogParams.hpp> + +namespace stdair { + + /** Interface for the STDAIR Services. */ + class STDAIR_Service { + 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. + @param const stdair::BasLogParams& Parameters for the output log + stream. */ + STDAIR_Service (const BasLogParams&); + + /** Destructor. */ + ~STDAIR_Service(); + + + private: + // /////// Construction and Destruction helper methods /////// + /** Default constructor. */ + STDAIR_Service (); + /** Default copy constructor. */ + STDAIR_Service (const STDAIR_Service&); + + /** Initialise the log. */ + void logInit (const BasLogParams&); + + /** Initialise. + <br>The static instance of the log service (Logger object) is created. + <br>The static instance of the FacSupervisor object, itself referencing + all the other objects (factories and BOM), is created. + <br>As those two objects are static, there is no need to store them + in any service context. However, some lock mechanism may be needed + in order to secure the access to the corresponding resources. */ + void init (); + + /** Finalise. */ + void finalise (); + }; +} +#endif // __STDAIR_SVC_STDAIR_SERVICE_HPP Modified: trunk/stdair/stdair/basic/Makefile.am =================================================================== --- trunk/stdair/stdair/basic/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/basic/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -2,11 +2,14 @@ include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk +# noinst_LTLIBRARIES= libbas.la libbas_la_SOURCES = $(bas_h_sources) $(bas_cc_sources) libbas_la_CXXFLAGS = $(BOOST_CFLAGS) libbas_la_LDFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/basic -#pkginclude_HEADERS = $(bas_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/basic +pkginclude_HEADERS = $(bas_h_sources) Modified: trunk/stdair/stdair/bom/Makefile.am =================================================================== --- trunk/stdair/stdair/bom/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/bom/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -8,5 +8,7 @@ libbom_la_CXXFLAGS = $(BOOST_CFLAGS) libbom_la_LDFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/bom -#pkginclude_HEADERS = $(bom_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/bom +pkginclude_HEADERS = $(bom_h_sources) Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/core/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -21,3 +21,7 @@ libstdair_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ -version-info $(GENERIC_LIBRARY_VERSION) + +# +pkgincludedir = $(includedir)/stdair +pkginclude_HEADERS = $(service_h_sources) Modified: trunk/stdair/stdair/core/sources.mk =================================================================== --- trunk/stdair/stdair/core/sources.mk 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/core/sources.mk 2010-01-22 19:47:29 UTC (rev 104) @@ -1,2 +1,3 @@ -service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp +service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp \ + $(top_srcdir)/stdair/STDAIR_Service.hpp service_cc_sources = Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -38,7 +38,6 @@ FacSupervisor::~FacSupervisor() { cleanBomStructureLayer(); cleanBomContentLayer(); - cleanLoggerService(); } // ////////////////////////////////////////////////////////////////////// @@ -78,11 +77,13 @@ } // ////////////////////////////////////////////////////////////////////// - void FacSupervisor::cleanFactory () { + void FacSupervisor::cleanAll () { // Clean the static instance of the log service - Logger::clean(); + cleanLoggerService(); - // Clean the static instance of the FacSupervisor + // Clean the static instance of the FacSupervisor. + // This in turn will invoke the destructor (~FacSupervisor() method) + // of the static instance. delete _instance; _instance = NULL; } Modified: trunk/stdair/stdair/factory/FacSupervisor.hpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-22 19:47:29 UTC (rev 104) @@ -24,43 +24,46 @@ typedef std::vector<FacBomStructure*> BomStructureFactoryPool_T; typedef std::vector<FacBomContent*> BomContentFactoryPool_T; - /** Provides the unique instance. + /** Provide the unique (static) instance of the FacSupervisor object. <br>The singleton is instantiated when first used. @return FacSupervisor& */ static FacSupervisor& instance(); - /** Register a newly instantiated concrete factory for the BomStructure layer. + /** Register a newly instantiated concrete factory for the + BomStructure layer. <br>When a concrete Factory is firstly instantiated this factory have to register itself to the FacSupervisor - @param FacBomStructure& the concrete Factory to register. */ + @param FacBomStructure* The concrete Factory to register. */ void registerBomStructureFactory (FacBomStructure*); - /** Register a newly instantiated concrete factory for the BomContent layer. + /** Register a newly instantiated concrete factory for the + BomContent layer. <br>When a concrete Factory is firstly instantiated this factory have to register itself to the FacSupervisor - @param FacBomContent& the concrete Factory to register. */ + @param FacBomContent* The concrete Factory to register. */ void registerBomContentFactory (FacBomContent*); - /** Clean all created object. - <br>Call the clean method of all the instantiated factories + /** Clean all registered object. + <br>Call the clean method of all the instantiated factories for the BomStructure layer. */ void cleanBomStructureLayer(); - /** Clean all created object. - <br>Call the clean method of all the instantiated factories + /** Clean all the registered object. + <br>Call the clean method of all the instantiated factories for the BomContent layer. */ void cleanBomContentLayer(); - /** Delete the Logger object. */ - void cleanLoggerService(); + /** Delete the static instance of the Logger object. */ + static void cleanLoggerService(); /** Clean the static instance. - <br> The singleton is deleted.*/ - static void cleanFactory (); + <br>As the static instance (singleton) is deleted, all the other + registered objects will be deleted in turn. */ + static void cleanAll (); - /** Destructor - <br>The static instance is deleted (and reset to NULL) - by the static cleanFactory() method. */ + /** Destructor. + <br>That destructors is applied on the static instance. It then + deletes in turn all the other registered objects. */ ~FacSupervisor(); Modified: trunk/stdair/stdair/factory/Makefile.am =================================================================== --- trunk/stdair/stdair/factory/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -7,5 +7,7 @@ libfac_la_SOURCES= $(fac_h_sources) $(fac_cc_sources) libfac_la_CXXFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/factory -#pkginclude_HEADERS = $(fac_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/factory +pkginclude_HEADERS = $(fac_h_sources) Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -26,7 +26,7 @@ // ////////////////////////////////////////////////////////////////////// Logger::~Logger () { - std::cout << "In Logger destructor" << std::endl; + // std::cout << "In Logger destructor" << std::endl; } // ////////////////////////////////////////////////////////////////////// @@ -52,9 +52,11 @@ // ////////////////////////////////////////////////////////////////////// void Logger::clean() { - std::cout << "In Logger::clean(), before static instance deletion" << std::endl; + // std::cout << "In Logger::clean(), before static instance deletion" + // << std::endl; delete _instance; _instance = NULL; - std::cout << "In Logger::clean(), after static instance deletion" << std::endl; + // std::cout << "In Logger::clean(), after static instance deletion" + // << std::endl; } } Modified: trunk/stdair/stdair/service/Makefile.am =================================================================== --- trunk/stdair/stdair/service/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -2,10 +2,12 @@ include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk +# noinst_LTLIBRARIES= libsvc.la libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) libsvc_la_CXXFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/service -#pkginclude_HEADERS = $(svc_h_sources) +# Header files +pkgincludedir = $(includedir)/stdair/service +pkginclude_HEADERS = $(svc_h_sources) Added: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp (rev 0) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -0,0 +1,58 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// StdAir +#include <stdair/basic/BasChronometer.hpp> +#include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/factory/FacSupervisor.hpp> +#include <stdair/service/Logger.hpp> +#include <stdair/STDAIR_Service.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service () { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const STDAIR_Service& iService) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) { + // Set the log file + logInit (iLogParams); + + // Initialise the (remaining of the) context + init (); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::~STDAIR_Service () { + // Delete/Clean all the objects from memory + finalise(); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::logInit (const BasLogParams& iLogParams) { + Logger::init (iLogParams); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::init () { + // Create the static instance of the FacSupervisor object + FacSupervisor::instance(); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::finalise () { + // std::cout << "In STDAIR_Service destructor, before cleaning" << std::endl; + FacSupervisor::cleanAll(); + // std::cout << "In STDAIR_Service destructor, after cleaning" << std::endl; + } + +} Modified: trunk/stdair/stdair/service/sources.mk =================================================================== --- trunk/stdair/stdair/service/sources.mk 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/sources.mk 2010-01-22 19:47:29 UTC (rev 104) @@ -1,2 +1,3 @@ svc_h_sources = $(top_srcdir)/stdair/service/Logger.hpp -svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp +svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp \ + $(top_srcdir)/stdair/service/STDAIR_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 23:31:04
|
Revision: 103 http://stdair.svn.sourceforge.net/stdair/?rev=103&view=rev Author: denis_arnaud Date: 2010-01-21 23:30:57 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The static log service instance is now cleaned directly within the FacSupervisor::cleanFactory() method. Modified Paths: -------------- trunk/stdair/stdair/factory/FacBomContent.cpp trunk/stdair/stdair/factory/FacBomStructure.cpp trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/service/Logger.cpp Modified: trunk/stdair/stdair/factory/FacBomContent.cpp =================================================================== --- trunk/stdair/stdair/factory/FacBomContent.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/factory/FacBomContent.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -1,8 +1,8 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> +// STL +#include <cassert> // STDAIR #include <stdair/bom/BomStructure.hpp> #include <stdair/bom/BomContent.hpp> Modified: trunk/stdair/stdair/factory/FacBomStructure.cpp =================================================================== --- trunk/stdair/stdair/factory/FacBomStructure.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/factory/FacBomStructure.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -1,9 +1,9 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> -// STDAIR +// STL +#include <cassert> +// StdAir #include <stdair/bom/BomStructure.hpp> #include <stdair/factory/FacSupervisor.hpp> #include <stdair/factory/FacBomStructure.hpp> Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -3,7 +3,6 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> -#include <ostream> // StdAir #include <stdair/factory/FacBomStructure.hpp> #include <stdair/factory/FacBomContent.hpp> @@ -39,6 +38,7 @@ FacSupervisor::~FacSupervisor() { cleanBomStructureLayer(); cleanBomContentLayer(); + cleanLoggerService(); } // ////////////////////////////////////////////////////////////////////// @@ -73,16 +73,16 @@ // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanLoggerService() { + // Clean the static instance of the log service Logger::clean(); } // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanFactory () { - if (_instance != NULL) { - _instance->cleanBomStructureLayer(); - _instance->cleanBomContentLayer(); - _instance->cleanLoggerService(); - } + // Clean the static instance of the log service + Logger::clean(); + + // Clean the static instance of the FacSupervisor delete _instance; _instance = NULL; } Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-21 19:35:16 UTC (rev 102) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-21 23:30:57 UTC (rev 103) @@ -26,6 +26,7 @@ // ////////////////////////////////////////////////////////////////////// Logger::~Logger () { + std::cout << "In Logger destructor" << std::endl; } // ////////////////////////////////////////////////////////////////////// @@ -33,11 +34,11 @@ // Sanity check if (_instance != NULL) { STDAIR_LOG_ERROR ("Error: the log stream has already been initialised"); - // TODO: throw an exception? + assert (false); + } + assert (_instance == NULL); - } else { - _instance = new Logger (iLogParams); - } + _instance = new Logger (iLogParams); } // ////////////////////////////////////////////////////////////////////// @@ -51,7 +52,9 @@ // ////////////////////////////////////////////////////////////////////// void Logger::clean() { + std::cout << "In Logger::clean(), before static instance deletion" << std::endl; delete _instance; _instance = NULL; + std::cout << "In Logger::clean(), after static instance deletion" << std::endl; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-21 19:35:25
|
Revision: 102 http://stdair.svn.sourceforge.net/stdair/?rev=102&view=rev Author: denis_arnaud Date: 2010-01-21 19:35:16 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The log output stream initialisation has been moved into the StdAir library. Modified Paths: -------------- trunk/stdair/stdair/basic/sources.mk Added Paths: ----------- trunk/stdair/stdair/basic/StructAbstract.hpp Added: trunk/stdair/stdair/basic/StructAbstract.hpp =================================================================== --- trunk/stdair/stdair/basic/StructAbstract.hpp (rev 0) +++ trunk/stdair/stdair/basic/StructAbstract.hpp 2010-01-21 19:35:16 UTC (rev 102) @@ -0,0 +1,81 @@ +#ifndef __STDAIR_BAS_STRUCTABSTRACT_HPP +#define __STDAIR_BAS_STRUCTABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> + +namespace stdair { + + /** Base class for the light structures. */ + struct StructAbstract { + public: + + /** Destructor. */ + virtual ~StructAbstract() {} + + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { + ioOut << describe(); + } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + virtual void fromStream (std::istream& ioIn) {} + + /** Display of the structure. */ + virtual const std::string describe() const = 0; + + protected: + /** Protected Default Constructor to ensure this class is abtract. */ + StructAbstract() {} + }; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (p653) of his book "The C++ Standard Library: A Tutorial + and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_ostream<charT, traits>& +operator<< (std::basic_ostream<charT, traits>& ioOut, + const stdair::StructAbstract& iStruct) { + /** + string stream: + - with same format + - without special field width + */ + std::basic_ostringstream<charT,traits> ostr; + ostr.copyfmt (ioOut); + ostr.width (0); + + // Fill string stream + iStruct.toStream (ostr); + + // Print string stream + ioOut << ostr.str(); + + return ioOut; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (pp655-657) of his book "The C++ Standard Library: + A Tutorial and Reference", published by Addison-Wesley. +*/ +template <class charT, class traits> +inline +std::basic_istream<charT, traits>& +operator>> (std::basic_istream<charT, traits>& ioIn, + stdair::StructAbstract& ioStruct) { + // Fill the Structure object with the input stream. + ioStruct.fromStream (ioIn); + return ioIn; + +} +#endif // __STDAIR_BAS_STRUCTABSTRACT_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-21 13:26:12 UTC (rev 101) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-21 19:35:16 UTC (rev 102) @@ -6,6 +6,7 @@ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ + $(top_srcdir)/stdair/basic/StructAbstract.hpp \ $(top_srcdir)/stdair/basic/BasChronometer.hpp \ $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ $(top_srcdir)/stdair/basic/BasLogParams.hpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-21 13:26:18
|
Revision: 101 http://stdair.svn.sourceforge.net/stdair/?rev=101&view=rev Author: denis_arnaud Date: 2010-01-21 13:26:12 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The log output stream initialisation has been moved into the StdAir library. Modified Paths: -------------- trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Logger.hpp Added Paths: ----------- trunk/stdair/stdair/basic/BasDBParams.cpp trunk/stdair/stdair/basic/BasDBParams.hpp trunk/stdair/stdair/basic/BasLogParams.cpp trunk/stdair/stdair/basic/BasLogParams.hpp Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -22,6 +22,9 @@ class FileNotFoundException : public RootException { }; + class NonInitialisedLogServiceException : public RootException { + }; + class NonInitialisedServiceException : public RootException { }; Added: trunk/stdair/stdair/basic/BasDBParams.cpp =================================================================== --- trunk/stdair/stdair/basic/BasDBParams.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasDBParams.cpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,61 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <istream> +#include <ostream> +#include <sstream> +// StdAir +#include <stdair/basic/BasDBParams.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + BasDBParams::BasDBParams (const std::string& iDBUser, + const std::string& iDBPasswd, + const std::string& iDBHost, + const std::string& iDBPort, + const std::string& iDBName) + : _user (iDBUser), _passwd (iDBPasswd), _host (iDBHost), _port (iDBPort), + _dbname (iDBName) { + } + + // ////////////////////////////////////////////////////////////////////// + BasDBParams::~BasDBParams() { + } + + // ////////////////////////////////////////////////////////////////////// + void BasDBParams::toStream (std::ostream& ioOut) const { + ioOut << toString(); + } + + // ////////////////////////////////////////////////////////////////////// + void BasDBParams::fromStream (std::istream&) { + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasDBParams::toShortString() const { + std::ostringstream oStr; + oStr << _dbname << "." << _user << "@" << _host << ":" << _port; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasDBParams::toString() const { + std::ostringstream oStr; + oStr << _dbname << "." << _user << "@" << _host << ":" << _port; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + bool BasDBParams::check () const { + if (_user.empty() == true || _passwd.empty() == true + || _host.empty() == true || _port.empty() + || _dbname.empty() == true) { + return false; + } + return true; + } + +} Added: trunk/stdair/stdair/basic/BasDBParams.hpp =================================================================== --- trunk/stdair/stdair/basic/BasDBParams.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasDBParams.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,125 @@ +#ifndef __STDAIR_BAS_BASDBPARAMS_HPP +#define __STDAIR_BAS_BASDBPARAMS_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +#include <string> +// Stdair +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Structure holding the parameters for connection to a database. */ + struct BasDBParams { + public: + // ///////// Getters //////// + /** Get the database user name. */ + std::string getUser() const { + return _user; + } + + /** Get the database user password. */ + std::string getPassword() const { + return _passwd; + } + + /** Get the database host name. */ + std::string getHost() const { + return _host; + } + + /** Get the database port number. */ + std::string getPort() const { + return _port; + } + + /** Get the database name. */ + std::string getDBName() const { + return _dbname; + } + + + // ///////// Setters ////////// + /** Set the database user name. */ + void setUser (const std::string& iUser) { + _user = iUser; + } + + /** Set the database password. */ + void setPassword (const std::string& iPasswd) { + _passwd = iPasswd; + } + + /** Set the database host name. */ + void setHost (const std::string& iHost) { + _host = iHost; + } + + /** Set the database port number. */ + void setPort (const std::string& iPort) { + _port = iPort; + } + + /** Set the database name. */ + void setDBName (const std::string& iDBName) { + _dbname = iDBName; + } + + + public: + // ///////// Busines methods //////// + /** Check that all the parameters are fine. */ + bool check () const; + + + public: + // ///////// Display methods //////// + /** Dump a structure into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a structure from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream&); + + /** Get a short display of the DBParams structure. */ + std::string toShortString() const; + + /** Get the serialised version of the DBParams structure. */ + std::string toString() const; + + + public: + /** Main Constructor. */ + BasDBParams (const std::string& iDBUser, const std::string& iDBPasswd, + const std::string& iDBHost, const std::string& iDBPort, + const std::string& iDBName); + + /** Default Constructor. */ + // BasDBParams (); + /** Default copy constructor. */ + // BasDBParams (const BasDBParams&); + + /** Destructor. */ + ~BasDBParams(); + + + private: + // /////// Attributes ///////// + /** Database user name. */ + std::string _user; + /** Database user password. */ + std::string _passwd; + /** Database host name. */ + std::string _host; + /** Database port number. */ + std::string _port; + /** Database name. */ + std::string _dbname; + }; + +} +#endif // __STDAIR_BAS_BASDBPARAMS_HPP Added: trunk/stdair/stdair/basic/BasLogParams.cpp =================================================================== --- trunk/stdair/stdair/basic/BasLogParams.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasLogParams.cpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,47 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <istream> +#include <ostream> +#include <sstream> +// StdAir +#include <stdair/basic/BasLogParams.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + BasLogParams::BasLogParams (const LOG::EN_LogLevel iLogLevel, + std::ostream& ioLogOutputStream) + : _logLevel (iLogLevel), _logStream (ioLogOutputStream) { + } + + // ////////////////////////////////////////////////////////////////////// + BasLogParams::~BasLogParams() { + } + + // ////////////////////////////////////////////////////////////////////// + void BasLogParams::toStream (std::ostream& ioOut) const { + ioOut << toString(); + } + + // ////////////////////////////////////////////////////////////////////// + void BasLogParams::fromStream (std::istream&) { + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasLogParams::toShortString() const { + std::ostringstream oStr; + oStr << LOG::_logLevels[_logLevel]; + return oStr.str(); + } + + // ////////////////////////////////////////////////////////////////////// + std::string BasLogParams::toString() const { + std::ostringstream oStr; + oStr << LOG::_logLevels[_logLevel]; + return oStr.str(); + } + +} Added: trunk/stdair/stdair/basic/BasLogParams.hpp =================================================================== --- trunk/stdair/stdair/basic/BasLogParams.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasLogParams.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -0,0 +1,82 @@ +#ifndef __STDAIR_BAS_BASLOGPARAMS_HPP +#define __STDAIR_BAS_BASLOGPARAMS_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +#include <string> +// Stdair +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** Structure holding parameters for logging. */ + struct BasLogParams { + friend class Logger; + public: + // ///////// Getters //////// + /** Get the log level. */ + const LOG::EN_LogLevel& getLogLevel() const { + return _logLevel; + } + + /** Get the log output stream. */ + std::ostream& getLogStream() const { + return _logStream; + } + + + // ///////// Setters ////////// + // No setters + + + public: + // ///////// Busines methods //////// + /** Check that all the parameters are fine. */ + bool check () const; + + + public: + // ///////// Display methods //////// + /** Dump a structure into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const; + + /** Read a structure from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream&); + + /** Get a short display of the LOGParams structure. */ + std::string toShortString() const; + + /** Get the serialised version of the LOGParams structure. */ + std::string toString() const; + + + public: + /** Main Constructor. */ + BasLogParams (const LOG::EN_LogLevel iLogLevel, + std::ostream& ioLogOutputStream); + + /** Default Constructor. */ + // BasLogParams (); + /** Default copy constructor. */ + // BasLogParams (const BasLogParams&); + + /** Destructor. */ + ~BasLogParams(); + + + private: + // /////// Attributes ///////// + /** Log level (e.g., LOG::DEBUG). */ + const LOG::EN_LogLevel _logLevel; + + /** Log output stream (e.g., std::cout). */ + std::ostream& _logStream; + }; + +} +#endif // __STDAIR_BAS_BASLOGPARAMS_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-21 13:26:12 UTC (rev 101) @@ -7,8 +7,12 @@ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ $(top_srcdir)/stdair/basic/BasChronometer.hpp \ - $(top_srcdir)/stdair/basic/BasFileMgr.hpp + $(top_srcdir)/stdair/basic/BasFileMgr.hpp \ + $(top_srcdir)/stdair/basic/BasLogParams.hpp \ + $(top_srcdir)/stdair/basic/BasDBParams.hpp bas_cc_sources = \ $(top_srcdir)/stdair/basic/BasConst.cpp \ $(top_srcdir)/stdair/basic/BasChronometer.cpp \ - $(top_srcdir)/stdair/basic/BasFileMgr.cpp + $(top_srcdir)/stdair/basic/BasFileMgr.cpp \ + $(top_srcdir)/stdair/basic/BasLogParams.cpp \ + $(top_srcdir)/stdair/basic/BasDBParams.cpp Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-21 13:26:12 UTC (rev 101) @@ -2,63 +2,56 @@ // Import section // ////////////////////////////////////////////////////////////////////// // Stdair Logger -#include <stdair/factory/FacSupervisor.hpp> +//#include <stdair/factory/FacSupervisor.hpp> #include <stdair/service/Logger.hpp> namespace stdair { - Logger* Logger::_instance = NULL; + Logger* Logger::_instance = NULL; - // ////////////////////////////////////////////////////////////////////// - Logger::Logger () : _logStream (&std::cout) { - assert (false); - } + // ////////////////////////////////////////////////////////////////////// + Logger::Logger () : _logStream (std::cout), _level (LOG::DEBUG) { + assert (false); + } - // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const Logger&) : _logStream (&std::cout) { - assert (false); - } + // ////////////////////////////////////////////////////////////////////// + Logger::Logger (const Logger&) : _logStream (std::cout), _level (LOG::DEBUG) { + assert (false); + } - // ////////////////////////////////////////////////////////////////////// - Logger::Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream) - : _level (iLevel), _logStream (&ioLogStream) { - } + // ////////////////////////////////////////////////////////////////////// + Logger::Logger (const stdair::BasLogParams& iLogParams) + : _level (iLogParams._logLevel), _logStream (iLogParams._logStream) { + } - // ////////////////////////////////////////////////////////////////////// - Logger::~Logger () { - _logStream = NULL; - } + // ////////////////////////////////////////////////////////////////////// + Logger::~Logger () { + } - // ////////////////////////////////////////////////////////////////////// - void Logger::clean() { - delete _instance; _instance = NULL; - } - - // ////////////////////////////////////////////////////////////////////// - LOG::EN_LogLevel Logger::getLogLevel() { - return _level; - } + // ////////////////////////////////////////////////////////////////////// + void Logger::init (const BasLogParams& iLogParams) { + // Sanity check + if (_instance != NULL) { + STDAIR_LOG_ERROR ("Error: the log stream has already been initialised"); + // TODO: throw an exception? - // ////////////////////////////////////////////////////////////////////// - std::ostream& Logger::getLogStream() { - assert (_logStream != NULL); - return *_logStream; + } else { + _instance = new Logger (iLogParams); } + } - // ////////////////////////////////////////////////////////////////////// - void Logger::setLogParameters (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogStream) { - _level = iLogLevel; - _logStream = &ioLogStream; + // ////////////////////////////////////////////////////////////////////// + Logger& Logger::instance() { + if (_instance == NULL) { + throw NonInitialisedLogServiceException(); } - - // ////////////////////////////////////////////////////////////////////// - Logger& Logger::instance() { - if (_instance == NULL) { - _instance = new Logger (LOG::DEBUG, std::cout); - } - assert (_instance != NULL); - return *_instance; - } - + assert (_instance != NULL); + return *_instance; + } + + // ////////////////////////////////////////////////////////////////////// + void Logger::clean() { + delete _instance; _instance = NULL; + } + } Modified: trunk/stdair/stdair/service/Logger.hpp =================================================================== --- trunk/stdair/stdair/service/Logger.hpp 2010-01-20 21:33:53 UTC (rev 100) +++ trunk/stdair/stdair/service/Logger.hpp 2010-01-21 13:26:12 UTC (rev 101) @@ -9,8 +9,9 @@ #include <iostream> #include <sstream> #include <string> -// STDAIR +// StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> // /////////////// LOG MACROS ///////////////// #define STDAIR_LOG_CORE(iLevel, iToBeLogged) \ @@ -52,32 +53,26 @@ void log (const LOG::EN_LogLevel iLevel, const int iLineNumber, const std::string& iFileName, const T& iToBeLogged) { if (iLevel <= _level) { - assert (_logStream != NULL); - *_logStream << "[" << LOG::_logLevels[iLevel] << "]" << iFileName << ":" - << iLineNumber << ": " << iToBeLogged << std::endl; + _logStream << "[" << LOG::_logLevels[iLevel] << "]" << iFileName << ":" + << iLineNumber << ": " << iToBeLogged << std::endl; } } - /** Get the log level. */ - LOG::EN_LogLevel getLogLevel(); + /** Initialise the static Logger instance. */ + static void init (const stdair::BasLogParams&); - /** get the log stream. */ - std::ostream& getLogStream(); - - /** Set the logger parameters (level and stream). */ - void setLogParameters (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogStream); - - /** Return the static Logger instance.*/ + /** Return the static Logger instance. */ static Logger& instance(); private: /** Default constructors are private so that only the required constructor can be used. */ + Logger (const stdair::BasLogParams&); + /** Default constructor. It must not be used. */ Logger (); + /** Default copy constructor. It must not be used. */ Logger (const Logger&); - Logger (const LOG::EN_LogLevel iLevel, std::ostream& ioLogStream); /** Destructor. */ ~Logger (); @@ -85,14 +80,14 @@ static void clean(); private: + /** Instance object.*/ + static Logger* _instance; + /** Log level. */ LOG::EN_LogLevel _level; /** Stream dedicated to the logs. */ - std::ostream* _logStream; - - /** Instance object.*/ - static Logger* _instance; + std::ostream& _logStream; }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-20 21:34:59
|
Revision: 100 http://stdair.svn.sourceforge.net/stdair/?rev=100&view=rev Author: denis_arnaud Date: 2010-01-20 21:33:53 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Conf] Added the stdair/service/Makefile build. Modified Paths: -------------- trunk/stdair/configure.ac Modified: trunk/stdair/configure.ac =================================================================== --- trunk/stdair/configure.ac 2010-01-20 20:09:35 UTC (rev 99) +++ trunk/stdair/configure.ac 2010-01-20 21:33:53 UTC (rev 100) @@ -190,6 +190,7 @@ stdair/basic/Makefile stdair/bom/Makefile stdair/factory/Makefile + stdair/service/Makefile stdair/core/Makefile stdair/config/Makefile doc/Makefile 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:09:43
|
Revision: 99 http://stdair.svn.sourceforge.net/stdair/?rev=99&view=rev Author: denis_arnaud Date: 2010-01-20 20:09:35 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Dev] Implemented the Logger service. Modified Paths: -------------- trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/STDAIR_Types.hpp trunk/stdair/stdair/basic/sources.mk trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/factory/FacSupervisor.hpp Added Paths: ----------- trunk/stdair/stdair/basic/BasFileMgr.cpp trunk/stdair/stdair/basic/BasFileMgr.hpp trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Logger.hpp trunk/stdair/stdair/service/Makefile.am trunk/stdair/stdair/service/sources.mk Property Changed: ---------------- trunk/stdair/stdair/service/ Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/Makefile.am 2010-01-20 20:09:35 UTC (rev 99) @@ -1,3 +1,4 @@ +# stdair include $(top_srcdir)/Makefile.common include $(srcdir)/core/sources.mk @@ -5,7 +6,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic bom factory core config +SUBDIRS = basic bom factory config service core #EXTRA_DIST = config_msvc.h EXTRA_DIST = Modified: trunk/stdair/stdair/STDAIR_Types.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/STDAIR_Types.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -7,7 +7,7 @@ // STL #include <string> #include <vector> -#include <list> +#include <map> // Boost (Extended STL) #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/posix_time.hpp> @@ -15,7 +15,7 @@ namespace stdair { - // ///////// Exceptions /////////// + // ///////// Exceptions /////////// class RootException : public std::exception { }; @@ -46,6 +46,9 @@ VERBOSE, LAST_VALUE } EN_LogLevel; + + static const std::string _logLevels[LAST_VALUE] = + {"C", "E", "N", "W", "D", "V"}; } // //////// Type definitions ///////// Added: trunk/stdair/stdair/basic/BasFileMgr.cpp =================================================================== --- trunk/stdair/stdair/basic/BasFileMgr.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasFileMgr.cpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,29 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// Boost (STL Extension) +// Boost Filesystem (http://www.boost.org/doc/libs/1_41_0/libs/filesystem/doc/index.htm) +#include <boost/filesystem.hpp> +// StdAir +#include <stdair/basic/BasFileMgr.hpp> + +namespace boostfs = boost::filesystem; + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + bool BasFileMgr::doesExistAndIsReadable (const std::string& iFilepath) { + bool oFine = false; + + boostfs::path lPath (iFilepath); + + if (boostfs::exists (lPath) == true && boostfs::is_regular (lPath) == true) { + oFine = true; + } + + return true; + } + +} Added: trunk/stdair/stdair/basic/BasFileMgr.hpp =================================================================== --- trunk/stdair/stdair/basic/BasFileMgr.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasFileMgr.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,22 @@ +#ifndef __STDAIR_BAS_BASFILEMGR_HPP +#define __STDAIR_BAS_BASFILEMGR_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> + +namespace stdair { + + /** Helper class for operations on files and on the file-system. */ + struct BasFileMgr { + public: + + // //////////// Functional Support Methods //////////// + static bool doesExistAndIsReadable (const std::string& iFilepath); + + }; + +} +#endif // __STDAIR_BAS_BASFILEMGR_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-20 20:09:35 UTC (rev 99) @@ -6,7 +6,9 @@ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ - $(top_srcdir)/stdair/basic/BasChronometer.hpp + $(top_srcdir)/stdair/basic/BasChronometer.hpp \ + $(top_srcdir)/stdair/basic/BasFileMgr.hpp bas_cc_sources = \ $(top_srcdir)/stdair/basic/BasConst.cpp \ - $(top_srcdir)/stdair/basic/BasChronometer.cpp + $(top_srcdir)/stdair/basic/BasChronometer.cpp \ + $(top_srcdir)/stdair/basic/BasFileMgr.cpp Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/core/Makefile.am 2010-01-20 20:09:35 UTC (rev 99) @@ -1,3 +1,4 @@ +# core include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk @@ -15,6 +16,8 @@ libstdair_la_LIBADD = \ $(top_builddir)/stdair/basic/libbas.la \ $(top_builddir)/stdair/bom/libbom.la \ - $(top_builddir)/stdair/factory/libfac.la + $(top_builddir)/stdair/factory/libfac.la \ + $(top_builddir)/stdair/service/libsvc.la libstdair_la_LDFLAGS = \ - $(BOOST_DATE_TIME_LIB) -version-info $(GENERIC_LIBRARY_VERSION) + $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ + -version-info $(GENERIC_LIBRARY_VERSION) Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-20 20:09:35 UTC (rev 99) @@ -1,12 +1,14 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// C -#include <assert.h> -// STDAIR +// STL +#include <cassert> +#include <ostream> +// StdAir #include <stdair/factory/FacBomStructure.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/factory/FacSupervisor.hpp> +#include <stdair/service/Logger.hpp> namespace stdair { @@ -70,10 +72,16 @@ } // ////////////////////////////////////////////////////////////////////// + void FacSupervisor::cleanLoggerService() { + Logger::clean(); + } + + // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanFactory () { if (_instance != NULL) { - _instance->cleanBomStructureLayer(); - _instance->cleanBomContentLayer(); + _instance->cleanBomStructureLayer(); + _instance->cleanBomContentLayer(); + _instance->cleanLoggerService(); } delete _instance; _instance = NULL; } Modified: trunk/stdair/stdair/factory/FacSupervisor.hpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-20 17:07:06 UTC (rev 98) +++ trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -5,7 +5,10 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STL +#include <iosfwd> #include <vector> +// StdAir +#include <stdair/STDAIR_Types.hpp> namespace stdair { @@ -48,6 +51,9 @@ for the BomContent layer. */ void cleanBomContentLayer(); + /** Delete the Logger object. */ + void cleanLoggerService(); + /** Clean the static instance. <br> The singleton is deleted.*/ static void cleanFactory (); Property changes on: trunk/stdair/stdair/service ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile Makefile.in Added: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp (rev 0) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,64 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Stdair Logger +#include <stdair/factory/FacSupervisor.hpp> +#include <stdair/service/Logger.hpp> + +namespace stdair { + + 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; + } + + // ////////////////////////////////////////////////////////////////////// + void Logger::clean() { + delete _instance; _instance = 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); + return *_instance; + } + +} Added: trunk/stdair/stdair/service/Logger.hpp =================================================================== --- trunk/stdair/stdair/service/Logger.hpp (rev 0) +++ trunk/stdair/stdair/service/Logger.hpp 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,100 @@ +#ifndef __STDAIR_SVC_LOGGER_HPP +#define __STDAIR_SVC_LOGGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <string> +// STDAIR +#include <stdair/STDAIR_Types.hpp> + +// /////////////// LOG MACROS ///////////////// +#define STDAIR_LOG_CORE(iLevel, iToBeLogged) \ + { std::ostringstream ostr; ostr << iToBeLogged; \ + stdair::Logger::instance().log (iLevel, __LINE__, __FILE__, ostr.str()); } + +#define STDAIR_LOG_CRITICAL(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::CRITICAL, iToBeLogged) + +#define STDAIR_LOG_ERROR(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::ERROR, iToBeLogged) + +#define STDAIR_LOG_NOTIFICATION(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::NOTIFICATION, iToBeLogged) + +#define STDAIR_LOG_WARNING(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::WARNING, iToBeLogged) + +#define STDAIR_LOG_DEBUG(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::DEBUG, iToBeLogged) + +#define STDAIR_LOG_VERBOSE(iToBeLogged) \ + STDAIR_LOG_CORE (stdair::LOG::VERBOSE, iToBeLogged) +// /////////// (END OF) LOG MACROS ///////////// + + +namespace stdair { + + /** 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 << "[" << LOG::_logLevels[iLevel] << "]" << 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); + + /** Return the static 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 (); + + /** Delete the static Logger instance.*/ + static void clean(); + + private: + /** Log level. */ + LOG::EN_LogLevel _level; + + /** Stream dedicated to the logs. */ + std::ostream* _logStream; + + /** Instance object.*/ + static Logger* _instance; + }; + +} +#endif // __STDAIR_SVC_LOGGER_HPP + Added: trunk/stdair/stdair/service/Makefile.am =================================================================== --- trunk/stdair/stdair/service/Makefile.am (rev 0) +++ trunk/stdair/stdair/service/Makefile.am 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,11 @@ +## service sub-directory +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +noinst_LTLIBRARIES= libsvc.la + +libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) +libsvc_la_CXXFLAGS = + +#pkgincludedir = $(includedir)/@PACKAGE@/service +#pkginclude_HEADERS = $(svc_h_sources) Added: trunk/stdair/stdair/service/sources.mk =================================================================== --- trunk/stdair/stdair/service/sources.mk (rev 0) +++ trunk/stdair/stdair/service/sources.mk 2010-01-20 20:09:35 UTC (rev 99) @@ -0,0 +1,2 @@ +svc_h_sources = $(top_srcdir)/stdair/service/Logger.hpp +svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp 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:07:13
|
Revision: 98 http://stdair.svn.sourceforge.net/stdair/?rev=98&view=rev Author: denis_arnaud Date: 2010-01-20 17:07:06 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Test] Added a few revenue management sample (CSV) files. Added Paths: ----------- trunk/stdair/test/samples/rm01.csv trunk/stdair/test/samples/rm02.csv trunk/stdair/test/samples/rm03.csv trunk/stdair/test/samples/rm04.csv Added: trunk/stdair/test/samples/rm01.csv =================================================================== --- trunk/stdair/test/samples/rm01.csv (rev 0) +++ trunk/stdair/test/samples/rm01.csv 2010-01-20 17:07:06 UTC (rev 98) @@ -0,0 +1,4 @@ +price; mean; standard deviation; +100; 20; 9; +70; 45; 12; +42; 80; 16; Added: trunk/stdair/test/samples/rm02.csv =================================================================== --- trunk/stdair/test/samples/rm02.csv (rev 0) +++ trunk/stdair/test/samples/rm02.csv 2010-01-20 17:07:06 UTC (rev 98) @@ -0,0 +1,5 @@ +price; mean; standard deviation; +1050; 17.3; 5.8; +567; 45.1; 15.0; +534; 39.6; 13.2; +520; 34.0; 11.3; Added: trunk/stdair/test/samples/rm03.csv =================================================================== --- trunk/stdair/test/samples/rm03.csv (rev 0) +++ trunk/stdair/test/samples/rm03.csv 2010-01-20 17:07:06 UTC (rev 98) @@ -0,0 +1,5 @@ +price; mean; standard deviation; +1050; 17.3; 5.8; +950; 45.1; 15.0; +699; 39.6; 13.2; +520; 34.0; 11.3; Added: trunk/stdair/test/samples/rm04.csv =================================================================== --- trunk/stdair/test/samples/rm04.csv (rev 0) +++ trunk/stdair/test/samples/rm04.csv 2010-01-20 17:07:06 UTC (rev 98) @@ -0,0 +1,17 @@ +price; mean; standard deviation; +2000; 7.3; 2.8; +1850; 15.1; 5.0; +1800; 19.6; 5.2; +1623; 24.0; 6.3; +1511; 27.3; 5.8; +1430; 25.1; 7.0; +1290; 29.6; 7.2; +1100; 24.0; 6.3; +1050; 17.3; 5.8; +950; 25.1; 5.0; +799; 29.6; 10.2; +750; 24.0; 11.3; +700; 27.3; 5.8; +655; 25.1; 7.0; +599; 39.6; 13.2; +520; 44.0; 15.3; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-20 15:16:33
|
Revision: 97 http://stdair.svn.sourceforge.net/stdair/?rev=97&view=rev Author: denis_arnaud Date: 2010-01-20 15:16:23 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Dev] Added BasChronometer class. Modified Paths: -------------- trunk/stdair/stdair/basic/sources.mk Added Paths: ----------- trunk/stdair/stdair/basic/BasChronometer.cpp trunk/stdair/stdair/basic/BasChronometer.hpp Added: trunk/stdair/stdair/basic/BasChronometer.cpp =================================================================== --- trunk/stdair/stdair/basic/BasChronometer.cpp (rev 0) +++ trunk/stdair/stdair/basic/BasChronometer.cpp 2010-01-20 15:16:23 UTC (rev 97) @@ -0,0 +1,45 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// Stdair +#include <stdair/basic/BasChronometer.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + BasChronometer::BasChronometer () : _startTimeLaunched (false) { + } + + // ////////////////////////////////////////////////////////////////////// + void BasChronometer::start () { + // Get the time-stamp of now, and store it for later use + _startTime = boost::posix_time::microsec_clock::local_time(); + + // Update the boolean which states whether the chronometer + // is launched + _startTimeLaunched = true; + } + + // ////////////////////////////////////////////////////////////////////// + double BasChronometer::elapsed () const { + assert (_startTimeLaunched == true); + + // Get the time-stamp of now + const boost::posix_time::ptime lStopTime = + boost::posix_time::microsec_clock::local_time(); + + // Calculate the time elapsed since the last time-stamp + const boost::posix_time::time_duration lElapsedTime = + lStopTime - _startTime; + + // Derived the corresponding number of milliseconds + const double lElapsedTimeInMicroSeconds = + static_cast<const double> (lElapsedTime.total_microseconds()); + + // The elapsed time given in return is expressed in seconds + return (lElapsedTimeInMicroSeconds / 1e6); + } + +} Added: trunk/stdair/stdair/basic/BasChronometer.hpp =================================================================== --- trunk/stdair/stdair/basic/BasChronometer.hpp (rev 0) +++ trunk/stdair/stdair/basic/BasChronometer.hpp 2010-01-20 15:16:23 UTC (rev 97) @@ -0,0 +1,41 @@ +#ifndef __STDAIR_BAS_BASCHRONOMETER_HPP +#define __STDAIR_BAS_BASCHRONOMETER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost (STL Extension) +// Boost Date-Time (http://boost.org/doc/html/date_time/posix_time.html) +#include <boost/date_time/posix_time/posix_time.hpp> + +namespace stdair { + + /** Structure allowing measuring the time elapsed between two events. */ + struct BasChronometer { + /** Constructor. */ + BasChronometer(); + + /** Start the chronometer from the local time + <br>The elapsed time given is the one elapsed since the start + is launched. */ + void start (); + + /** Get the start time. */ + std::string getStart () const { + return boost::posix_time::to_simple_string (_startTime); + } + + /** Return the time elapsed since the structure has been instanciated. + <br>That elapsed time is expressed in seconds. */ + double elapsed () const; + + private: + /** Start time. */ + boost::posix_time::ptime _startTime; + + /** Boolean which states whether the chronometer is started or not.*/ + bool _startTimeLaunched; + }; + +} +#endif // __STDAIR_BAS_BASCHRONOMETER_HPP Modified: trunk/stdair/stdair/basic/sources.mk =================================================================== --- trunk/stdair/stdair/basic/sources.mk 2010-01-19 18:44:31 UTC (rev 96) +++ trunk/stdair/stdair/basic/sources.mk 2010-01-20 15:16:23 UTC (rev 97) @@ -5,6 +5,8 @@ $(top_srcdir)/stdair/basic/BasConst_BookingClass.hpp \ $(top_srcdir)/stdair/basic/BasConst_Yield.hpp \ $(top_srcdir)/stdair/basic/BasConst_Period_BOM.hpp \ - $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp + $(top_srcdir)/stdair/basic/BasConst_TravelSolution.hpp \ + $(top_srcdir)/stdair/basic/BasChronometer.hpp bas_cc_sources = \ - $(top_srcdir)/stdair/basic/BasConst.cpp + $(top_srcdir)/stdair/basic/BasConst.cpp \ + $(top_srcdir)/stdair/basic/BasChronometer.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-19 18:44:37
|
Revision: 96 http://stdair.svn.sourceforge.net/stdair/?rev=96&view=rev Author: denis_arnaud Date: 2010-01-19 18:44:31 +0000 (Tue, 19 Jan 2010) Log Message: ----------- [Conf] Improved the M4 (macro) files for OpenMPI. Modified Paths: -------------- trunk/stdair/config/openmpi.m4 Modified: trunk/stdair/config/openmpi.m4 =================================================================== --- trunk/stdair/config/openmpi.m4 2010-01-19 10:54:35 UTC (rev 95) +++ trunk/stdair/config/openmpi.m4 2010-01-19 18:44:31 UTC (rev 96) @@ -57,10 +57,10 @@ [ --with-openmpi=<path> root directory path of Openmpi installation], [OPENMPI_lib_check="$with_openmpi/lib${MODE}/openmpi $with_openmpi/lib/openmpi $with_openmpi/lib${MODE} $with_openmpi/lib" OPENMPI_inc_check="$with_openmpi/include $with_openmpi/include/openmpi $with_openmpi/include/openmpi/${MPIDIR}" - OPENMPI_bin_check="$with_openmpi/lib${MODE}/openmpi/bin $with_openmpi/lib/openmpi/bin $with_openmpi/lib${MODE}/bin $with_openmpi/lib/bin"], + OPENMPI_bin_check="$with_openmpi/bin $with_openmpi/lib${MODE}/openmpi/bin $with_openmpi/lib/openmpi/bin $with_openmpi/lib${MODE}/bin $with_openmpi/lib/bin"], [OPENMPI_lib_check="/usr/lib${MODE} /usr/lib /usr/lib${MODE}/openmpi /usr/lib/openmpi /usr/lib${MODE}/openmpi/lib /usr/lib/openmpi/lib /usr/lib${MODE}/openmpi/${MPIDIR} /usr/lib/openmpi/${MPIDIR} /usr/local/lib${MODE} /usr/local/lib /usr/local/lib${MODE}/openmpi /usr/local/lib/openmpi /usr/local/lib${MODE}/openmpi/${MPIDIR} /usr/local/lib/openmpi/${MPIDIR} /usr/local/openmpi/lib${MODE} /usr/local/openmpi/lib /usr/local/openmpi/${MPIDIR}/lib${MODE} /usr/local/openmpi/${MPIDIR}/lib /opt/openmpi/lib /opt/openmpi/${MPIDIR}/lib /opt/openmpi/lib/openmpi" OPENMPI_inc_check="/usr/include /usr/include/openmpi /usr/include/openmpi-${ARCH} /usr/include/openmpi-${GENARCH} /usr/include/openmpi/${MPIDIR} /usr/local/include /usr/local/include/openmpi /usr/local/include/openmpi/${MPIDIR} /opt/openmpi/include /opt/openmpi/${MPIDIR}/include" - OPENMPI_bin_check="/usr/lib${MODE}/bin /usr/lib/bin /usr/lib${MODE}/openmpi/bin /usr/lib/openmpi/bin /usr/lib${MODE}/openmpi/lib/bin /usr/lib/openmpi/lib/bin /usr/lib${MODE}/openmpi/${MPIDIR}/bin /usr/lib/openmpi/${MPIDIR}/bin /usr/local/lib${MODE}/bin /usr/local/lib/bin /usr/local/lib${MODE}/openmpi/bin /usr/local/lib/openmpi/bin /usr/local/lib${MODE}/openmpi/${MPIDIR}/bin /usr/local/lib/openmpi/${MPIDIR}/bin /usr/local/openmpi/lib${MODE}/bin /usr/local/openmpi/lib/bin /usr/local/openmpi/${MPIDIR}/lib${MODE}/bin /usr/local/openmpi/${MPIDIR}/lib/bin /opt/openmpi/lib/bin /opt/openmpi/${MPIDIR}/lib/bin /opt/openmpi/lib/openmpi/bin"]) + OPENMPI_bin_check="/usr/bin /usr/lib${MODE}/bin /usr/lib/bin /usr/lib${MODE}/openmpi/bin /usr/lib/openmpi/bin /usr/lib${MODE}/openmpi/lib/bin /usr/lib/openmpi/lib/bin /usr/lib${MODE}/openmpi/${MPIDIR}/bin /usr/lib/openmpi/${MPIDIR}/bin /usr/local/bin /usr/local/lib${MODE}/bin /usr/local/lib/bin /usr/local/lib${MODE}/openmpi/bin /usr/local/lib/openmpi/bin /usr/local/lib${MODE}/openmpi/${MPIDIR}/bin /usr/local/lib/openmpi/${MPIDIR}/bin /usr/local/openmpi/lib${MODE}/bin /usr/local/openmpi/lib/bin /usr/local/openmpi/${MPIDIR}/lib${MODE}/bin /usr/local/openmpi/${MPIDIR}/lib/bin /opt/bin /opt/openmpi/bin /opt/openmpi/lib/bin /opt/openmpi/${MPIDIR}/lib/bin /opt/openmpi/lib/openmpi/bin"]) AC_ARG_WITH(openmpi-lib, [ --with-openmpi-lib=<path> directory path of Openmpi library installation], @@ -132,7 +132,7 @@ # Look for OpenMPI configuration # # OpenMPI configuration binary - OPENMPI_VERBIN=mpirun + OPENMPI_VERBIN1=ompi_info AC_MSG_CHECKING([for OpenMPI configuration]) OPENMPI_verdir= @@ -150,14 +150,14 @@ if test -z "$OPENMPI_verdir" then - AC_MSG_ERROR([Did not find $OPENMPI_VERBIN tool in '$OPENMPI_bin_check']) + AC_MSG_RESULT([Did not find $OPENMPI_VERBIN tool, but will try to determine the version with other tricks]) + else + case "$OPENMPI_verdir" in + /* ) ;; + * ) AC_MSG_ERROR([The Openmpi tool directory ($OPENMPI_verdir) must be an absolute path.]) ;; + esac fi - case "$OPENMPI_verdir" in - /* ) ;; - * ) AC_MSG_ERROR([The Openmpi tool directory ($OPENMPI_verdir) must be an absolute path.]) ;; - esac - AC_MSG_RESULT([$OPENMPI_verdir]) # @@ -167,7 +167,10 @@ AC_MSG_CHECKING([for OpenMPI version >= $min_openmpi_version]) # Derive the full version, e.g., 1.3.3 - OPENMPI_VERSION=`${OPENMPI_verdir}/${OPENMPI_VERBIN} --version 2>&1 | grep mpirun | cut -d\) -f2` + if test ! -z "$OPENMPI_verdir" + then + OPENMPI_VERSION=`${OPENMPI_verdir}/${OPENMPI_VERBIN} | grep "Open MPI:" | cut -d: -f2 | cut -d\ -f2` + fi if test -z "${OPENMPI_VERSION}" ; then OPENMPI_VERSION=${OPENMPI_DEF_VERSION} fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |