From: <den...@us...> - 2009-12-26 01:40:52
|
Revision: 21 http://dsim.svn.sourceforge.net/dsim/?rev=21&view=rev Author: denis_arnaud Date: 2009-12-26 01:40:41 +0000 (Sat, 26 Dec 2009) Log Message: ----------- [Test] Created a dedicated test suite for Boost tests. Modified Paths: -------------- trunk/dsim/Makefile.am trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Added Paths: ----------- trunk/dsim/test/boost/ trunk/dsim/test/boost/Makefile.am trunk/dsim/test/boost/accumulators/ trunk/dsim/test/boost/accumulators/Makefile.am trunk/dsim/test/boost/accumulators/accu.cpp trunk/dsim/test/boost/asio/ trunk/dsim/test/boost/asio/Makefile.am trunk/dsim/test/boost/asio/daytime1.cpp trunk/dsim/test/boost/asio/daytime2.cpp trunk/dsim/test/boost/asio/daytime3.cpp trunk/dsim/test/boost/asio/daytime4.cpp trunk/dsim/test/boost/asio/daytime5.cpp trunk/dsim/test/boost/asio/daytime6.cpp trunk/dsim/test/boost/asio/daytime7.cpp trunk/dsim/test/boost/asio/httpd/ trunk/dsim/test/boost/asio/httpd/Makefile.am trunk/dsim/test/boost/asio/httpd/connection.cpp trunk/dsim/test/boost/asio/httpd/connection.hpp trunk/dsim/test/boost/asio/httpd/header.hpp trunk/dsim/test/boost/asio/httpd/mime_types.cpp trunk/dsim/test/boost/asio/httpd/mime_types.hpp trunk/dsim/test/boost/asio/httpd/posix_main.cpp trunk/dsim/test/boost/asio/httpd/reply.cpp trunk/dsim/test/boost/asio/httpd/reply.hpp trunk/dsim/test/boost/asio/httpd/request.hpp trunk/dsim/test/boost/asio/httpd/request_handler.cpp trunk/dsim/test/boost/asio/httpd/request_handler.hpp trunk/dsim/test/boost/asio/httpd/request_parser.cpp trunk/dsim/test/boost/asio/httpd/request_parser.hpp trunk/dsim/test/boost/asio/httpd/server.cpp trunk/dsim/test/boost/asio/httpd/server.hpp trunk/dsim/test/boost/asio/httpd/win_main.cpp trunk/dsim/test/boost/asio/logd/ trunk/dsim/test/boost/asio/logd/Makefile.am trunk/dsim/test/boost/asio/logd/log/ trunk/dsim/test/boost/asio/logd/logd.cpp trunk/dsim/test/boost/asio/logger/ trunk/dsim/test/boost/asio/logger/Makefile.am trunk/dsim/test/boost/asio/logger/basic_logger.hpp trunk/dsim/test/boost/asio/logger/daytime_client.cpp trunk/dsim/test/boost/asio/logger/logger.hpp trunk/dsim/test/boost/asio/logger/logger_service.cpp trunk/dsim/test/boost/asio/logger/logger_service.hpp trunk/dsim/test/boost/asio/logger/stream_socket_service.hpp trunk/dsim/test/boost/asio/timer1.cpp trunk/dsim/test/boost/asio/timer2.cpp trunk/dsim/test/boost/asio/timer3.cpp trunk/dsim/test/boost/asio/timer4.cpp trunk/dsim/test/boost/asio/timer5.cpp trunk/dsim/test/boost/mpi/ trunk/dsim/test/boost/mpi/Makefile.am trunk/dsim/test/boost/mpi/mpi.cpp trunk/dsim/test/boost/mpi/pympi.py trunk/dsim/test/boost/mpl/ trunk/dsim/test/boost/mpl/Makefile.am trunk/dsim/test/boost/mpl/mpl.cpp trunk/dsim/test/boost/mpl/test_mpl.sh trunk/dsim/test/boost/serialization/ trunk/dsim/test/boost/serialization/Makefile.am trunk/dsim/test/boost/serialization/serial1.cpp trunk/dsim/test/boost/signals/ trunk/dsim/test/boost/signals/Makefile.am trunk/dsim/test/boost/signals/multislots.cpp trunk/dsim/test/boost/spirit/ trunk/dsim/test/boost/spirit/Makefile.am trunk/dsim/test/boost/spirit/full_calculator.cpp trunk/dsim/test/boost/spirit/levenshtein.cpp trunk/dsim/test/boost/spirit/levenshtein_new.cpp trunk/dsim/test/boost/spirit/parameter_parser.cpp trunk/dsim/test/boost/spirit/schedule_parser.cpp trunk/dsim/test/boost/spirit/search_string_parser.cpp trunk/dsim/test/boost/spirit/test_full_calculator.sh trunk/dsim/test/boost/spirit/test_parameter_parser.sh trunk/dsim/test/boost/spirit/test_schedule_parser.sh trunk/dsim/test/boost/spirit/world_schedule.csv Modified: trunk/dsim/Makefile.am =================================================================== --- trunk/dsim/Makefile.am 2009-12-24 16:05:27 UTC (rev 20) +++ trunk/dsim/Makefile.am 2009-12-26 01:40:41 UTC (rev 21) @@ -25,7 +25,7 @@ EXTRA_DIST = # Build in these directories: -SUBDIRS = stdair trademgen airsched airinv simcrs rmol $(TEST_DIR) +SUBDIRS = stdair trademgen airsched airinv simcrs rmol dsim $(TEST_DIR) # Configuration helpers Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-24 16:05:27 UTC (rev 20) +++ trunk/dsim/configure.ac 2009-12-26 01:40:41 UTC (rev 21) @@ -464,6 +464,17 @@ dsim/core/Makefile dsim/batches/Makefile test/Makefile + test/boost/Makefile + test/boost/accumulators/Makefile + test/boost/asio/Makefile + test/boost/asio/httpd/Makefile + test/boost/asio/logd/Makefile + test/boost/asio/logger/Makefile + test/boost/mpi/Makefile + test/boost/mpl/Makefile + test/boost/spirit/Makefile + test/boost/serialization/Makefile + test/boost/signals/Makefile ) AC_OUTPUT Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-24 16:05:27 UTC (rev 20) +++ trunk/dsim/test/Makefile.am 2009-12-26 01:40:41 UTC (rev 21) @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = +SUBDIRS = boost ## check_PROGRAMS = simulate Property changes on: trunk/dsim/test/boost ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile Added: trunk/dsim/test/boost/Makefile.am =================================================================== --- trunk/dsim/test/boost/Makefile.am (rev 0) +++ trunk/dsim/test/boost/Makefile.am 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,9 @@ +## test/boost sub-directory +include $(top_srcdir)/Makefile.common + +## +SUBDIRS = accumulators asio mpi mpl serialization signals spirit + +MAINTAINERCLEANFILES = Makefile.in + +EXTRA_DIST = Property changes on: trunk/dsim/test/boost/accumulators ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile accu Added: trunk/dsim/test/boost/accumulators/Makefile.am =================================================================== --- trunk/dsim/test/boost/accumulators/Makefile.am (rev 0) +++ trunk/dsim/test/boost/accumulators/Makefile.am 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,21 @@ +## test/architecture sub-directory +include $(top_srcdir)/Makefile.common + +MAINTAINERCLEANFILES = Makefile.in + +## +SUBDIRS = + +EXTRA_DIST = +## + +check_PROGRAMS = accu +#TESTS = $(check_PROGRAMS) +TESTS = +XFAIL_TESTS = #IndexBuildingTestSuite + +accu_SOURCES = accu.cpp +accu_CXXFLAGS= $(BOOST_CFLAGS) +accu_LDFLAGS = $(BOOST_LIBS) +accu_LDADD = + Added: trunk/dsim/test/boost/accumulators/accu.cpp =================================================================== --- trunk/dsim/test/boost/accumulators/accu.cpp (rev 0) +++ trunk/dsim/test/boost/accumulators/accu.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,171 @@ +// STL +#include <iostream> +#include <algorithm> +// Boost +#include <boost/ref.hpp> +#include <boost/bind.hpp> +#include <boost/array.hpp> +#include <boost/foreach.hpp> +// Boost Accumulators +#include <boost/accumulators/accumulators.hpp> +#include <boost/accumulators/statistics.hpp> + +// using namespace boost; +namespace boostacc = boost::accumulators; + +// Helper that uses BOOST_FOREACH to display a range of doubles +template<typename Range> +void output_range(Range const &rng) { + bool first = true; + BOOST_FOREACH(double d, rng) { + if(!first) std::cout << ", "; + std::cout << d; + first = false; + } + std::cout << '\n'; +} + +/////////////////////////////////////////////////////////////////////////////// +// example1 +// +// Calculate some useful stats using accumulator_set<> and std::for_each() +// +void example1() { + boostacc::accumulator_set<double, + boostacc::stats<boostacc::tag::min, + boostacc::tag::mean(boostacc::immediate), + boostacc::tag::sum, + boostacc::tag::moment<2> > > acc; + + boost::array<double, 4> data = {0., 1., -1., 3.14159}; + + // std::for_each pushes each sample into the accumulator one at a + // time, and returns a copy of the accumulator. + acc = std::for_each(data.begin(), data.end(), acc); + + // The following would be equivalent, and could be more efficient + // because it doesn't pass and return the entire accumulator set + // by value. + //std::for_each(data.begin(), data.end(), bind<void>(ref(acc), _1)); + + std::cout << " min(acc) = " << (boostacc::min)(acc) << std::endl; + std::cout << " mean(acc) = " << boostacc::mean(acc) << std::endl; + + // since mean depends on count and sum, we can get their results, too. + std::cout << " count(acc) = " << boostacc::count(acc) << std::endl; + std::cout << " sum(acc) = " << boostacc::sum(acc) << std::endl; + std::cout << " moment<2>(acc) = " << boostacc::moment<2>(acc) << std::endl; +} + +/////////////////////////////////////////////////////////////////////////////// +// example2 +// +// Calculate some tail statistics. This demonstrates how to specify +// constructor and accumulator parameters. Note that the tail statistics +// return multiple values, which are returned in an iterator_range. +// +// It pushes data in and displays the intermediate results to demonstrate +// how the tail statistics are updated. +void example2() { + // An accumulator which tracks the right tail (largest N items) and + // some data that are covariate with them. N == 4. + boostacc::accumulator_set<double, + boostacc::stats< + boostacc::tag::tail_variate<double, + boostacc::tag::covariate1, boostacc::right> > > acc (boostacc::tag::tail<boostacc::right>::cache_size = 4); + + acc(2.1, boostacc::covariate1 = .21); + acc(1.1, boostacc::covariate1 = .11); + acc(2.1, boostacc::covariate1 = .21); + acc(1.1, boostacc::covariate1 = .11); + + std::cout << " tail = "; output_range(boostacc::tail(acc)); + std::cout << " tail_variate = "; output_range(boostacc::tail_variate(acc)); + std::cout << std::endl; + + acc(21.1, boostacc::covariate1 = 2.11); + acc(11.1, boostacc::covariate1 = 1.11); + acc(21.1, boostacc::covariate1 = 2.11); + acc(11.1, boostacc::covariate1 = 1.11); + + std::cout << " tail = "; output_range(boostacc::tail(acc)); + std::cout << " tail_variate = "; output_range(boostacc::tail_variate(acc)); + std::cout << std::endl; + + acc(42.1, boostacc::covariate1 = 4.21); + acc(41.1, boostacc::covariate1 = 4.11); + acc(42.1, boostacc::covariate1 = 4.21); + acc(41.1, boostacc::covariate1 = 4.11); + + std::cout << " tail = "; output_range(boostacc::tail(acc)); + std::cout << " tail_variate = "; output_range(boostacc::tail_variate(acc)); + std::cout << std::endl; + + acc(32.1, boostacc::covariate1 = 3.21); + acc(31.1, boostacc::covariate1 = 3.11); + acc(32.1, boostacc::covariate1 = 3.21); + acc(31.1, boostacc::covariate1 = 3.11); + + std::cout << " tail = "; output_range(boostacc::tail(acc)); + std::cout << " tail_variate = "; output_range(boostacc::tail_variate(acc)); +} + +/////////////////////////////////////////////////////////////////////////////// +// example3 +// +// Demonstrate how to calculate weighted statistics. This example demonstrates +// both a simple weighted statistical calculation, and a more complicated +// calculation where the weight statistics are calculated and stored in an +// external weight accumulataor. +void example3() { + // weight == double + double w = 1.; + + // Simple weighted calculation + { + // stats that depend on the weight are made external + boostacc::accumulator_set<double, + boostacc::stats<boostacc::tag::mean>, double> acc; + + acc(0., boostacc::weight = w); + acc(1., boostacc::weight = w); + acc(-1., boostacc::weight = w); + acc(3.14159, boostacc::weight = w); + + std::cout << " mean(acc) = " << boostacc::mean(acc) << std::endl; + } + + // Weighted calculation with an external weight accumulator + { + // stats that depend on the weight are made external + boostacc::accumulator_set<double, boostacc::stats<boostacc::tag::mean>, + boostacc::external<double> > acc; + + // Here's an external weight accumulator + boostacc::accumulator_set<void, boostacc::stats<boostacc::tag::sum_of_weights>, double> weight_acc; + + weight_acc(boostacc::weight = w); acc(0., boostacc::weight = w); + weight_acc(boostacc::weight = w); acc(1., boostacc::weight = w); + weight_acc(boostacc::weight = w); acc(-1., boostacc::weight = w); + weight_acc(boostacc::weight = w); acc(3.14159, boostacc::weight = w); + + std::cout << " mean(acc) = " + << boostacc::mean(acc, boostacc::weights = weight_acc) + << std::endl; + } +} + +/////////////////////////////////////////////////////////////////////////////// +// main +int main (int argc, char* argv[]) { + std::cout << "Example 1:" << std::endl; + example1(); + + std::cout << std::endl << "Example 2:" << std::endl; + example2(); + + std::cout << std::endl << "Example 3:" << std::endl; + example3(); + + return 0; +} Property changes on: trunk/dsim/test/boost/asio ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile daytime1 daytime2 daytime3 daytime4 daytime5 daytime6 daytime7 timer1 timer2 timer3 timer4 timer5 Added: trunk/dsim/test/boost/asio/Makefile.am =================================================================== --- trunk/dsim/test/boost/asio/Makefile.am (rev 0) +++ trunk/dsim/test/boost/asio/Makefile.am 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,72 @@ +## test/asio sub-directory +include $(top_srcdir)/Makefile.common + +## +SUBDIRS = logger logd httpd + +MAINTAINERCLEANFILES = Makefile.in + +check_PROGRAMS = timer1 timer2 timer3 timer4 timer5 \ + daytime1 daytime2 daytime3 daytime4 daytime5 daytime6 daytime7 + +timer1_SOURCES = timer1.cpp +timer1_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +timer1_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +timer1_LDADD = + +timer2_SOURCES = timer2.cpp +timer2_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +timer2_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +timer2_LDADD = + +timer3_SOURCES = timer3.cpp +timer3_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +timer3_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +timer3_LDADD = + +timer4_SOURCES = timer4.cpp +timer4_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +timer4_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +timer4_LDADD = + +timer5_SOURCES = timer5.cpp +timer5_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +timer5_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +timer5_LDADD = + +daytime1_SOURCES = daytime1.cpp +daytime1_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +daytime1_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +daytime1_LDADD = + +daytime2_SOURCES = daytime2.cpp +daytime2_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +daytime2_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +daytime2_LDADD = + +daytime3_SOURCES = daytime3.cpp +daytime3_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +daytime3_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +daytime3_LDADD = + +daytime4_SOURCES = daytime4.cpp +daytime4_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +daytime4_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +daytime4_LDADD = + +daytime5_SOURCES = daytime5.cpp +daytime5_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +daytime5_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +daytime5_LDADD = + +daytime6_SOURCES = daytime6.cpp +daytime6_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +daytime6_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +daytime6_LDADD = + +daytime7_SOURCES = daytime7.cpp +daytime7_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +daytime7_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +daytime7_LDADD = + +EXTRA_DIST = Added: trunk/dsim/test/boost/asio/daytime1.cpp =================================================================== --- trunk/dsim/test/boost/asio/daytime1.cpp (rev 0) +++ trunk/dsim/test/boost/asio/daytime1.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,82 @@ +// Boost.ASIO Tutorial - Daytime1: +// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime1.html +// STL +#include <iostream> +#include <string> +// Boost.ASIO +#include <boost/asio.hpp> +#include <boost/array.hpp> + +// /////////// M A I N //////////////// +int main (int argc, char* argv[]) { + + // Host name + std::string lHostname = "localhost"; + + // Service name (as specified within /etc/services) + // The "aria" service corresponds to the port 2624 + const std::string lServiceName = "aria"; + + try { + + if (argc >= 2) { + lHostname = argv[1]; + } + + boost::asio::io_service lIOService; + + boost::asio::ip::tcp::resolver lResolver (lIOService); + + boost::asio::ip::tcp::resolver::query lQuery (lHostname, lServiceName); + + boost::asio::ip::tcp::resolver::iterator itEndPoint = + lResolver.resolve (lQuery); + boost::asio::ip::tcp::resolver::iterator lEnd; + + boost::asio::ip::tcp::socket lSocket (lIOService); + boost::system::error_code lError = boost::asio::error::host_not_found; + + while (lError && itEndPoint != lEnd) { + const boost::asio::ip::tcp::endpoint lEndPoint = *itEndPoint; + + // DEBUG + std::cout << "Testing end point: " << std::endl; + + lSocket.close(); + lSocket.connect (lEndPoint, lError); + ++itEndPoint; + } + + if (lError) { + throw boost::system::system_error (lError); + } + assert (!lError); + + // DEBUG + const boost::asio::ip::tcp::endpoint lValidEndPoint; + std::cout << "Valid end point: " << lValidEndPoint << std::endl; + + for (;;) { + boost::array<char, 128> lBuffer; + boost::system::error_code lError; + + size_t lLength = lSocket.read_some (boost::asio::buffer (lBuffer), lError); + + if (lError == boost::asio::error::eof) { + // Connection closed cleanly by peer. + break; + + } else if (lError) { + // Some other error. + throw boost::system::system_error (lError); + } + + std::cout.write (lBuffer.data(), lLength); + } + + } catch (std::exception& lException) { + std::cerr << lException.what() << std::endl; + } + + return 0; +} Added: trunk/dsim/test/boost/asio/daytime2.cpp =================================================================== --- trunk/dsim/test/boost/asio/daytime2.cpp (rev 0) +++ trunk/dsim/test/boost/asio/daytime2.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,46 @@ +// Boost.ASIO Tutorial - Daytime2: +// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime2.html +// STL +#include <iostream> +#include <string> +#include <ctime> +// Boost.ASIO +#include <iostream> +#include <boost/asio.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +// ////////////////////////////////////////////////////////// +std::string make_daytime_string() { + const std::time_t now = std::time(0); + return std::ctime (&now); +} + +// //////////////////// M A I N ///////////////////////////// +int main (int argc, char* argv[]) { + + try { + + boost::asio::io_service lIOService; + + // Create a listener for IP/TCP v4, listening on port 2624 (corresponding + // to the "aria" service, as specified within the /etc/services file) + boost::asio::ip::tcp::acceptor lAcceptor (lIOService, + boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), 2624)); + + for (;;) { + boost::asio::ip::tcp::socket lSocket (lIOService); + lAcceptor.accept (lSocket); + const std::string lMessage = make_daytime_string(); + + boost::system::error_code lIgnoredError; + boost::asio::write (lSocket, boost::asio::buffer (lMessage), + boost::asio::transfer_all(), lIgnoredError); + } + + } catch (std::exception& lException) { + std::cerr << lException.what() << std::endl; + } + + return 0; +} + Added: trunk/dsim/test/boost/asio/daytime3.cpp =================================================================== --- trunk/dsim/test/boost/asio/daytime3.cpp (rev 0) +++ trunk/dsim/test/boost/asio/daytime3.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,145 @@ +// Boost.ASIO Tutorial - Daytime3: +// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime3.html +// STL +#include <cassert> +#include <ctime> +#include <iostream> +#include <string> +// Boost.ASIO +#include <iostream> +#include <boost/asio.hpp> +#include <boost/bind.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +// ////////////////////////////////////////////////////////// +std::string make_daytime_string() { + const std::time_t now = std::time(0); + return std::ctime (&now); +} + +// ////////////////////////////////////////////////////////// +/** Class handling TCP connections for a given server. */ +class TCPConnection : + public boost::enable_shared_from_this<TCPConnection> { +public: + /** Pointer on a TCP connection. */ + typedef boost::shared_ptr<TCPConnection> Pointer_T; + + /** Create a TCP connection, from a given Boost.ASIO service. */ + static Pointer_T create (boost::asio::io_service& ioIOService) { + TCPConnection* oConnectionPtr = new TCPConnection (ioIOService); + assert (oConnectionPtr != NULL); + return Pointer_T (oConnectionPtr); + } + + /** Get the underlying TCP socket. */ + boost::asio::ip::tcp::socket& socket() { + return _socket; + } + + /** Process the incoming client request, by giving it back the time of day. */ + void start() { + + _message = make_daytime_string(); + + boost::system::error_code lIgnoredError; + boost::asio::async_write (_socket, boost::asio::buffer (_message), + boost::bind (&TCPConnection::handleWrite, + shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); + } + + +private: + // //////////// Constructors & Destructors ///////////// + /** Constructor. */ + TCPConnection (boost::asio::io_service& ioIOService) + : _socket (ioIOService) { + } + + void handleWrite (const boost::system::error_code& iErrorCode, + const size_t iTransferredBytes) { + } + + +private: + // ///////////////// Technical Methods /////////////////// + + +private: + // /////////// Attributes ///////////// + /** Time of day. */ + std::string _message; + + /** TCP/IP socket. */ + boost::asio::ip::tcp::socket _socket; +}; + + +/** Class starting a TCP server, and handling incoming requests. */ +class TCPServer { +public: + // //////////// Constructors & Destructors ///////////// + /** Constructor. + <br>Create a listener for IP/TCP v4, listening on port 2624 (corresponding + to the "aria" service, as specified within the /etc/services file) */ + TCPServer (boost::asio::io_service& ioIOService) + : _acceptor (ioIOService, + boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v4(), + 2624)) { + startAccept(); + } + + +private: + // ///////////////// Technical Methods /////////////////// + /** Accept (socket) connection from any client. */ + void startAccept() { + TCPConnection::Pointer_T lConnection = + TCPConnection::create (_acceptor.io_service()); + + boost::asio::ip::tcp::socket& lSocket = lConnection->socket(); + _acceptor.async_accept (lSocket, + boost::bind (&TCPServer::handleAccept, this, + lConnection, + boost::asio::placeholders::error)); + } + + /** Process the (socket) connection from any client. */ + void handleAccept (TCPConnection::Pointer_T ioConnection, + const boost::system::error_code& iError) { + + if (!iError) { + ioConnection->start(); + startAccept(); + } + } + + +private: + // /////////// Attributes ///////////// + /** Connection acceptor. */ + boost::asio::ip::tcp::acceptor _acceptor; +}; + + +// //////////////////// M A I N ///////////////////////////// +int main (int argc, char* argv[]) { + + try { + + boost::asio::io_service lIOService; + TCPServer lServer (lIOService); + + lIOService.run(); + + } catch (std::exception& lException) { + std::cerr << lException.what() << std::endl; + } + + return 0; +} + Added: trunk/dsim/test/boost/asio/daytime4.cpp =================================================================== --- trunk/dsim/test/boost/asio/daytime4.cpp (rev 0) +++ trunk/dsim/test/boost/asio/daytime4.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,17 @@ +// Boost.ASIO Tutorial - Daytime4: +// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime4.html +// STL +#include <iostream> +// Boost.ASIO +#include <boost/asio.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +// /////////// M A I N //////////////// +int main (int argc, char* argv[]) { + + boost::asio::io_service lIOService; + + std::cout << "We have waited 1 second" << std::endl; + + return 0; +} Added: trunk/dsim/test/boost/asio/daytime5.cpp =================================================================== --- trunk/dsim/test/boost/asio/daytime5.cpp (rev 0) +++ trunk/dsim/test/boost/asio/daytime5.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,17 @@ +// Boost.ASIO Tutorial - Daytime5: +// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime5.html +// STL +#include <iostream> +// Boost.ASIO +#include <boost/asio.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +// /////////// M A I N //////////////// +int main (int argc, char* argv[]) { + + boost::asio::io_service lIOService; + + std::cout << "We have waited 1 second" << std::endl; + + return 0; +} Added: trunk/dsim/test/boost/asio/daytime6.cpp =================================================================== --- trunk/dsim/test/boost/asio/daytime6.cpp (rev 0) +++ trunk/dsim/test/boost/asio/daytime6.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,17 @@ +// Boost.ASIO Tutorial - Daytime6: +// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime6.html +// STL +#include <iostream> +// Boost.ASIO +#include <boost/asio.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +// /////////// M A I N //////////////// +int main (int argc, char* argv[]) { + + boost::asio::io_service lIOService; + + std::cout << "We have waited 1 second" << std::endl; + + return 0; +} Added: trunk/dsim/test/boost/asio/daytime7.cpp =================================================================== --- trunk/dsim/test/boost/asio/daytime7.cpp (rev 0) +++ trunk/dsim/test/boost/asio/daytime7.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,17 @@ +// Boost.ASIO Tutorial - Daytime7: +// http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio/tutorial/tutdaytime7.html +// STL +#include <iostream> +// Boost.ASIO +#include <boost/asio.hpp> +#include <boost/date_time/posix_time/posix_time.hpp> + +// /////////// M A I N //////////////// +int main (int argc, char* argv[]) { + + boost::asio::io_service lIOService; + + std::cout << "We have waited 1 second" << std::endl; + + return 0; +} Property changes on: trunk/dsim/test/boost/asio/httpd ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile httpd_server Added: trunk/dsim/test/boost/asio/httpd/Makefile.am =================================================================== --- trunk/dsim/test/boost/asio/httpd/Makefile.am (rev 0) +++ trunk/dsim/test/boost/asio/httpd/Makefile.am 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,17 @@ +## test/asio/httpd sub-directory +include $(top_srcdir)/Makefile.common + +MAINTAINERCLEANFILES = Makefile.in + +check_PROGRAMS = httpd_server + +httpd_server_SOURCES = \ + header.hpp connection.hpp mime_types.hpp reply.hpp request.hpp \ + request_handler.hpp request_parser.hpp server.hpp \ + mime_types.cpp connection.cpp posix_main.cpp reply.cpp request_handler.cpp \ + request_parser.cpp server.cpp win_main.cpp +httpd_server_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +httpd_server_LDFLAGS = $(BOOST_LIBS) $(BOOST_DATE_TIME_LIB) $(BOOST_ASIO_LIB) +httpd_server_LDADD = + +EXTRA_DIST = Added: trunk/dsim/test/boost/asio/httpd/connection.cpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/connection.cpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/connection.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,87 @@ +// +// connection.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "connection.hpp" +#include <vector> +#include <boost/bind.hpp> +#include "request_handler.hpp" + +namespace http { + + namespace server3 { + + connection::connection(boost::asio::io_service& io_service, + request_handler& handler) + : strand_(io_service), + socket_(io_service), + request_handler_(handler) { + } + + boost::asio::ip::tcp::socket& connection::socket() { + return socket_; + } + + void connection::start() { + socket_.async_read_some(boost::asio::buffer(buffer_), + strand_.wrap( + boost::bind(&connection::handle_read, shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred))); + } + + void connection::handle_read(const boost::system::error_code& e, + std::size_t bytes_transferred) { + if (!e) { + boost::tribool result; + boost::tie(result, boost::tuples::ignore) = request_parser_.parse( + request_, buffer_.data(), buffer_.data() + bytes_transferred); + + if (result) { + request_handler_.handle_request(request_, reply_); + boost::asio::async_write(socket_, reply_.to_buffers(), + strand_.wrap( + boost::bind(&connection::handle_write, shared_from_this(), + boost::asio::placeholders::error))); + } else if (!result) { + reply_ = reply::stock_reply(reply::bad_request); + boost::asio::async_write(socket_, reply_.to_buffers(), + strand_.wrap( + boost::bind(&connection::handle_write, shared_from_this(), + boost::asio::placeholders::error))); + } else { + socket_.async_read_some(boost::asio::buffer(buffer_), + strand_.wrap( + boost::bind(&connection::handle_read, shared_from_this(), + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred))); + } + } + + // If an error occurs then no new asynchronous operations are started. This + // means that all shared_ptr references to the connection object will + // disappear and the object will be destroyed automatically after this + // handler returns. The connection class's destructor closes the socket. + } + + void connection::handle_write(const boost::system::error_code& e) { + if (!e) { + // Initiate graceful connection closure. + boost::system::error_code ignored_ec; + socket_.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec); + } + + // No new asynchronous operations are started. This means that all shared_ptr + // references to the connection object will disappear and the object will be + // destroyed automatically after this handler returns. The connection class's + // destructor closes the socket. + } + + } // namespace server3 +} // namespace http Added: trunk/dsim/test/boost/asio/httpd/connection.hpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/connection.hpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/connection.hpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,77 @@ +// +// connection.hpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_SERVER3_CONNECTION_HPP +#define HTTP_SERVER3_CONNECTION_HPP + +#include <boost/asio.hpp> +#include <boost/array.hpp> +#include <boost/noncopyable.hpp> +#include <boost/shared_ptr.hpp> +#include <boost/enable_shared_from_this.hpp> +#include "reply.hpp" +#include "request.hpp" +#include "request_handler.hpp" +#include "request_parser.hpp" + +namespace http { + + namespace server3 { + + /// Represents a single connection from a client. + class connection + : public boost::enable_shared_from_this<connection>, + private boost::noncopyable { + public: + /// Construct a connection with the given io_service. + explicit connection(boost::asio::io_service& io_service, + request_handler& handler); + + /// Get the socket associated with the connection. + boost::asio::ip::tcp::socket& socket(); + + /// Start the first asynchronous operation for the connection. + void start(); + + private: + /// Handle completion of a read operation. + void handle_read(const boost::system::error_code& e, + std::size_t bytes_transferred); + + /// Handle completion of a write operation. + void handle_write(const boost::system::error_code& e); + + /// Strand to ensure the connection's handlers are not called concurrently. + boost::asio::io_service::strand strand_; + + /// Socket for the connection. + boost::asio::ip::tcp::socket socket_; + + /// The handler used to process the incoming request. + request_handler& request_handler_; + + /// Buffer for incoming data. + boost::array<char, 8192> buffer_; + + /// The incoming request. + request request_; + + /// The parser for the incoming request. + request_parser request_parser_; + + /// The reply to be sent back to the client. + reply reply_; + }; + + typedef boost::shared_ptr<connection> connection_ptr; + + } // namespace server3 +} // namespace http +#endif // HTTP_SERVER3_CONNECTION_HPP Added: trunk/dsim/test/boost/asio/httpd/header.hpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/header.hpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/header.hpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,27 @@ +// +// header.hpp +// ~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_SERVER3_HEADER_HPP +#define HTTP_SERVER3_HEADER_HPP + +#include <string> + +namespace http { + + namespace server3 { + + struct header { + std::string name; + std::string value; + }; + + } // namespace server3 +} // namespace http +#endif // HTTP_SERVER3_HEADER_HPP Added: trunk/dsim/test/boost/asio/httpd/mime_types.cpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/mime_types.cpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/mime_types.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,43 @@ +// +// mime_types.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "mime_types.hpp" + +namespace http { + + namespace server3 { + + namespace mime_types { + + struct mapping { + const char* extension; + const char* mime_type; + } mappings[] = { + { "gif", "image/gif" }, + { "htm", "text/html" }, + { "html", "text/html" }, + { "jpg", "image/jpeg" }, + { "png", "image/png" }, + { 0, 0 } // Marks end of list. + }; + + std::string extension_to_type(const std::string& extension) { + for (mapping* m = mappings; m->extension; ++m) { + if (m->extension == extension) { + return m->mime_type; + } + } + + return "text/plain"; + } + + } // namespace mime_types + } // namespace server3 +} // namespace http Added: trunk/dsim/test/boost/asio/httpd/mime_types.hpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/mime_types.hpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/mime_types.hpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,29 @@ +// +// mime_types.hpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_SERVER3_MIME_TYPES_HPP +#define HTTP_SERVER3_MIME_TYPES_HPP + +#include <string> + +namespace http { + + namespace server3 { + + namespace mime_types { + + /// Convert a file extension into a MIME type. + std::string extension_to_type(const std::string& extension); + + } // namespace mime_types + } // namespace server3 +} // namespace http + +#endif // HTTP_SERVER3_MIME_TYPES_HPP Added: trunk/dsim/test/boost/asio/httpd/posix_main.cpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/posix_main.cpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/posix_main.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,73 @@ +// +// posix_main.cpp +// ~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include <iostream> +#include <string> +#include <boost/asio.hpp> +#include <boost/thread.hpp> +#include <boost/bind.hpp> +#include <boost/lexical_cast.hpp> +#include "server.hpp" + +#if !defined(_WIN32) + +#include <pthread.h> +#include <signal.h> + +int main(int argc, char* argv[]) { + + try { + + // Check command line arguments. + if (argc != 5) { + std::cerr << "Usage: http_server <address> <port> <threads> <doc_root>\n"; + std::cerr << " For IPv4, try:\n"; + std::cerr << " receiver 0.0.0.0 80 1 .\n"; + std::cerr << " For IPv6, try:\n"; + std::cerr << " receiver 0::0 80 1 .\n"; + return 1; + } + + // Block all signals for background thread. + sigset_t new_mask; + sigfillset(&new_mask); + sigset_t old_mask; + pthread_sigmask(SIG_BLOCK, &new_mask, &old_mask); + + // Run server in background thread. + std::size_t num_threads = boost::lexical_cast<std::size_t>(argv[3]); + http::server3::server s(argv[1], argv[2], argv[4], num_threads); + boost::thread t(boost::bind(&http::server3::server::run, &s)); + + // Restore previous signals. + pthread_sigmask(SIG_SETMASK, &old_mask, 0); + + // Wait for signal indicating time to shut down. + sigset_t wait_mask; + sigemptyset(&wait_mask); + sigaddset(&wait_mask, SIGINT); + sigaddset(&wait_mask, SIGQUIT); + sigaddset(&wait_mask, SIGTERM); + pthread_sigmask(SIG_BLOCK, &wait_mask, 0); + int sig = 0; + sigwait(&wait_mask, &sig); + + // Stop the server. + s.stop(); + t.join(); + + } catch (std::exception& e) { + std::cerr << "exception: " << e.what() << "\n"; + } + + return 0; +} + +#endif // !defined(_WIN32) Added: trunk/dsim/test/boost/asio/httpd/reply.cpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/reply.cpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/reply.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,253 @@ +// +// reply.cpp +// ~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "reply.hpp" +#include <string> +#include <boost/lexical_cast.hpp> + +namespace http { + + namespace server3 { + + namespace status_strings { + + const std::string ok = + "HTTP/1.0 200 OK\r\n"; + const std::string created = + "HTTP/1.0 201 Created\r\n"; + const std::string accepted = + "HTTP/1.0 202 Accepted\r\n"; + const std::string no_content = + "HTTP/1.0 204 No Content\r\n"; + const std::string multiple_choices = + "HTTP/1.0 300 Multiple Choices\r\n"; + const std::string moved_permanently = + "HTTP/1.0 301 Moved Permanently\r\n"; + const std::string moved_temporarily = + "HTTP/1.0 302 Moved Temporarily\r\n"; + const std::string not_modified = + "HTTP/1.0 304 Not Modified\r\n"; + const std::string bad_request = + "HTTP/1.0 400 Bad Request\r\n"; + const std::string unauthorized = + "HTTP/1.0 401 Unauthorized\r\n"; + const std::string forbidden = + "HTTP/1.0 403 Forbidden\r\n"; + const std::string not_found = + "HTTP/1.0 404 Not Found\r\n"; + const std::string internal_server_error = + "HTTP/1.0 500 Internal Server Error\r\n"; + const std::string not_implemented = + "HTTP/1.0 501 Not Implemented\r\n"; + const std::string bad_gateway = + "HTTP/1.0 502 Bad Gateway\r\n"; + const std::string service_unavailable = + "HTTP/1.0 503 Service Unavailable\r\n"; + + boost::asio::const_buffer to_buffer(reply::status_type status) { + switch (status) { + case reply::ok: + return boost::asio::buffer(ok); + case reply::created: + return boost::asio::buffer(created); + case reply::accepted: + return boost::asio::buffer(accepted); + case reply::no_content: + return boost::asio::buffer(no_content); + case reply::multiple_choices: + return boost::asio::buffer(multiple_choices); + case reply::moved_permanently: + return boost::asio::buffer(moved_permanently); + case reply::moved_temporarily: + return boost::asio::buffer(moved_temporarily); + case reply::not_modified: + return boost::asio::buffer(not_modified); + case reply::bad_request: + return boost::asio::buffer(bad_request); + case reply::unauthorized: + return boost::asio::buffer(unauthorized); + case reply::forbidden: + return boost::asio::buffer(forbidden); + case reply::not_found: + return boost::asio::buffer(not_found); + case reply::internal_server_error: + return boost::asio::buffer(internal_server_error); + case reply::not_implemented: + return boost::asio::buffer(not_implemented); + case reply::bad_gateway: + return boost::asio::buffer(bad_gateway); + case reply::service_unavailable: + return boost::asio::buffer(service_unavailable); + default: + return boost::asio::buffer(internal_server_error); + } + } + + } // namespace status_strings + + namespace misc_strings { + + const char name_value_separator[] = { ':', ' ' }; + const char crlf[] = { '\r', '\n' }; + + } // namespace misc_strings + + std::vector<boost::asio::const_buffer> reply::to_buffers() { + + std::vector<boost::asio::const_buffer> buffers; + + buffers.push_back(status_strings::to_buffer(status)); + for (std::size_t i = 0; i < headers.size(); ++i) { + header& h = headers[i]; + buffers.push_back(boost::asio::buffer(h.name)); + buffers.push_back(boost::asio::buffer(misc_strings::name_value_separator)); + buffers.push_back(boost::asio::buffer(h.value)); + buffers.push_back(boost::asio::buffer(misc_strings::crlf)); + } + + buffers.push_back(boost::asio::buffer(misc_strings::crlf)); + buffers.push_back(boost::asio::buffer(content)); + return buffers; + } + + namespace stock_replies { + + const char ok[] = ""; + const char created[] = + "<html>" + "<head><title>Created</title></head>" + "<body><h1>201 Created</h1></body>" + "</html>"; + const char accepted[] = + "<html>" + "<head><title>Accepted</title></head>" + "<body><h1>202 Accepted</h1></body>" + "</html>"; + const char no_content[] = + "<html>" + "<head><title>No Content</title></head>" + "<body><h1>204 Content</h1></body>" + "</html>"; + const char multiple_choices[] = + "<html>" + "<head><title>Multiple Choices</title></head>" + "<body><h1>300 Multiple Choices</h1></body>" + "</html>"; + const char moved_permanently[] = + "<html>" + "<head><title>Moved Permanently</title></head>" + "<body><h1>301 Moved Permanently</h1></body>" + "</html>"; + const char moved_temporarily[] = + "<html>" + "<head><title>Moved Temporarily</title></head>" + "<body><h1>302 Moved Temporarily</h1></body>" + "</html>"; + const char not_modified[] = + "<html>" + "<head><title>Not Modified</title></head>" + "<body><h1>304 Not Modified</h1></body>" + "</html>"; + const char bad_request[] = + "<html>" + "<head><title>Bad Request</title></head>" + "<body><h1>400 Bad Request</h1></body>" + "</html>"; + const char unauthorized[] = + "<html>" + "<head><title>Unauthorized</title></head>" + "<body><h1>401 Unauthorized</h1></body>" + "</html>"; + const char forbidden[] = + "<html>" + "<head><title>Forbidden</title></head>" + "<body><h1>403 Forbidden</h1></body>" + "</html>"; + const char not_found[] = + "<html>" + "<head><title>Not Found</title></head>" + "<body><h1>404 Not Found</h1></body>" + "</html>"; + const char internal_server_error[] = + "<html>" + "<head><title>Internal Server Error</title></head>" + "<body><h1>500 Internal Server Error</h1></body>" + "</html>"; + const char not_implemented[] = + "<html>" + "<head><title>Not Implemented</title></head>" + "<body><h1>501 Not Implemented</h1></body>" + "</html>"; + const char bad_gateway[] = + "<html>" + "<head><title>Bad Gateway</title></head>" + "<body><h1>502 Bad Gateway</h1></body>" + "</html>"; + const char service_unavailable[] = + "<html>" + "<head><title>Service Unavailable</title></head>" + "<body><h1>503 Service Unavailable</h1></body>" + "</html>"; + + std::string to_string(reply::status_type status) { + switch (status) { + case reply::ok: + return ok; + case reply::created: + return created; + case reply::accepted: + return accepted; + case reply::no_content: + return no_content; + case reply::multiple_choices: + return multiple_choices; + case reply::moved_permanently: + return moved_permanently; + case reply::moved_temporarily: + return moved_temporarily; + case reply::not_modified: + return not_modified; + case reply::bad_request: + return bad_request; + case reply::unauthorized: + return unauthorized; + case reply::forbidden: + return forbidden; + case reply::not_found: + return not_found; + case reply::internal_server_error: + return internal_server_error; + case reply::not_implemented: + return not_implemented; + case reply::bad_gateway: + return bad_gateway; + case reply::service_unavailable: + return service_unavailable; + default: + return internal_server_error; + } + } + + } // namespace stock_replies + + reply reply::stock_reply(reply::status_type status) { + reply rep; + rep.status = status; + rep.content = stock_replies::to_string(status); + rep.headers.resize(2); + rep.headers[0].name = "Content-Length"; + rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[1].name = "Content-Type"; + rep.headers[1].value = "text/html"; + return rep; + } + + } // namespace server3 +} // namespace http Added: trunk/dsim/test/boost/asio/httpd/reply.hpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/reply.hpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/reply.hpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,63 @@ +// +// reply.hpp +// ~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_SERVER3_REPLY_HPP +#define HTTP_SERVER3_REPLY_HPP + +#include <string> +#include <vector> +#include <boost/asio.hpp> +#include "header.hpp" + +namespace http { + + namespace server3 { + + /// A reply to be sent to a client. + struct reply { + + /// The status of the reply. + enum status_type { + ok = 200, + created = 201, + accepted = 202, + no_content = 204, + multiple_choices = 300, + moved_permanently = 301, + moved_temporarily = 302, + not_modified = 304, + bad_request = 400, + unauthorized = 401, + forbidden = 403, + not_found = 404, + internal_server_error = 500, + not_implemented = 501, + bad_gateway = 502, + service_unavailable = 503 + } status; + + /// The headers to be included in the reply. + std::vector<header> headers; + + /// The content to be sent in the reply. + std::string content; + + /// Convert the reply into a vector of buffers. The buffers do not own the + /// underlying memory blocks, therefore the reply object must remain valid and + /// not be changed until the write operation has completed. + std::vector<boost::asio::const_buffer> to_buffers(); + + /// Get a stock reply. + static reply stock_reply(status_type status); + }; + + } // namespace server3 +} // namespace http +#endif // HTTP_SERVER3_REPLY_HPP Added: trunk/dsim/test/boost/asio/httpd/request.hpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/request.hpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/request.hpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,33 @@ +// +// request.hpp +// ~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_SERVER3_REQUEST_HPP +#define HTTP_SERVER3_REQUEST_HPP + +#include <string> +#include <vector> +#include "header.hpp" + +namespace http { + + namespace server3 { + + /// A request received from a client. + struct request { + std::string method; + std::string uri; + int http_version_major; + int http_version_minor; + std::vector<header> headers; + }; + + } // namespace server3 +} // namespace http +#endif // HTTP_SERVER3_REQUEST_HPP Added: trunk/dsim/test/boost/asio/httpd/request_handler.cpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/request_handler.cpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/request_handler.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,115 @@ +// +// request_handler.cpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "request_handler.hpp" +#include <fstream> +#include <sstream> +#include <string> +#include <boost/lexical_cast.hpp> +#include "mime_types.hpp" +#include "reply.hpp" +#include "request.hpp" + +namespace http { + + namespace server3 { + + request_handler::request_handler(const std::string& doc_root) + : doc_root_(doc_root) { + } + + void request_handler::handle_request(const request& req, reply& rep) { + // Decode url to path. + std::string request_path; + + if (!url_decode(req.uri, request_path)) { + rep = reply::stock_reply(reply::bad_request); + return; + } + + // Request path must be absolute and not contain "..". + if (request_path.empty() || request_path[0] != '/' + || request_path.find("..") != std::string::npos) { + rep = reply::stock_reply(reply::bad_request); + return; + } + + // If path ends in slash (i.e. is a directory) then add "index.html". + if (request_path[request_path.size() - 1] == '/') { + request_path += "index.html"; + } + + // Determine the file extension. + std::size_t last_slash_pos = request_path.find_last_of("/"); + std::size_t last_dot_pos = request_path.find_last_of("."); + std::string extension; + + if (last_dot_pos != std::string::npos && last_dot_pos > last_slash_pos) { + extension = request_path.substr(last_dot_pos + 1); + } + + // Open the file to send back. + std::string full_path = doc_root_ + request_path; + std::ifstream is (full_path.c_str(), std::ios::in | std::ios::binary); + + if (!is) { + rep = reply::stock_reply(reply::not_found); + return; + } + + // Fill out the reply to be sent to the client. + rep.status = reply::ok; + char buf[512]; + while (is.read(buf, sizeof(buf)).gcount() > 0) + rep.content.append(buf, is.gcount()); + rep.headers.resize(2); + rep.headers[0].name = "Content-Length"; + rep.headers[0].value = boost::lexical_cast<std::string>(rep.content.size()); + rep.headers[1].name = "Content-Type"; + rep.headers[1].value = mime_types::extension_to_type(extension); + } + + bool request_handler::url_decode(const std::string& in, std::string& out) { + out.clear(); + out.reserve(in.size()); + + for (std::size_t i = 0; i < in.size(); ++i) { + + if (in[i] == '%') { + + if (i + 3 <= in.size()) { + int value = 0; + std::istringstream is(in.substr(i + 1, 2)); + + if (is >> std::hex >> value) { + out += static_cast<char>(value); + i += 2; + + } else { + return false; + } + + } else { + return false; + } + + } else if (in[i] == '+') { + out += ' '; + + } else { + out += in[i]; + } + } + + return true; + } + + } // namespace server3 +} // namespace http Added: trunk/dsim/test/boost/asio/httpd/request_handler.hpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/request_handler.hpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/request_handler.hpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,45 @@ +// +// request_handler.hpp +// ~~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef HTTP_SERVER3_REQUEST_HANDLER_HPP +#define HTTP_SERVER3_REQUEST_HANDLER_HPP + +#include <string> +#include <boost/noncopyable.hpp> + +namespace http { + + namespace server3 { + + struct reply; + struct request; + + /// The common handler for all incoming requests. + class request_handler + : private boost::noncopyable { + public: + /// Construct with a directory containing files to be served. + explicit request_handler(const std::string& doc_root); + + /// Handle a request and produce a reply. + void handle_request(const request& req, reply& rep); + + private: + /// The directory containing the files to be served. + std::string doc_root_; + + /// Perform URL-decoding on a string. Returns false if the encoding was + /// invalid. + static bool url_decode(const std::string& in, std::string& out); + }; + + } // namespace server3 +} // namespace http +#endif // HTTP_SERVER3_REQUEST_HANDLER_HPP Added: trunk/dsim/test/boost/asio/httpd/request_parser.cpp =================================================================== --- trunk/dsim/test/boost/asio/httpd/request_parser.cpp (rev 0) +++ trunk/dsim/test/boost/asio/httpd/request_parser.cpp 2009-12-26 01:40:41 UTC (rev 21) @@ -0,0 +1,291 @@ +// +// request_parser.cpp +// ~~~~~~~~~~~~~~~~~~ +// +// Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#include "request_parser.hpp" +#include "request.hpp" + +namespace http { + + namespace server3 { + + request_parser::request_parser() + : state_(method_start) { + } + + void request_parser::reset() { + state_ = method_start; + } + + boost::tribool request_parser::consume(request& req, char input) { + + switch (state_) { + + case method_start: + if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { + return false; + + } else { + state_ = method; + req.method.push_back(input); + return boost::indeterminate; + } + + case method: + if (input == ' ') { + state_ = uri; + return boost::indeterminate; + + } else if (!is_char(input) || is_ctl(input) || is_tspecial(input)) { + return false; + + } else { + ... [truncated message content] |
From: <den...@us...> - 2009-12-28 15:16:34
|
Revision: 25 http://dsim.svn.sourceforge.net/dsim/?rev=25&view=rev Author: denis_arnaud Date: 2009-12-28 15:16:19 +0000 (Mon, 28 Dec 2009) Log Message: ----------- [Conf] Suppressed useless dependencies on SOCI and MySQL. Modified Paths: -------------- trunk/dsim/config/mysql.m4 trunk/dsim/config/soci.m4 trunk/dsim/configure.ac trunk/dsim/dsim/bom/Makefile.am trunk/dsim/test/Makefile.am Property Changed: ---------------- trunk/dsim/test/ Modified: trunk/dsim/config/mysql.m4 =================================================================== --- trunk/dsim/config/mysql.m4 2009-12-28 10:52:19 UTC (rev 24) +++ trunk/dsim/config/mysql.m4 2009-12-28 15:16:19 UTC (rev 25) @@ -113,10 +113,10 @@ AC_MSG_RESULT([$MYSQL_libdir]) - case "$MYSQL_libdir" in - /usr/lib) ;; - *) LDFLAGS="$LDFLAGS -L${MYSQL_libdir}" ;; - esac +# case "$MYSQL_libdir" in +# /usr/lib) ;; +# *) LDFLAGS="$LDFLAGS -L${MYSQL_libdir}" ;; +# esac # # Look for MySQL C API headers Modified: trunk/dsim/config/soci.m4 =================================================================== --- trunk/dsim/config/soci.m4 2009-12-28 10:52:19 UTC (rev 24) +++ trunk/dsim/config/soci.m4 2009-12-28 15:16:19 UTC (rev 25) @@ -79,10 +79,10 @@ AC_MSG_RESULT([$SOCI_libdir]) - case "$SOCI_libdir" in - /usr/lib) ;; - *) LDFLAGS="$LDFLAGS -L${SOCI_libdir}" ;; - esac +# case "$SOCI_libdir" in +# /usr/lib) ;; +# *) LDFLAGS="$LDFLAGS -L${SOCI_libdir}" ;; +# esac # @@ -119,8 +119,8 @@ then SOCI_LIBS="-L${SOCI_libdir}" fi - SOCI_CFLAGS="-DSOCI_HEADERS_BURIED -DSOCI_MYSQL_HEADERS_BURIED $SOCI_CFLAGS" - SOCI_LIBS="$SOCI_LIBS -l${SOCI_CORE_LIB} -l${SOCI_MYSQL_LIB} -ldl" + SOCI_CFLAGS="-DSOCI_HEADERS_BURIED -DSOCI_MYSQL_HEADERS_BURIED ${MYSQL_CFLAGS} ${SOCI_CFLAGS}" + SOCI_LIBS="${MYSQL_LIBS} ${SOCI_LIBS} -l${SOCI_CORE_LIB} -l${SOCI_MYSQL_LIB} -ldl" AC_SUBST(SOCI_CFLAGS) AC_SUBST(SOCI_LIBS) Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-28 10:52:19 UTC (rev 24) +++ trunk/dsim/configure.ac 2009-12-28 15:16:19 UTC (rev 25) @@ -475,6 +475,7 @@ test/boost/spirit/Makefile test/boost/serialization/Makefile test/boost/signals/Makefile + test/rmol/Makefile ) AC_OUTPUT Modified: trunk/dsim/dsim/bom/Makefile.am =================================================================== --- trunk/dsim/dsim/bom/Makefile.am 2009-12-28 10:52:19 UTC (rev 24) +++ trunk/dsim/dsim/bom/Makefile.am 2009-12-28 15:16:19 UTC (rev 25) @@ -5,8 +5,8 @@ noinst_LTLIBRARIES= libbom.la libbom_la_SOURCES= $(bom_h_sources) $(bom_cc_sources) -libbom_la_CXXFLAGS = $(GSL_CFLAGS) -libbom_la_LDFLAGS = $(GSL_LIBS) +libbom_la_CXXFLAGS = +libbom_la_LDFLAGS = #pkgincludedir = $(includedir)/@PACKAGE@/bom #pkginclude_HEADERS = $(bom_h_sources) Property changes on: trunk/dsim/test ___________________________________________________________________ Added: svn:externals + rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-28 10:52:19 UTC (rev 24) +++ trunk/dsim/test/Makefile.am 2009-12-28 15:16:19 UTC (rev 25) @@ -17,12 +17,12 @@ #SimulationTestSuite_LDADD = $(top_builddir)/test/com/libcppunitcore.la #SimulationTestSuite_LDFLAGS = \ # $(BOOST_LIBS) $(CPPUNIT_LIBS) \ -# $(top_builddir)/@PACKAGE@/lib@PACKAGE@.la +# $(top_builddir)/dsim/libdsim.la simulate_SOURCES = simulate.cpp simulate_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) simulate_LDADD = simulate_LDFLAGS = $(BOOST_LIBS) \ - $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la + $(top_builddir)/dsim/core/libdsim.la EXTRA_DIST = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-28 18:24:20
|
Revision: 26 http://dsim.svn.sourceforge.net/dsim/?rev=26&view=rev Author: denis_arnaud Date: 2009-12-28 18:24:08 +0000 (Mon, 28 Dec 2009) Log Message: ----------- [Test] Activated the embedded ExtraCC library, and added the RMOL test sub-directory. Modified Paths: -------------- trunk/dsim/Makefile.am trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Property Changed: ---------------- trunk/dsim/ Property changes on: trunk/dsim ___________________________________________________________________ Modified: svn:externals - stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/trademgen airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/airsched avlcal https://avlcal.svn.sourceforge.net/svnroot/avlcal/trunk/avlcal/avlcal airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/airinv simfqt https://simfqt.svn.sourceforge.net/svnroot/simfqt/trunk/simfqt/simfqt simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/simcrs rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/rmol travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/travelccm + stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/trademgen airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/airsched avlcal https://avlcal.svn.sourceforge.net/svnroot/avlcal/trunk/avlcal/avlcal airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/airinv simfqt https://simfqt.svn.sourceforge.net/svnroot/simfqt/trunk/simfqt/simfqt simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/simcrs rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/rmol travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/travelccm extracppunit https://extracc.svn.sourceforge.net/svnroot/extracc/trunk/extracc/extracppunit Modified: trunk/dsim/Makefile.am =================================================================== --- trunk/dsim/Makefile.am 2009-12-28 15:16:19 UTC (rev 25) +++ trunk/dsim/Makefile.am 2009-12-28 18:24:08 UTC (rev 26) @@ -25,7 +25,8 @@ EXTRA_DIST = # Build in these directories: -SUBDIRS = stdair trademgen airsched airinv simcrs rmol dsim $(TEST_DIR) +SUBDIRS = stdair trademgen airsched airinv simcrs rmol dsim \ + extracppunit $(TEST_DIR) # Configuration helpers Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-28 15:16:19 UTC (rev 25) +++ trunk/dsim/configure.ac 2009-12-28 18:24:08 UTC (rev 26) @@ -141,7 +141,11 @@ # ----------------------------------------------------------------------------- # Support for ExtraCC (Extra-CruiseControl): http://sf.net/projects/extracc # ----------------------------------------------------------------------------- -AM_PATH_EXTRACC +# Note: the ExtraCC is now imported as a Subversion external reference, +# thus directly accessible within the extracppunit directory. +# When that library will be widely avaible on Linux distributions, +# the external reference can be removed and the following line uncommented. +#AM_PATH_EXTRACC #AC_SUBST(EXTRACC_VERSION) #AC_SUBST(EXTRACC_CFLAGS) #AC_SUBST(EXTRACC_LIBS) @@ -199,14 +203,6 @@ AC_SUBST(BOOST_MPI_PYTHON_LIB) # -------------------------------------------------------------------- -# Support for MySQL++ (C++ client API): http://tangentsoft.net/mysql++ -# -------------------------------------------------------------------- -AX_MYSQLPP -AC_SUBST(MYSQLPP_VERSION) -AC_SUBST(MYSQLPP_CFLAGS) -AC_SUBST(MYSQLPP_LIBS) - -# -------------------------------------------------------------------- # Support for SOCI http://soci.sourceforge.net # -------------------------------------------------------------------- AX_SOCI @@ -217,18 +213,22 @@ # -------------------------------------------------------------------- # Support for TRAVEL-CCM (CCM Open Library): http://sf.net/projects/travel-ccm # -------------------------------------------------------------------- -AM_PATH_TRAVELCCM -AC_SUBST(TRAVELCCM_VERSION) -AC_SUBST(TRAVELCCM_CFLAGS) -AC_SUBST(TRAVELCCM_LIBS) +# Note: That library is imported as a Subversion external reference. So, there is +# no need to import it as an independent library as well. +#AM_PATH_TRAVELCCM +#AC_SUBST(TRAVELCCM_VERSION) +#AC_SUBST(TRAVELCCM_CFLAGS) +#AC_SUBST(TRAVELCCM_LIBS) # -------------------------------------------------------------------- # Support for RMOL (RM Open Library): http://sf.net/projects/rmol # -------------------------------------------------------------------- -AM_PATH_RMOL([0.19]) -AC_SUBST(RMOL_VERSION) -AC_SUBST(RMOL_CFLAGS) -AC_SUBST(RMOL_LIBS) +# Note: That library is imported as a Subversion external reference. So, there is +# no need to import it as an independent library as well. +#AM_PATH_RMOL([0.19]) +#AC_SUBST(RMOL_VERSION) +#AC_SUBST(RMOL_CFLAGS) +#AC_SUBST(RMOL_LIBS) # ============ X E R C E S ================== AX_XERCES_C @@ -238,14 +238,6 @@ # AC_CHECK_LIBRT -# ----------------------------------------------------------- -# Xapian (Indexing & Search API: http://www.xapian.org -# ----------------------------------------------------------- -XO_LIB_XAPIAN -AC_SUBST(XAPIAN_VERSION) -AC_SUBST(XAPIAN_CFLAGS) -AC_SUBST(XAPIAN_LIBS) - # ------------------------------------------------------------------- # Support for documentation # ------------------------------------------------------------------- @@ -463,6 +455,7 @@ dsim/config/Makefile dsim/core/Makefile dsim/batches/Makefile + extracppunit/Makefile test/Makefile test/boost/Makefile test/boost/accumulators/Makefile @@ -561,11 +554,6 @@ o MYSQL_CFLAGS .... : ${MYSQL_CFLAGS} o MYSQL_LIBS ...... : ${MYSQL_LIBS} - - MySQL++ ........... : - o MYSQLPP_version . : ${MYSQLPP_VERSION} - o MYSQLPP_CFLAGS .. : ${MYSQLPP_CFLAGS} - o MYSQLPP_LIBS .... : ${MYSQLPP_LIBS} - - SOCI .............. : o SOCI_version .... : ${SOCI_VERSION} o SOCI_CFLAGS ..... : ${SOCI_CFLAGS} @@ -576,26 +564,6 @@ o XERCES_CFLAGS ... : ${XERCES_CFLAGS} o XERCES_LIBS ..... : ${XERCES_LIBS} - - EXTRACC ........... : - o EXTRACC_VERSION . : ${EXTRACC_VERSION} - o EXTRACC_CFLAGS .. : ${EXTRACC_CFLAGS} - o EXTRACC_LIBS .... : ${EXTRACC_LIBS} - - - TRAVELCCM ......... : - o TRAVELCCM_VERSION : ${TRAVELCCM_VERSION} - o TRAVELCCM_CFLAGS : ${TRAVELCCM_CFLAGS} - o TRAVELCCM_LIBS .. : ${TRAVELCCM_LIBS} - - - RMOL .............. : - o RMOL_VERSION .... : ${RMOL_VERSION} - o RMOL_CFLAGS ..... : ${RMOL_CFLAGS} - o RMOL_LIBS ....... : ${RMOL_LIBS} - - - XAPIAN ............ : - o XAPIAN_VERSION .. : ${XAPIAN_VERSION} - o XAPIAN_CFLAGS ... : ${XAPIAN_CFLAGS} - o XAPIAN_LIBS ..... : ${XAPIAN_LIBS} - - CPPUNIT............ : o CPPUNIT_VERSION . : ${CPPUNIT_VERSION} o CPPUNIT_CFLAGS .. : ${CPPUNIT_CFLAGS} Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-28 15:16:19 UTC (rev 25) +++ trunk/dsim/test/Makefile.am 2009-12-28 18:24:08 UTC (rev 26) @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = boost +SUBDIRS = boost rmol ## check_PROGRAMS = simulate This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-29 13:34:22
|
Revision: 29 http://dsim.svn.sourceforge.net/dsim/?rev=29&view=rev Author: denis_arnaud Date: 2009-12-29 13:34:09 +0000 (Tue, 29 Dec 2009) Log Message: ----------- [Test] Added the tests on the Airline Schedule Manager (airsched) library. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Property Changed: ---------------- trunk/dsim/test/ Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-29 13:19:34 UTC (rev 28) +++ trunk/dsim/configure.ac 2009-12-29 13:34:09 UTC (rev 29) @@ -476,6 +476,7 @@ test/boost/spirit/Makefile test/boost/serialization/Makefile test/boost/signals/Makefile + test/airsched/Makefile test/rmol/Makefile ) AC_OUTPUT Property changes on: trunk/dsim/test ___________________________________________________________________ Modified: svn:externals - rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol + airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-29 13:19:34 UTC (rev 28) +++ trunk/dsim/test/Makefile.am 2009-12-29 13:34:09 UTC (rev 29) @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = boost rmol +SUBDIRS = boost airsched rmol ## check_PROGRAMS = simulate This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-29 14:14:48
|
Revision: 30 http://dsim.svn.sourceforge.net/dsim/?rev=30&view=rev Author: denis_arnaud Date: 2009-12-29 14:14:40 +0000 (Tue, 29 Dec 2009) Log Message: ----------- [Test] Added tests for the stdair, airinv and simcrs projects. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Property Changed: ---------------- trunk/dsim/test/ Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-29 13:34:09 UTC (rev 29) +++ trunk/dsim/configure.ac 2009-12-29 14:14:40 UTC (rev 30) @@ -476,8 +476,11 @@ test/boost/spirit/Makefile test/boost/serialization/Makefile test/boost/signals/Makefile + test/stdair/Makefile test/airsched/Makefile + test/airinv/Makefile test/rmol/Makefile + test/simcrs/Makefile ) AC_OUTPUT Property changes on: trunk/dsim/test ___________________________________________________________________ Modified: svn:externals - airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol + stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://rmol.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://rmol.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-29 13:34:09 UTC (rev 29) +++ trunk/dsim/test/Makefile.am 2009-12-29 14:14:40 UTC (rev 30) @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = boost airsched rmol +SUBDIRS = boost stdair airsched airinv rmol simcrs ## check_PROGRAMS = simulate This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-07-24 16:29:52
|
Revision: 110 http://dsim.svn.sourceforge.net/dsim/?rev=110&view=rev Author: denis_arnaud Date: 2010-07-24 16:29:46 +0000 (Sat, 24 Jul 2010) Log Message: ----------- [Doc] Updated the tool for document generation (in order to produce PDF documents). Modified Paths: -------------- trunk/dsim/Makefile.am trunk/dsim/doc/Makefile.am Modified: trunk/dsim/Makefile.am =================================================================== --- trunk/dsim/Makefile.am 2010-07-24 16:24:03 UTC (rev 109) +++ trunk/dsim/Makefile.am 2010-07-24 16:29:46 UTC (rev 110) @@ -74,4 +74,3 @@ upload-tex: dist-tex @UPLOAD_COMMAND@ @PACKAGE_TARNAME@-tex-@VERSION@.tar.gz \ @PACKAGE_TARNAME@-tex-@VERSION@.tar.bz2 - Modified: trunk/dsim/doc/Makefile.am =================================================================== --- trunk/dsim/doc/Makefile.am 2010-07-24 16:24:03 UTC (rev 109) +++ trunk/dsim/doc/Makefile.am 2010-07-24 16:29:46 UTC (rev 110) @@ -158,6 +158,13 @@ $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/html; \ done \ fi + $(mkinstalldirs) $(DESTDIR)$(docdir) + if test -d latex; then \ + $(mkinstalldirs) $(DESTDIR)$(docdir)/latex; \ + for f in latex/*; do \ + $(INSTALL_DATA) $$f $(DESTDIR)$(docdir)/latex; \ + done \ + fi uninstall-local: rm -rf $(DESTDIR)$(docdir) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-29 17:57:15
|
Revision: 32 http://dsim.svn.sourceforge.net/dsim/?rev=32&view=rev Author: denis_arnaud Date: 2009-12-29 17:57:04 +0000 (Tue, 29 Dec 2009) Log Message: ----------- [Test] Moved the dsim tests into a dedicated directory. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Added Paths: ----------- trunk/dsim/test/dsim/ trunk/dsim/test/dsim/Makefile.am trunk/dsim/test/dsim/simulate.cpp Removed Paths: ------------- trunk/dsim/test/simulate.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-29 16:05:42 UTC (rev 31) +++ trunk/dsim/configure.ac 2009-12-29 17:57:04 UTC (rev 32) @@ -481,6 +481,7 @@ test/airinv/Makefile test/rmol/Makefile test/simcrs/Makefile + test/dsim/Makefile ) AC_OUTPUT Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-29 16:05:42 UTC (rev 31) +++ trunk/dsim/test/Makefile.am 2009-12-29 17:57:04 UTC (rev 32) @@ -4,25 +4,11 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = boost stdair airsched airinv rmol simcrs +SUBDIRS = boost stdair airsched airinv rmol simcrs dsim +EXTRA_DIST = + ## -check_PROGRAMS = simulate +check_PROGRAMS = TESTS = $(check_PROGRAMS) XFAIL_TESTS = # - -#SimulationTestSuite_SOURCES = SimulationTestSuite.hpp \ - SimulationTestSuite.cpp -#SimulationTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) -#SimulationTestSuite_LDADD = $(top_builddir)/test/com/libcppunitcore.la -#SimulationTestSuite_LDFLAGS = \ -# $(BOOST_LIBS) $(CPPUNIT_LIBS) \ -# $(top_builddir)/dsim/libdsim.la - -simulate_SOURCES = simulate.cpp -simulate_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) -simulate_LDADD = -simulate_LDFLAGS = $(BOOST_LIBS) \ - $(top_builddir)/dsim/core/libdsim.la - -EXTRA_DIST = Property changes on: trunk/dsim/test/dsim ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile simulate simulate.log Copied: trunk/dsim/test/dsim/Makefile.am (from rev 31, trunk/dsim/test/Makefile.am) =================================================================== --- trunk/dsim/test/dsim/Makefile.am (rev 0) +++ trunk/dsim/test/dsim/Makefile.am 2009-12-29 17:57:04 UTC (rev 32) @@ -0,0 +1,28 @@ +## test sub-directory +include $(top_srcdir)/Makefile.common + +MAINTAINERCLEANFILES = Makefile.in + +## +SUBDIRS = + +EXTRA_DIST = + +## +check_PROGRAMS = simulate +TESTS = $(check_PROGRAMS) +XFAIL_TESTS = # + +#SimulationTestSuite_SOURCES = SimulationTestSuite.hpp \ + SimulationTestSuite.cpp +#SimulationTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) +#SimulationTestSuite_LDADD = $(top_builddir)/test/com/libcppunitcore.la +#SimulationTestSuite_LDFLAGS = \ +# $(BOOST_LIBS) $(CPPUNIT_LIBS) \ +# $(top_builddir)/dsim/libdsim.la + +simulate_SOURCES = simulate.cpp +simulate_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) +simulate_LDADD = +simulate_LDFLAGS = $(BOOST_LIBS) \ + $(top_builddir)/dsim/core/libdsim.la Copied: trunk/dsim/test/dsim/simulate.cpp (from rev 31, trunk/dsim/test/simulate.cpp) =================================================================== --- trunk/dsim/test/dsim/simulate.cpp (rev 0) +++ trunk/dsim/test/dsim/simulate.cpp 2009-12-29 17:57:04 UTC (rev 32) @@ -0,0 +1,40 @@ +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <fstream> +#include <string> +// DSIM +#include <dsim/DSIM_Service.hpp> +#include <dsim/config/dsim-paths.hpp> + +// ///////// M A I N //////////// +int main (int argc, char* argv[]) { + + try { + + // Output log File + std::string lLogFilename ("simulate.log"); + + // Set the log parameters + std::ofstream logOutputFile; + // Open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + // Initialise the list of classes/buckets + DSIM::DSIM_Service dsimService (logOutputFile); + + // Perform a simulation + dsimService.simulate(); + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return -1; + + } catch (...) { + return -1; + } + + return 0; +} Deleted: trunk/dsim/test/simulate.cpp =================================================================== --- trunk/dsim/test/simulate.cpp 2009-12-29 16:05:42 UTC (rev 31) +++ trunk/dsim/test/simulate.cpp 2009-12-29 17:57:04 UTC (rev 32) @@ -1,40 +0,0 @@ -// STL -#include <cassert> -#include <iostream> -#include <sstream> -#include <fstream> -#include <string> -// DSIM -#include <dsim/DSIM_Service.hpp> -#include <dsim/config/dsim-paths.hpp> - -// ///////// M A I N //////////// -int main (int argc, char* argv[]) { - - try { - - // Output log File - std::string lLogFilename ("simulate.log"); - - // Set the log parameters - std::ofstream logOutputFile; - // Open and clean the log outputfile - logOutputFile.open (lLogFilename.c_str()); - logOutputFile.clear(); - - // Initialise the list of classes/buckets - DSIM::DSIM_Service dsimService (logOutputFile); - - // Perform a simulation - dsimService.simulate(); - - } catch (const std::exception& stde) { - std::cerr << "Standard exception: " << stde.what() << std::endl; - return -1; - - } catch (...) { - return -1; - } - - return 0; -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-30 14:25:15
|
Revision: 37 http://dsim.svn.sourceforge.net/dsim/?rev=37&view=rev Author: denis_arnaud Date: 2009-12-30 14:25:05 +0000 (Wed, 30 Dec 2009) Log Message: ----------- [Struct] Added a dependency (as Subversion external references) on the TraDemGen project. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Property Changed: ---------------- trunk/dsim/test/ Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-30 11:19:01 UTC (rev 36) +++ trunk/dsim/configure.ac 2009-12-30 14:25:05 UTC (rev 37) @@ -477,6 +477,7 @@ test/boost/serialization/Makefile test/boost/signals/Makefile test/stdair/Makefile + test/trademgen/Makefile test/airsched/Makefile test/airinv/Makefile test/rmol/Makefile Property changes on: trunk/dsim/test ___________________________________________________________________ Modified: svn:externals - stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://rmol.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://rmol.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs + stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/test/trademgen Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-30 11:19:01 UTC (rev 36) +++ trunk/dsim/test/Makefile.am 2009-12-30 14:25:05 UTC (rev 37) @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = boost stdair airsched airinv rmol simcrs dsim +SUBDIRS = boost stdair trademgen airsched airinv rmol simcrs dsim EXTRA_DIST = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-30 15:15:08
|
Revision: 39 http://dsim.svn.sourceforge.net/dsim/?rev=39&view=rev Author: denis_arnaud Date: 2009-12-30 15:14:59 +0000 (Wed, 30 Dec 2009) Log Message: ----------- [Test] Added the (external reference on the) samples directory. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Removed Paths: ------------- trunk/dsim/test/samples/ Property Changed: ---------------- trunk/dsim/test/ Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-30 14:34:30 UTC (rev 38) +++ trunk/dsim/configure.ac 2009-12-30 15:14:59 UTC (rev 39) @@ -465,6 +465,7 @@ dsim/batches/Makefile extracppunit/Makefile test/Makefile + test/samples/Makefile test/boost/Makefile test/boost/accumulators/Makefile test/boost/asio/Makefile Property changes on: trunk/dsim/test ___________________________________________________________________ Modified: svn:externals - stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/test/trademgen + samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/test/trademgen Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-30 14:34:30 UTC (rev 38) +++ trunk/dsim/test/Makefile.am 2009-12-30 15:14:59 UTC (rev 39) @@ -4,7 +4,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = boost stdair trademgen airsched airinv rmol simcrs dsim +SUBDIRS = boost samples stdair trademgen airsched airinv rmol simcrs dsim EXTRA_DIST = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-30 16:08:30
|
Revision: 40 http://dsim.svn.sourceforge.net/dsim/?rev=40&view=rev Author: denis_arnaud Date: 2009-12-30 16:08:23 +0000 (Wed, 30 Dec 2009) Log Message: ----------- [Struct] Added the Travel-CCM project. Modified Paths: -------------- trunk/dsim/Makefile.am trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Property Changed: ---------------- trunk/dsim/test/ Modified: trunk/dsim/Makefile.am =================================================================== --- trunk/dsim/Makefile.am 2009-12-30 15:14:59 UTC (rev 39) +++ trunk/dsim/Makefile.am 2009-12-30 16:08:23 UTC (rev 40) @@ -21,11 +21,10 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure \ config-h.in sic/stamp-h.in autogen.sh bootstrap -#EXTRA_DIST = @PACKAGE@.spec @PACKAGE@.m4 @PACKAGE@.pc Makefile.common -EXTRA_DIST = +EXTRA_DIST = @PACKAGE@.spec @PACKAGE@.m4 @PACKAGE@.pc Makefile.common # Build in these directories: -SUBDIRS = stdair trademgen airsched airinv simcrs rmol dsim \ +SUBDIRS = stdair trademgen airsched airinv simcrs rmol travelccm dsim \ extracppunit $(TEST_DIR) Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-30 15:14:59 UTC (rev 39) +++ trunk/dsim/configure.ac 2009-12-30 16:08:23 UTC (rev 40) @@ -454,6 +454,15 @@ rmol/config/Makefile rmol/core/Makefile rmol/batches/Makefile + travelccm/Makefile + travelccm/basic/Makefile + travelccm/bom/Makefile + travelccm/factory/Makefile + travelccm/command/Makefile + travelccm/service/Makefile + travelccm/core/Makefile + travelccm/config/Makefile + travelccm/batches/Makefile dsim/Makefile dsim/basic/Makefile dsim/bom/Makefile @@ -483,6 +492,7 @@ test/airinv/Makefile test/rmol/Makefile test/simcrs/Makefile + test/travelccm/Makefile test/dsim/Makefile ) AC_OUTPUT Property changes on: trunk/dsim/test ___________________________________________________________________ Modified: svn:externals - samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/test/trademgen + samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/test/trademgen travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/test/travelccm Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-30 15:14:59 UTC (rev 39) +++ trunk/dsim/test/Makefile.am 2009-12-30 16:08:23 UTC (rev 40) @@ -4,7 +4,8 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = boost samples stdair trademgen airsched airinv rmol simcrs dsim +SUBDIRS = boost samples \ + stdair trademgen airsched airinv rmol simcrs travelccm dsim EXTRA_DIST = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-31 11:15:08
|
Revision: 41 http://dsim.svn.sourceforge.net/dsim/?rev=41&view=rev Author: denis_arnaud Date: 2009-12-31 11:14:56 +0000 (Thu, 31 Dec 2009) Log Message: ----------- [Struct] Added SimFQT and AvlCal projects. Modified Paths: -------------- trunk/dsim/Makefile.am trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Property Changed: ---------------- trunk/dsim/test/ Modified: trunk/dsim/Makefile.am =================================================================== --- trunk/dsim/Makefile.am 2009-12-30 16:08:23 UTC (rev 40) +++ trunk/dsim/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) @@ -24,8 +24,8 @@ EXTRA_DIST = @PACKAGE@.spec @PACKAGE@.m4 @PACKAGE@.pc Makefile.common # Build in these directories: -SUBDIRS = stdair trademgen airsched airinv simcrs rmol travelccm dsim \ - extracppunit $(TEST_DIR) +SUBDIRS = stdair trademgen airsched rmol airinv avlcal simfqt simcrs travelccm \ + dsim extracppunit $(TEST_DIR) # Configuration helpers Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-30 16:08:23 UTC (rev 40) +++ trunk/dsim/configure.ac 2009-12-31 11:14:56 UTC (rev 41) @@ -426,6 +426,16 @@ airsched/config/Makefile airsched/core/Makefile airsched/batches/Makefile + rmol/Makefile + rmol/basic/Makefile + rmol/field/Makefile + rmol/bom/Makefile + rmol/factory/Makefile + rmol/command/Makefile + rmol/service/Makefile + rmol/config/Makefile + rmol/core/Makefile + rmol/batches/Makefile airinv/Makefile airinv/basic/Makefile airinv/bom/Makefile @@ -435,6 +445,24 @@ airinv/config/Makefile airinv/core/Makefile airinv/batches/Makefile + avlcal/Makefile + avlcal/basic/Makefile + avlcal/bom/Makefile + avlcal/factory/Makefile + avlcal/command/Makefile + avlcal/service/Makefile + avlcal/config/Makefile + avlcal/core/Makefile + avlcal/batches/Makefile + simfqt/Makefile + simfqt/basic/Makefile + simfqt/bom/Makefile + simfqt/factory/Makefile + simfqt/command/Makefile + simfqt/service/Makefile + simfqt/config/Makefile + simfqt/core/Makefile + simfqt/batches/Makefile simcrs/Makefile simcrs/basic/Makefile simcrs/bom/Makefile @@ -444,16 +472,6 @@ simcrs/config/Makefile simcrs/core/Makefile simcrs/batches/Makefile - rmol/Makefile - rmol/basic/Makefile - rmol/field/Makefile - rmol/bom/Makefile - rmol/factory/Makefile - rmol/command/Makefile - rmol/service/Makefile - rmol/config/Makefile - rmol/core/Makefile - rmol/batches/Makefile travelccm/Makefile travelccm/basic/Makefile travelccm/bom/Makefile @@ -489,8 +507,10 @@ test/stdair/Makefile test/trademgen/Makefile test/airsched/Makefile + test/rmol/Makefile test/airinv/Makefile - test/rmol/Makefile + test/avlcal/Makefile + test/simfqt/Makefile test/simcrs/Makefile test/travelccm/Makefile test/dsim/Makefile Property changes on: trunk/dsim/test ___________________________________________________________________ Modified: svn:externals - samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/test/trademgen travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/test/travelccm + samples https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/samples stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/test/stdair airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/test/airsched avlcal https://avlcal.svn.sourceforge.net/svnroot/avlcal/trunk/avlcal/test/avlcal simfqt https://simfqt.svn.sourceforge.net/svnroot/simfqt/trunk/simfqt/test/simfqt airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/test/airinv rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/test/rmol simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/test/simcrs trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/test/trademgen travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/test/travelccm Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2009-12-30 16:08:23 UTC (rev 40) +++ trunk/dsim/test/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) @@ -5,7 +5,7 @@ ## SUBDIRS = boost samples \ - stdair trademgen airsched airinv rmol simcrs travelccm dsim + stdair trademgen airsched rmol airinv avlcal simfqt simcrs travelccm dsim EXTRA_DIST = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2009-12-31 13:33:44
|
Revision: 42 http://dsim.svn.sourceforge.net/dsim/?rev=42&view=rev Author: denis_arnaud Date: 2009-12-31 13:33:35 +0000 (Thu, 31 Dec 2009) Log Message: ----------- [Test] Added tests for the Boost.Filesystem library. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/boost/Makefile.am trunk/dsim/test/boost/accumulators/Makefile.am trunk/dsim/test/boost/asio/Makefile.am trunk/dsim/test/boost/mpl/Makefile.am trunk/dsim/test/boost/serialization/Makefile.am trunk/dsim/test/boost/signals/Makefile.am Added Paths: ----------- trunk/dsim/test/boost/filesystem/ trunk/dsim/test/boost/filesystem/Makefile.am trunk/dsim/test/boost/filesystem/file_size.cpp trunk/dsim/test/boost/filesystem/fstream_test.cpp trunk/dsim/test/boost/filesystem/lpath.hpp trunk/dsim/test/boost/filesystem/operations_test.cpp trunk/dsim/test/boost/filesystem/path_test.cpp trunk/dsim/test/boost/filesystem/process_jam_log.cpp trunk/dsim/test/boost/filesystem/simple_ls.cpp trunk/dsim/test/boost/filesystem/tiny_xml.cpp trunk/dsim/test/boost/filesystem/tiny_xml.hpp trunk/dsim/test/boost/filesystem/utf8_codecvt_facet.cpp trunk/dsim/test/boost/filesystem/utf8_codecvt_facet.hpp trunk/dsim/test/boost/filesystem/utf8_codecvt_facet_base.cpp trunk/dsim/test/boost/filesystem/wide_test.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/configure.ac 2009-12-31 13:33:35 UTC (rev 42) @@ -499,6 +499,7 @@ test/boost/asio/httpd/Makefile test/boost/asio/logd/Makefile test/boost/asio/logger/Makefile + test/boost/filesystem/Makefile test/boost/mpi/Makefile test/boost/mpl/Makefile test/boost/spirit/Makefile Modified: trunk/dsim/test/boost/Makefile.am =================================================================== --- trunk/dsim/test/boost/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/test/boost/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -5,6 +5,6 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = accumulators asio mpi mpl serialization signals spirit +SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit EXTRA_DIST = Modified: trunk/dsim/test/boost/accumulators/Makefile.am =================================================================== --- trunk/dsim/test/boost/accumulators/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/test/boost/accumulators/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -1,4 +1,4 @@ -## test/architecture sub-directory +## test/boost/accumulators sub-directory include $(top_srcdir)/Makefile.common MAINTAINERCLEANFILES = Makefile.in Modified: trunk/dsim/test/boost/asio/Makefile.am =================================================================== --- trunk/dsim/test/boost/asio/Makefile.am 2009-12-31 11:14:56 UTC (rev 41) +++ trunk/dsim/test/boost/asio/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -1,4 +1,4 @@ -## test/asio sub-directory +## test/boost/asio sub-directory include $(top_srcdir)/Makefile.common ## Property changes on: trunk/dsim/test/boost/filesystem ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile simple_ls file_size process_jam_log path_test wide_test fstream_test operations_test Copied: trunk/dsim/test/boost/filesystem/Makefile.am (from rev 41, trunk/dsim/test/boost/mpl/Makefile.am) =================================================================== --- trunk/dsim/test/boost/filesystem/Makefile.am (rev 0) +++ trunk/dsim/test/boost/filesystem/Makefile.am 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,57 @@ +## test/boost/filesystem sub-directory +include $(top_srcdir)/Makefile.common + +# +MAINTAINERCLEANFILES = Makefile.in + +# +SUBDIRS = + +EXTRA_DIST = + +# +check_PROGRAMS = simple_ls file_size process_jam_log \ + path_test wide_test operations_test fstream_test + +# +simple_ls_SOURCES = simple_ls.cpp +simple_ls_CXXFLAGS = $(BOOST_CFLAGS) +simple_ls_LDADD = +simple_ls_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +file_size_SOURCES = file_size.cpp +file_size_CXXFLAGS = $(BOOST_CFLAGS) +file_size_LDADD = +file_size_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +process_jam_log_SOURCES = tiny_xml.hpp tiny_xml.cpp process_jam_log.cpp +process_jam_log_CXXFLAGS = $(BOOST_CFLAGS) +process_jam_log_LDADD = +process_jam_log_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +path_test_SOURCES = path_test.cpp +path_test_CXXFLAGS = $(BOOST_CFLAGS) +path_test_LDADD = +path_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +wide_test_SOURCES = wide_test.cpp +wide_test_CXXFLAGS = $(BOOST_CFLAGS) +wide_test_LDADD = +wide_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +operations_test_SOURCES = operations_test.cpp +operations_test_CXXFLAGS = $(BOOST_CFLAGS) +operations_test_LDADD = +operations_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + +# +fstream_test_SOURCES = fstream_test.cpp +fstream_test_CXXFLAGS = $(BOOST_CFLAGS) +fstream_test_LDADD = +fstream_test_LDFLAGS = $(BOOST_LIBS) $(BOOST_FILESYSTEM_LIB) + Added: trunk/dsim/test/boost/filesystem/file_size.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/file_size.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/file_size.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,38 @@ +// file_size program -------------------------------------------------------// +// Copyright Beman Dawes, 2004 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// See http://www.boost.org/libs/filesystem for documentation. +// STL +#include <iostream> +// Boost +#include <boost/filesystem/operations.hpp> + +namespace fs = boost::filesystem; + +// ////////////////////// M A I N /////////////////////// +int main( int argc, char* argv[] ) { + + if ( argc != 2 ) { + std::cout << "Usage: file_size path" << std::endl; + return 1; + } + + std::cout << "sizeof(intmax_t) is " << sizeof(boost::intmax_t) << std::endl; + + fs::path p( argv[1], fs::native ); + + if (fs::exists (p) == false) { + std::cout << "not found: " << argv[1] << std::endl; + return 1; + } + + if (fs::is_regular (p) == false) { + std::cout << "not a regular file: " << argv[1] << std::endl; + return 1; + } + + std::cout << "size of " << argv[1] << " is " << fs::file_size(p) << std::endl; + return 0; +} Added: trunk/dsim/test/boost/filesystem/fstream_test.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/fstream_test.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/fstream_test.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,177 @@ +// fstream_test.cpp --------------------------------------------------------// +// Copyright Beman Dawes 2002. +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// See library home page at http://www.boost.org/libs/filesystem +// STL +#include <string> +#include <iostream> +#include <cstdio> // for std::remove +// Boost +#include <boost/config/warning_disable.hpp> +// See deprecated_test for tests of deprecated features +#define BOOST_FILESYSTEM_NO_DEPRECATED +#include <boost/filesystem/config.hpp> + +# ifdef BOOST_FILESYSTEM_NARROW_ONLY +# include "lpath.hpp" +# endif + +#include <boost/filesystem/fstream.hpp> +#include <boost/filesystem/operations.hpp> +#include <boost/detail/lightweight_test.hpp> + +#include "utf8_codecvt_facet.hpp" + +namespace fs = boost::filesystem; + +#ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::remove; } +#endif + + +namespace { + + bool cleanup = true; + + template< class Path > + void test( const Path & p ) { +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 1\n"; + fs::filebuf fb; + fb.open( p, std::ios_base::in ); + BOOST_TEST( fb.is_open() == fs::exists( p ) ); + } + { + std::cout << " in test 2\n"; + fs::filebuf fb1; + fb1.open( p, std::ios_base::out ); + BOOST_TEST( fb1.is_open() ); + } + { + std::cout << " in test 3\n"; + fs::filebuf fb2; + fb2.open( p, std::ios_base::in ); + BOOST_TEST( fb2.is_open() ); + } +# else + std::cout << "<note>\n"; + std::cout << + "VC++6.0 does not support boost::filesystem open()\n"; +# endif + { + std::cout << " in test 4\n"; + fs::ifstream tfs( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 4.1\n"; + fs::ifstream tfs( p / p.filename() ); // should fail + BOOST_TEST( !tfs.is_open() ); + } + { + std::cout << " in test 5\n"; + fs::ifstream tfs( p, std::ios_base::in ); + BOOST_TEST( tfs.is_open() ); + } +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 6\n"; + fs::ifstream tfs; + tfs.open( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 7\n"; + fs::ifstream tfs; + tfs.open( p, std::ios_base::in ); + BOOST_TEST( tfs.is_open() ); + } +# endif + { + std::cout << " in test 8\n"; + fs::ofstream tfs( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 9\n"; + fs::ofstream tfs( p, std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 10\n"; + fs::ofstream tfs; + tfs.open( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 11\n"; + fs::ofstream tfs; + tfs.open( p, std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# endif + { + std::cout << " in test 12\n"; + fs::fstream tfs( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 13\n"; + fs::fstream tfs( p, std::ios_base::in|std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# if !BOOST_WORKAROUND( BOOST_MSVC, <= 1200 ) // VC++ 6.0 can't handle open + { + std::cout << " in test 14\n"; + fs::fstream tfs; + tfs.open( p ); + BOOST_TEST( tfs.is_open() ); + } + { + std::cout << " in test 15\n"; + fs::fstream tfs; + tfs.open( p, std::ios_base::in|std::ios_base::out ); + BOOST_TEST( tfs.is_open() ); + } +# endif + + if ( cleanup ) fs::remove( p ); + + } // test +} // unnamed namespace + +int main( int argc, char*[] ) +{ + if ( argc > 1 ) cleanup = false; + + // test fs::path + std::cout << "path tests:\n"; + test( fs::path( "fstream_test_foo" ) ); + +#ifndef BOOST_FILESYSTEM_NARROW_ONLY + + // So that tests are run with known encoding, use Boost UTF-8 codecvt + std::locale global_loc = std::locale(); + std::locale loc( global_loc, new fs::detail::utf8_codecvt_facet ); + fs::wpath_traits::imbue( loc ); + + // test fs::wpath + // x2780 is circled 1 against white background == e2 9e 80 in UTF-8 + // x2781 is circled 2 against white background == e2 9e 81 in UTF-8 + std::cout << "\nwpath tests:\n"; + test( fs::wpath( L"fstream_test_\x2780" ) ); + + // test user supplied basic_path + const long lname[] = { 'f', 's', 'r', 'e', 'a', 'm', '_', 't', 'e', 's', + 't', '_', 'l', 'p', 'a', 't', 'h', 0 }; + std::cout << "\nlpath tests:\n"; + // test( user::lpath( lname ) ); + +#endif + + return ::boost::report_errors(); +} Added: trunk/dsim/test/boost/filesystem/lpath.hpp =================================================================== --- trunk/dsim/test/boost/filesystem/lpath.hpp (rev 0) +++ trunk/dsim/test/boost/filesystem/lpath.hpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,101 @@ +// Boost lpath.hpp ---------------------------------------------------------// + +// Copyright Beman Dawes 2005 + +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// See library home page at http://www.boost.org/libs/filesystem + +#include <boost/filesystem/path.hpp> +#include <cwchar> // for std::mbstate_t +#include <string> +#include <ios> // for std::streamoff + +namespace std +{ + // Note well: this specialization is meant only to support wide_test.cpp. + // It is not fully functional, fully correct, or efficient. + template<> struct char_traits<long> + { + typedef long char_type; + typedef long int_type; + typedef streamoff off_type; + typedef streampos pos_type; + typedef mbstate_t state_type; + static void assign(char_type& c1, const char_type& c2){c1=c2;} + static bool eq(const char_type& c1, const char_type& c2){return c1==c2;} + static bool lt(const char_type& c1, const char_type& c2){return c1<c2;} + static int compare(const char_type* s1, const char_type* s2, size_t n) + { + const char_type* e = s1 + n; + for ( ;s1 != e && *s1 == *s2; ++s1, ++s2 ) {} + return s1 == e ? 0 : (*s1<*s2 ? -1 : 1); + } + static size_t length(const char_type* s) + { const char_type* b=s; for(;*s!=0L;++s){} return s-b; } + + static const char_type* find(const char_type* /*s*/, size_t /*n*/, const char_type& /*a*/) + { return 0; } + + // copy semantics will do for wide_test + static char_type* move(char_type* s1, const char_type* s2, size_t n) + { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; } + + static char_type* copy(char_type* s1, const char_type* s2, size_t n) + { char_type* b=s1; for(const char_type* e=s1+n;s1!=e;++s1,++s2) *s1=*s2; return b; } + + static char_type* assign(char_type* s, size_t n, char_type a) + { char_type* b=s; for(char_type* e=s+n;s!=e;++s) *s=a; return b; } + + static int_type not_eof(const int_type& c); + static char_type to_char_type(const int_type& c); + static int_type to_int_type(const char_type& c); + static bool eq_int_type(const int_type& c1, const int_type& c2); + static int_type eof(); + }; +} + +namespace user +{ + typedef std::basic_string<long> lstring; + struct lpath_traits; + typedef boost::filesystem::basic_path<lstring, lpath_traits> lpath; + + struct lpath_traits + { + typedef lstring internal_string_type; + typedef std::string external_string_type; + + static external_string_type to_external( const lpath &, + const internal_string_type & src ) + { + external_string_type tmp; + for ( internal_string_type::const_iterator it( src.begin() ); + it != src.end(); ++it ) + { + tmp += static_cast<external_string_type::value_type>(*it); + } + return tmp; + } + + static internal_string_type to_internal( const external_string_type & src ) + { + internal_string_type tmp; + for ( external_string_type::const_iterator it( src.begin() ); + it != src.end(); ++it ) tmp += *it; + return tmp; + } + }; + +} // namespace user + +namespace boost +{ + namespace filesystem + { + template<> struct is_basic_path<user::lpath> + { static const bool value = true; }; + } +} Added: trunk/dsim/test/boost/filesystem/operations_test.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/operations_test.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/operations_test.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,942 @@ +// Boost operations_test.cpp -----------------------------------------------// +// Copyright Beman Dawes 2002. +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +// See library home page at http://www.boost.org/libs/filesystem +// STL +#include <fstream> +#include <iostream> +#include <string> +#include <cstring> // for strncmp, etc. +#include <ctime> +#include <cstdlib> // for system() +// Boost +#include <boost/config/warning_disable.hpp> +// See deprecated_test for tests of deprecated features +#define BOOST_FILESYSTEM_NO_DEPRECATED +#include <boost/filesystem/operations.hpp> +#include <boost/filesystem/convenience.hpp> +#include <boost/cerrno.hpp> +namespace fs = boost::filesystem; + +#include <boost/config.hpp> +#include <boost/detail/lightweight_test.hpp> + +using boost::system::error_code; +using boost::system::system_category; +using boost::system::system_error; + +#ifndef BOOST_FILESYSTEM_NARROW_ONLY +# define BOOST_BND(BOOST_FUNC_TO_DO) BOOST_FUNC_TO_DO<fs::path> +#else +# define BOOST_BND(BOOST_FUNC_TO_DO) BOOST_FUNC_TO_DO +#endif + +// VC++ 7.0 and earlier has a serious namespace bug that causes a clash +// between boost::filesystem::is_empty and the unrelated type trait +// boost::is_empty. +#if !defined( BOOST_MSVC ) || BOOST_MSVC > 1300 +# define BOOST_FS_IS_EMPTY fs::is_empty +#else +# define BOOST_FS_IS_EMPTY fs::_is_empty +#endif + +# ifdef BOOST_NO_STDC_NAMESPACE + namespace std { using ::asctime; using ::gmtime; using ::localtime; + using ::difftime; using ::time; using ::tm; using ::mktime; using ::system; } +# endif + +#ifdef BOOST_WINDOWS_API +# include <windows.h> +#endif + +#define CHECK_EXCEPTION(Functor,Expect) throws_fs_error(Functor,Expect,__LINE__) + +namespace +{ + typedef int errno_t; + std::string platform( BOOST_PLATFORM ); + bool report_throws; + fs::directory_iterator end_itr; + + unsigned short language_id; // 0 except for Windows + + const char * temp_dir_name = "temp_fs_test_dir"; + + void create_file( const fs::path & ph, const std::string & contents ) + { + std::ofstream f( ph.file_string().c_str() ); + if ( !f ) + throw fs::filesystem_error( "operations_test create_file", + ph, error_code(errno, system_category) ); + if ( !contents.empty() ) f << contents; + } + + void verify_file( const fs::path & ph, const std::string & expected ) + { + std::ifstream f( ph.file_string().c_str() ); + if ( !f ) + throw fs::filesystem_error( "operations_test verify_file", + ph, error_code(errno, system_category) ); + std::string contents; + f >> contents; + if ( contents != expected ) + throw fs::filesystem_error( "operations_test verify_file contents \"" + + contents + "\" != \"" + expected + "\"", ph, error_code() ); + } + + template< typename F > + bool throws_fs_error( F func, errno_t en, int line ) + { + try { func(); } + + catch ( const fs::filesystem_error & ex ) + { + if ( report_throws ) + { + // use the what() convenience function to display exceptions + std::cout << "\n" << ex.what() << "\n"; + } + if ( en == 0 + || en == ex.code().default_error_condition().value() ) return true; + std::cout + << "\nWarning: line " << line + << " exception reports default_error_condition().value() " << ex.code().default_error_condition().value() + << ", should be " << en + << "\n value() is " << ex.code().value() + << std::endl; + return true; + } + return false; + } + + // compile-only two argument "do-the-right-thing" tests + // verifies that all overload combinations compile without error + void do_not_call() + { + fs::path p; + std::string s; + const char * a = 0; + fs::copy_file( p, p ); + fs::copy_file( s, p ); + fs::copy_file( a, p ); + fs::copy_file( p, s ); + fs::copy_file( p, a ); + fs::copy_file( s, s ); + fs::copy_file( a, s ); + fs::copy_file( s, a ); + fs::copy_file( a, a ); + } + + void exception_tests() + { + bool exception_thrown; + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( std::runtime_error x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + // the stdcxx standard library apparently appends additional info + // to what(), so check only the initial portion: + BOOST_TEST( std::strncmp( x.what(), + "boost::filesystem::create_directory", + sizeof("boost::filesystem::create_directory")-1 ) == 0 ); + } + BOOST_TEST( exception_thrown ); + + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( system_error x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + BOOST_TEST( std::strcmp( x.what(), + "boost::filesystem::create_directory: The system cannot find the path specified" ) == 0 ); + } + BOOST_TEST( exception_thrown ); + + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( fs::filesystem_error x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + { + bool ok ( std::strcmp( x.what(), + "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir\\foo\\bar\"" ) == 0 ); + BOOST_TEST( ok ); + if ( !ok ) + { + std::cout << "what returns \"" << x.what() << "\"" << std::endl; + } + } + } + BOOST_TEST( exception_thrown ); + + exception_thrown = false; + try + { + fs::create_directory( "no-such-dir/foo/bar" ); + } + catch ( const fs::filesystem_error & x ) + { + exception_thrown = true; + if ( report_throws ) std::cout << x.what() << std::endl; + if ( platform == "Windows" && language_id == 0x0409 ) // English (United States) + { + bool ok ( std::strcmp( x.what(), + "boost::filesystem::create_directory: The system cannot find the path specified: \"no-such-dir\\foo\\bar\"" ) == 0 ); + BOOST_TEST( ok ); + if ( !ok ) + { + std::cout << "what returns \"" << x.what() << "\"" << std::endl; + } + } + } + BOOST_TEST( exception_thrown ); + } + + void bad_file_size() + { + fs::file_size( " No way, Jose" ); + } + + void bad_directory_size() + { + fs::file_size( fs::current_path<fs::path>() ); + } + + fs::path bad_create_directory_path; + void bad_create_directory() + { + fs::create_directory( bad_create_directory_path ); + } + + void bad_equivalent() + { + fs::equivalent( "no-such-path", "another-not-present-path" ); + } + + fs::path bad_remove_dir; + void bad_remove() + { + fs::remove( bad_remove_dir ); + } + + class renamer + { + public: + renamer( const fs::path & p1, const fs::path & p2 ) + : from(p1), to(p2) {} + void operator()() + { + fs::rename( from, to ); + } + private: + fs::path from; + fs::path to; + }; + +} // unnamed namespace + +// main ------------------------------------------------------------------------------// + +int main( int argc, char * argv[] ) +{ + if ( argc > 1 && *argv[1]=='-' && *(argv[1]+1)=='t' ) report_throws = true; + + // The choice of platform is make at runtime rather than compile-time + // so that compile errors for all platforms will be detected even though + // only the current platform is runtime tested. +# if defined( BOOST_POSIX_API ) + platform = "POSIX"; +# elif defined( BOOST_WINDOWS_API ) + platform = "Windows"; +# if !defined(__MINGW32__) && !defined(__CYGWIN__) + language_id = ::GetUserDefaultUILanguage(); +# else + language_id = 0x0409; // Assume US English +# endif +# else + platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" ) + ? "Windows" + : "POSIX"; +# endif + std::cout << "API is " << platform << std::endl; + + exception_tests(); + + std::cout << "\ninitial_path<path>().string() is\n \"" + << fs::initial_path<fs::path>().string() + << "\"\n"; + std::cout << "\ninitial_path<fs::path>().file_string() is\n \"" + << fs::initial_path<fs::path>().file_string() + << "\"\n\n"; + BOOST_TEST( fs::initial_path<fs::path>().is_complete() ); + BOOST_TEST( fs::current_path<fs::path>().is_complete() ); + BOOST_TEST( fs::initial_path<fs::path>().string() + == fs::current_path<fs::path>().string() ); + + BOOST_TEST( fs::complete( "" ).empty() ); + BOOST_TEST( fs::complete( "/" ).string() == fs::initial_path<fs::path>().root_path().string() ); + BOOST_TEST( fs::complete( "foo" ).string() == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::complete( "/foo" ).string() == fs::initial_path<fs::path>().root_path().string()+"foo" ); + BOOST_TEST( fs::complete( "foo", fs::path( "//net/bar" ) ).string() + == "//net/bar/foo" ); + + // predicate and status tests + BOOST_TEST( fs::exists( "/" ) ); + fs::path ng( " no-way, Jose" ); + BOOST_TEST( !fs::exists( ng ) ); + BOOST_TEST( !fs::is_directory( ng ) ); + BOOST_TEST( !fs::is_regular_file( ng ) ); + BOOST_TEST( !fs::is_symlink( ng ) ); + fs::file_status stat( fs::status( ng ) ); + BOOST_TEST( fs::status_known( stat ) ); + BOOST_TEST( !fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + stat = fs::status( "" ); + BOOST_TEST( fs::status_known( stat ) ); + BOOST_TEST( !fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + + fs::path dir( fs::initial_path<fs::path>() / temp_dir_name ); + + if ( fs::exists( dir ) ) + fs::remove_all( dir ); // remove residue from prior failed tests + BOOST_TEST( !fs::exists( dir ) ); + + // create a directory, then check it for consistency + // take extra care to report problems, since if this fails + // many subsequent tests will fail + try + { + fs::create_directory( dir ); + } + + catch ( const fs::filesystem_error & x ) + { + std::cout << x.what() << "\n\n" + "***** Creating directory " << dir.string() << " failed. *****\n" + "***** This is a serious error that will prevent further tests *****\n" + "***** from returning useful results. Further testing is aborted. *****\n\n"; + return 1; + } + + catch ( ... ) + { + std::cout << "\n\n" + "***** Creating directory " << dir.string() << " failed. *****\n" + "***** This is a serious error that will prevent further tests *****\n" + "***** from returning useful results. Further testing is aborted. *****\n\n"; + return 1; + } + + BOOST_TEST( fs::exists( dir ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( dir ) ); + BOOST_TEST( fs::is_directory( dir ) ); + BOOST_TEST( !fs::is_regular_file( dir ) ); + BOOST_TEST( !fs::is_other( dir ) ); + BOOST_TEST( !fs::is_symlink( dir ) ); + stat = fs::status( dir ); + BOOST_TEST( fs::exists( stat ) ); + BOOST_TEST( fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + + // Windows only tests + if ( platform == "Windows" ) + { + BOOST_TEST( !fs::exists( fs::path( "//share-not" ) ) ); + BOOST_TEST( !fs::exists( fs::path( "//share-not/" ) ) ); + BOOST_TEST( !fs::exists( fs::path( "//share-not/foo" ) ) ); + BOOST_TEST( !fs::exists( "tools/jam/src/:sys:stat.h" ) ); // !exists() if ERROR_INVALID_NAME + BOOST_TEST( !fs::exists( ":sys:stat.h" ) ); // !exists() if ERROR_INVALID_PARAMETER + BOOST_TEST( !fs::exists( "1:/" ) ); + BOOST_TEST( dir.string().size() > 1 + && dir.string()[1] == ':' ); // verify path includes drive + + BOOST_TEST( fs::system_complete( "" ).empty() ); + BOOST_TEST( fs::system_complete( "/" ).string() + == fs::initial_path<fs::path>().root_path().string() ); + BOOST_TEST( fs::system_complete( "foo" ).string() + == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::system_complete( "/foo" ).string() + == fs::initial_path<fs::path>().root_path().string()+"foo" ); + BOOST_TEST( fs::complete( fs::path( "c:/" ) ).string() + == "c:/" ); + BOOST_TEST( fs::complete( fs::path( "c:/foo" ) ).string() + == "c:/foo" ); + + BOOST_TEST( fs::system_complete( fs::path( fs::initial_path<fs::path>().root_name() ) ).string() == fs::initial_path<fs::path>().string() ); + BOOST_TEST( fs::system_complete( fs::path( fs::initial_path<fs::path>().root_name() + + "foo" ) ).string() == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::system_complete( fs::path( "c:/" ) ).string() + == "c:/" ); + BOOST_TEST( fs::system_complete( fs::path( "c:/foo" ) ).string() + == "c:/foo" ); + BOOST_TEST( fs::system_complete( fs::path( "//share" ) ).string() + == "//share" ); + } // Windows + + else if ( platform == "POSIX" ) + { + BOOST_TEST( fs::system_complete( "" ).empty() ); + BOOST_TEST( fs::initial_path<fs::path>().root_path().string() == "/" ); + BOOST_TEST( fs::system_complete( "/" ).string() == "/" ); + BOOST_TEST( fs::system_complete( "foo" ).string() + == fs::initial_path<fs::path>().string()+"/foo" ); + BOOST_TEST( fs::system_complete( "/foo" ).string() + == fs::initial_path<fs::path>().root_path().string()+"foo" ); + } // POSIX + + // the bound functions should throw, so CHECK_EXCEPTION() should return true + BOOST_TEST( CHECK_EXCEPTION( bad_file_size, ENOENT ) ); + + // test path::exception members + try { fs::file_size( ng ); } // will throw + + catch ( const fs::filesystem_error & ex ) + { + BOOST_TEST( ex.path1().string() == " no-way, Jose" ); + } + // several functions give unreasonable results if uintmax_t isn't 64-bits + std::cout << "sizeof(boost::uintmax_t) = " << sizeof(boost::uintmax_t) << '\n'; + BOOST_TEST( sizeof( boost::uintmax_t ) >= 8 ); + + // set the current directory, then check it for consistency + fs::path original_dir = fs::current_path<fs::path>(); + BOOST_TEST( dir != original_dir ); + fs::current_path( dir ); + BOOST_TEST( fs::current_path<fs::path>() == dir ); + BOOST_TEST( fs::current_path<fs::path>() != original_dir ); + fs::current_path( original_dir ); + BOOST_TEST( fs::current_path<fs::path>() == original_dir ); + BOOST_TEST( fs::current_path<fs::path>() != dir ); + // make sure the overloads work + fs::current_path( dir.string().c_str() ); + BOOST_TEST( fs::current_path<fs::path>() == dir ); + BOOST_TEST( fs::current_path<fs::path>() != original_dir ); + fs::current_path( original_dir.string() ); + BOOST_TEST( fs::current_path<fs::path>() == original_dir ); + BOOST_TEST( fs::current_path<fs::path>() != dir ); + + // make some reasonable assuptions for testing purposes + fs::space_info spi( fs::space( dir ) ); + BOOST_TEST( spi.capacity > 1000000 ); + BOOST_TEST( spi.free > 1000 ); + BOOST_TEST( spi.capacity > spi.free ); + BOOST_TEST( spi.free >= spi.available ); + + // it is convenient to display space, but older VC++ versions choke +# if !defined(BOOST_MSVC) || _MSC_VER >= 1300 // 1300 == VC++ 7.0 + std::cout << " capacity = " << spi.capacity << '\n'; + std::cout << " free = " << spi.free << '\n'; + std::cout << "available = " << spi.available << '\n'; +# endif + + if ( platform == "Windows" ) + BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, ENOENT ) ); + else + BOOST_TEST( CHECK_EXCEPTION( bad_directory_size, 0 ) ); + BOOST_TEST( !fs::create_directory( dir ) ); + + BOOST_TEST( !fs::is_symlink( dir ) ); + BOOST_TEST( !fs::is_symlink( "nosuchfileordirectory" ) ); + + fs::path d1( dir / "d1" ); + BOOST_TEST( fs::create_directory( d1 ) ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::is_directory( d1 ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( d1 ) ); + +// boost::function_requires< boost::InputIteratorConcept< fs::directory_iterator > >(); + + bool dir_itr_exception(false); + try { fs::directory_iterator it( "" ); } + catch ( const fs::filesystem_error & ) { dir_itr_exception = true; } + BOOST_TEST( dir_itr_exception ); + + dir_itr_exception = false; + try { fs::directory_iterator it( "nosuchdirectory" ); } + catch ( const fs::filesystem_error & ) { dir_itr_exception = true; } + BOOST_TEST( dir_itr_exception ); + + dir_itr_exception = false; + try + { + error_code ec; + fs::directory_iterator it( "nosuchdirectory", ec ); + BOOST_TEST( ec ); + BOOST_TEST( ec == fs::detail::not_found_error() ); + } + catch ( const fs::filesystem_error & ) { dir_itr_exception = true; } + BOOST_TEST( !dir_itr_exception ); + + { + // probe query function overloads + fs::directory_iterator dir_itr( dir ); + BOOST_TEST( fs::is_directory( *dir_itr ) ); + BOOST_TEST( fs::is_directory( dir_itr->status() ) ); + BOOST_TEST( fs::is_directory( fs::symlink_status(*dir_itr) ) ); + BOOST_TEST( fs::is_directory( dir_itr->symlink_status() ) ); + BOOST_TEST( dir_itr->path().filename() == "d1" ); + } + + // create a second directory named d2 + fs::path d2( dir / "d2" ); + fs::create_directory(d2 ); + BOOST_TEST( fs::exists( d2 ) ); + BOOST_TEST( fs::is_directory( d2 ) ); + + // test the basic operation of directory_iterators, and test that + // stepping one iterator doesn't affect a different iterator. + { + fs::directory_iterator dir_itr( dir ); + BOOST_TEST( fs::exists(dir_itr->status()) ); + BOOST_TEST( fs::is_directory(dir_itr->status()) ); + BOOST_TEST( !fs::is_regular_file(dir_itr->status()) ); + BOOST_TEST( !fs::is_other(dir_itr->status()) ); + BOOST_TEST( !fs::is_symlink(dir_itr->status()) ); + + fs::directory_iterator dir_itr2( dir ); + BOOST_TEST( dir_itr->path().filename() == "d1" + || dir_itr->path().filename() == "d2" ); + BOOST_TEST( dir_itr2->path().filename() == "d1" || dir_itr2->path().filename() == "d2" ); + if ( dir_itr->path().filename() == "d1" ) + { + BOOST_TEST( (++dir_itr)->path().filename() == "d2" ); + BOOST_TEST( dir_itr2->path().filename() == "d1" ); + BOOST_TEST( (++dir_itr2)->path().filename() == "d2" ); + } + else + { + BOOST_TEST( dir_itr->path().filename() == "d2" ); + BOOST_TEST( (++dir_itr)->path().filename() == "d1" ); + BOOST_TEST( (dir_itr2)->path().filename() == "d2" ); + BOOST_TEST( (++dir_itr2)->path().filename() == "d1" ); + } + BOOST_TEST( ++dir_itr == fs::directory_iterator() ); + BOOST_TEST( dir_itr2 != fs::directory_iterator() ); + BOOST_TEST( ++dir_itr2 == fs::directory_iterator() ); + } + + { // *i++ must work to meet the standard's InputIterator requirements + fs::directory_iterator dir_itr( dir ); + BOOST_TEST( dir_itr->path().filename() == "d1" + || dir_itr->path().filename() == "d2" ); + if ( dir_itr->path().filename() == "d1" ) + { + BOOST_TEST( (*dir_itr++).path().filename() == "d1" ); + BOOST_TEST( dir_itr->path().filename() == "d2" ); + } + else + { + // Check C++98 input iterator requirements + BOOST_TEST( (*dir_itr++).path().filename() == "d2" ); + // input iterator requirements in the current WP would require this check: + // BOOST_TEST( implicit_cast<std::string const&>(*dir_itr++).filename() == "d1" ); + + BOOST_TEST( dir_itr->path().filename() == "d1" ); + } + + // test case reported in comment to SourceForge bug tracker [937606] + fs::directory_iterator it( dir ); + const fs::path p1 = *it++; + BOOST_TEST( it != fs::directory_iterator() ); + const fs::path p2 = *it++; + BOOST_TEST( p1 != p2 ); + BOOST_TEST( it == fs::directory_iterator() ); + } + + // Windows has a tricky special case when just the root-name is given, + // causing the rest of the path to default to the current directory. + // Reported as S/F bug [ 1259176 ] + if ( platform == "Windows" ) + { + fs::path root_name_path( fs::current_path<fs::path>().root_name() ); + fs::directory_iterator it( root_name_path ); + BOOST_TEST( it != fs::directory_iterator() ); + BOOST_TEST( fs::exists( *it ) ); + BOOST_TEST( it->path().parent_path() == root_name_path ); + bool found(false); + do + { + if ( it->path().filename() == temp_dir_name ) found = true; + } while ( ++it != fs::directory_iterator() ); + BOOST_TEST( found ); + } + + // create an empty file named "f0" + fs::path file_ph( dir / "f0"); + create_file( file_ph, "" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( file_ph ) ); + BOOST_TEST( fs::file_size( file_ph ) == 0 ); + bad_create_directory_path = file_ph; + BOOST_TEST( CHECK_EXCEPTION( bad_create_directory, EEXIST ) ); + stat = fs::status( file_ph ); + BOOST_TEST( fs::status_known( stat ) ); + BOOST_TEST( fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( !fs::is_symlink( stat ) ); + + // create a file named "f1" + file_ph = dir / "f1"; + create_file( file_ph, "foobar1" ); + + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + BOOST_TEST( fs::file_size( file_ph ) == 7 ); + verify_file( file_ph, "foobar1" ); + + // equivalence tests + BOOST_TEST( CHECK_EXCEPTION( bad_equivalent, ENOENT ) ); + BOOST_TEST( fs::equivalent( file_ph, dir / "f1" ) ); + BOOST_TEST( fs::equivalent( dir, d1 / ".." ) ); + BOOST_TEST( !fs::equivalent( file_ph, dir ) ); + BOOST_TEST( !fs::equivalent( dir, file_ph ) ); + BOOST_TEST( !fs::equivalent( d1, d2 ) ); + BOOST_TEST( !fs::equivalent( dir, ng ) ); + BOOST_TEST( !fs::equivalent( ng, dir ) ); + BOOST_TEST( !fs::equivalent( file_ph, ng ) ); + BOOST_TEST( !fs::equivalent( ng, file_ph ) ); + + // hard link tests + fs::path from_ph( dir / "f3" ); + BOOST_TEST( !fs::exists( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + bool create_hard_link_ok(true); + try { fs::create_hard_link( file_ph, from_ph ); } + catch ( const fs::filesystem_error & ex ) + { + create_hard_link_ok = false; + std::cout + << "create_hard_link() attempt failed\n" + << "filesystem_error.what() reports: " << ex.what() << '\n' + << "create_hard_link() may not be supported on this file system\n"; + } + + if ( create_hard_link_ok ) + { + std::cout << "create_hard_link(\"" << file_ph << "\", \"" + << from_ph << "\") succeeded\n"; + BOOST_TEST( fs::exists( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( fs::equivalent( from_ph, file_ph ) ); + } + + error_code ec; + BOOST_TEST( fs::create_hard_link( fs::path("doesnotexist"), + fs::path("shouldnotwork"), ec ) ); + BOOST_TEST( ec ); + + // symbolic link tests + from_ph = dir / "f4"; + BOOST_TEST( !fs::exists( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + bool create_symlink_ok(true); + try { fs::create_symlink( file_ph, from_ph ); } + catch ( const fs::filesystem_error & ex ) + { + create_symlink_ok = false; + std::cout + << "create_symlink() attempt failed\n" + << "filesystem_error.what() reports: " << ex.what() << '\n' + << "create_symlink() may not be supported on this file system\n"; + } + + if ( create_symlink_ok ) + { + std::cout << "create_symlink() succeeded\n"; + BOOST_TEST( fs::exists( from_ph ) ); + BOOST_TEST( fs::is_symlink( from_ph ) ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( fs::equivalent( from_ph, file_ph ) ); + stat = fs::symlink_status( from_ph ); + BOOST_TEST( fs::exists( stat ) ); + BOOST_TEST( !fs::is_directory( stat ) ); + BOOST_TEST( !fs::is_regular_file( stat ) ); + BOOST_TEST( !fs::is_other( stat ) ); + BOOST_TEST( fs::is_symlink( stat ) ); + } + + ec = error_code(); + BOOST_TEST( fs::create_symlink( "doesnotexist", "", ec ) ); + BOOST_TEST( ec ); + + // there was an inital bug in directory_iterator that caused premature + // close of an OS handle. This block will detect regression. + { + fs::directory_iterator di; + { di = fs::directory_iterator( dir ); } + BOOST_TEST( ++di != fs::directory_iterator() ); + } + + // copy_file() tests + std::cout << "begin copy_file test..." << std::endl; + fs::copy_file( file_ph, d1 / "f2" ); + std::cout << "copying complete" << std::endl; + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::is_directory( d1 / "f2" ) ); + verify_file( d1 / "f2", "foobar1" ); + + bool copy_ex_ok = false; + try { fs::copy_file( file_ph, d1 / "f2" ); } + catch ( const fs::filesystem_error & ) { copy_ex_ok = true; } + BOOST_TEST( copy_ex_ok ); + + copy_ex_ok = false; + try { fs::copy_file( file_ph, d1 / "f2", fs::copy_option::fail_if_exists ); } + catch ( const fs::filesystem_error & ) { copy_ex_ok = true; } + BOOST_TEST( copy_ex_ok ); + + copy_ex_ok = true; + try { fs::copy_file( file_ph, d1 / "f2", fs::copy_option::overwrite_if_exists ); } + catch ( const fs::filesystem_error & ) { copy_ex_ok = false; } + BOOST_TEST( copy_ex_ok ); + + std::cout << "copy_file test complete" << std::endl; + + // rename() test case numbers refer to operations.htm#rename table + + // [case 1] make sure can't rename() a non-existent file + BOOST_TEST( !fs::exists( d1 / "f99" ) ); + BOOST_TEST( !fs::exists( d1 / "f98" ) ); + renamer n1a( d1 / "f99", d1 / "f98" ); + BOOST_TEST( CHECK_EXCEPTION( n1a, ENOENT ) ); + renamer n1b( fs::path(""), d1 / "f98" ); + BOOST_TEST( CHECK_EXCEPTION( n1b, ENOENT ) ); + + // [case 2] rename() target.empty() + renamer n2( file_ph, "" ); + BOOST_TEST( CHECK_EXCEPTION( n2, ENOENT ) ); + + // [case 3] make sure can't rename() to an existent file or directory + BOOST_TEST( fs::exists( dir / "f1" ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + renamer n3a( dir / "f1", d1 / "f2" ); + BOOST_TEST( CHECK_EXCEPTION( n3a, EEXIST ) ); + // several POSIX implementations (cygwin, openBSD) report ENOENT instead of EEXIST, + // so we don't verify error type on the above test. + renamer n3b( dir, d1 ); + BOOST_TEST( CHECK_EXCEPTION( n3b, 0 ) ); + + // [case 4A] can't rename() file to a nonexistent parent directory + BOOST_TEST( !fs::is_directory( dir / "f1" ) ); + BOOST_TEST( !fs::exists( dir / "d3/f3" ) ); + renamer n4a( dir / "f1", dir / "d3/f3" ); + BOOST_TEST( CHECK_EXCEPTION( n4a, ENOENT ) ); + + // [case 4B] rename() file in same directory + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d1 / "f50" ) ); + fs::rename( d1 / "f2", d1 / "f50" ); + BOOST_TEST( !fs::exists( d1 / "f2" ) ); + BOOST_TEST( fs::exists( d1 / "f50" ) ); + fs::rename( d1 / "f50", d1 / "f2" ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d1 / "f50" ) ); + + // [case 4C] rename() file d1/f2 to d2/f3 + fs::rename( d1 / "f2", d2 / "f3" ); + BOOST_TEST( !fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d2 / "f2" ) ); + BOOST_TEST( fs::exists( d2 / "f3" ) ); + BOOST_TEST( !fs::is_directory( d2 / "f3" ) ); + verify_file( d2 / "f3", "foobar1" ); + fs::rename( d2 / "f3", d1 / "f2" ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + + // [case 5A] rename() directory to nonexistent parent directory + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( !fs::exists( dir / "d3/d5" ) ); + BOOST_TEST( !fs::exists( dir / "d3" ) ); + renamer n5a( d1, dir / "d3/d5" ); + BOOST_TEST( CHECK_EXCEPTION( n5a, ENOENT ) ); + + // [case 5B] rename() on directory + fs::path d3( dir / "d3" ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d3 ) ); + fs::rename( d1, d3 ); + BOOST_TEST( !fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d3 ) ); + BOOST_TEST( fs::is_directory( d3 ) ); + BOOST_TEST( !fs::exists( d1 / "f2" ) ); + BOOST_TEST( fs::exists( d3 / "f2" ) ); + fs::rename( d3, d1 ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + BOOST_TEST( !fs::exists( d3 ) ); + + // [case 5C] rename() rename and move d1 to d2 / "d20" + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( !fs::exists( d2 / "d20" ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + fs::rename( d1, d2 / "d20" ); + BOOST_TEST( !fs::exists( d1 ) ); + BOOST_TEST( fs::exists( d2 / "d20" ) ); + BOOST_TEST( fs::exists( d2 / "d20" / "f2" ) ); + fs::rename( d2 / "d20", d1 ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( !fs::exists( d2 / "d20" ) ); + BOOST_TEST( fs::exists( d1 / "f2" ) ); + + // remove() file + file_ph = dir / "shortlife"; + BOOST_TEST( !fs::exists( file_ph ) ); + create_file( file_ph, "" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::remove( file_ph ) ); + BOOST_TEST( !fs::exists( file_ph ) ); + BOOST_TEST( !fs::remove( "no-such-file" ) ); + BOOST_TEST( !fs::remove( "no-such-directory/no-such-file" ) ); + + // remove() directory + d1 = dir / "shortlife_dir"; + BOOST_TEST( !fs::exists( d1 ) ); + fs::create_directory( d1 ); + BOOST_TEST( fs::exists( d1 ) ); + BOOST_TEST( fs::is_directory( d1 ) ); + BOOST_TEST( BOOST_FS_IS_EMPTY( d1 ) ); + bad_remove_dir = dir; + BOOST_TEST( CHECK_EXCEPTION( bad_remove, ENOTEMPTY ) ); + BOOST_TEST( fs::remove( d1 ) ); + BOOST_TEST( !fs::exists( d1 ) ); + + if ( create_symlink_ok ) // only if symlinks supported + { + // remove() dangling symbolic link + fs::path link( "dangling_link" ); + fs::remove( link ); // remove any residue from past tests + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( !fs::exists( link ) ); + fs::create_symlink( "nowhere", link ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( fs::is_symlink( link ) ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + + // remove() self-refering symbolic link + link = "link_to_self"; + fs::remove( link ); // remove any residue from past tests + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( !fs::exists( link ) ); + fs::create_symlink( link, link ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + + // remove() cyclic symbolic link + link = "link_to_a"; + fs::path link2( "link_to_b" ); + fs::remove( link ); // remove any residue from past tests + fs::remove( link2 ); // remove any residue from past tests + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( !fs::exists( link ) ); + fs::create_symlink( link, link2 ); + fs::create_symlink( link2, link ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( fs::remove( link2 ) ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( !fs::exists( link2 ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + + // remove() symbolic link to file + file_ph = "link_target"; + fs::remove( file_ph ); // remove any residue from past tests + BOOST_TEST( !fs::exists( file_ph ) ); + create_file( file_ph, "" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + link = "non_dangling_link"; + fs::create_symlink( file_ph, link ); + BOOST_TEST( fs::exists( link ) ); + BOOST_TEST( !fs::is_directory( link ) ); + BOOST_TEST( fs::is_regular_file( link ) ); + BOOST_TEST( fs::is_symlink( link ) ); + BOOST_TEST( fs::remove( link ) ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::exists( link ) ); + BOOST_TEST( !fs::is_symlink( link ) ); + BOOST_TEST( fs::remove( file_ph ) ); + BOOST_TEST( !fs::exists( file_ph ) ); + } + + // write time tests + + file_ph = dir / "foobar2"; + create_file( file_ph, "foobar2" ); + BOOST_TEST( fs::exists( file_ph ) ); + BOOST_TEST( !fs::is_directory( file_ph ) ); + BOOST_TEST( fs::is_regular_file( file_ph ) ); + BOOST_TEST( fs::file_size( file_ph ) == 7 ); + verify_file( file_ph, "foobar2" ); + + // Some file system report last write time as local (FAT), while + // others (NTFS) report it as UTC. The C standard does not specify + // if time_t is local or UTC. + + std::time_t ft = fs::last_write_time( file_ph ); + std::cout << "\nUTC last_write_time() for a file just created is " + << std::asctime(std::gmtime(&ft)) << std::endl; + + std::tm * tmp = std::localtime( &ft ); + std::cout << "\nYear is " << tmp->tm_year << std::endl; + --tmp->tm_year; + std::cout << "Change year to " << tmp->tm_year << std::endl; + fs::last_write_time( file_ph, std::mktime( tmp ) ); + std::time_t ft2 = fs::last_write_time( file_ph ); + std::cout << "last_write_time() for the file is now " + << std::asctime(std::gmtime(&ft2)) << std::endl; + BOOST_TEST( ft != fs::last_write_time( file_ph ) ); + + + std::cout << "\nReset to current time" << std::endl; + fs::last_write_time( file_ph, ft ); + double time_diff = std::difftime( ft, fs::last_write_time( file_ph ) ); + std::cout + << "original last_write_time() - current last_write_time() is " + << time_diff << " seconds" << std::endl; + BOOST_TEST( time_diff >= -60.0 && time_diff <= 60.0 ); + + // post-test cleanup + BOOST_TEST( fs::remove_all( dir ) != 0 ); + // above was added just to simplify testing, but it ended up detecting + // a bug (failure to close an internal search handle). + BOOST_TEST( !fs::exists( dir ) ); + BOOST_TEST( fs::remove_all( dir ) == 0 ); + + return ::boost::report_errors(); +} // main + Added: trunk/dsim/test/boost/filesystem/path_test.cpp =================================================================== --- trunk/dsim/test/boost/filesystem/path_test.cpp (rev 0) +++ trunk/dsim/test/boost/filesystem/path_test.cpp 2009-12-31 13:33:35 UTC (rev 42) @@ -0,0 +1,1366 @@ +// path_test program -------------------------------------------------------// +// Copyright Beman Dawes 2002 +// Copyright Vladimir Prus 2002 +// Use, modification, and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) +// See library home page at http://www.boost.org/libs/filesystem +// basic_path's stem(), extension(), and replace_extension() tests are based +// on basename(), extension(), and change_extension() tests from the original +// convenience_test.cpp by Vladimir Prus. +// See deprecated_test for tests of deprecated features +#define BOOST_FILESYSTEM_NO_DEPRECATED +// STL +#include <iostream> +#include <sstream> +#include <string> +#include <vector> +#include <cstring> +#include <cassert> +// Boost +#include <boost/filesystem/operations.hpp> +#include <boost/utility.hpp> + +namespace fs = boost::filesystem; +using boost::filesystem::path; + + +#include <boost/detail/lightweight_test.hpp> + +#define PATH_CHECK( a, b ) check( a, b, __LINE__ ) +#define DIR_CHECK( a, b ) check_dir( a, b, __LINE__ ) +#define CHECK_EQUAL( a,b ) check_equal( a, b, __LINE__ ) + + +namespace { + + std::string platform( BOOST_PLATFORM ); + + void check( const fs::path & source, + const std::string & expected, int line ) + { + if ( source.string()== expected ) return; + + ++::boost::detail::test_errors(); + + std::cout << '(' << line << ") source.string(): \"" << source.string() + << "\" != expected: \"" << expected + << "\"" << std::endl; + } + + void check_dir( const fs::path & source, + const std::string & expected, int line ) + { + if ( source.directory_string()== expected ) return; + + ++::boost::detail::test_errors(); + + std::cout << '(' << line << ") source.directory_string(): \"" + << source.directory_string() + << "\" != expected: \"" << expected + << "\"" << std::endl; + } + + void check_equal( const std::string & value, + const std::string & expected, int line ) + { + if ( value == expected ) return; + + ++::boost::detail::test_errors(); + + std::cout << '(' << line << ") value: \"" << value + << "\" != expected: \"" << expected + << "\"" << std::endl; + } + + + void exception_tests() + { + const std::string str_1("string-1"); + boost::system::error_code ec( 12345, boost::system::system_category); + try { throw fs::filesystem_error( str_1, ec ); } + catch ( const fs::filesystem_error & ex ) + { + //std::cout << ex.what() << "*" << std::endl; + //BOOST_TEST( std::strcmp( ex.what(), + // "string-1: Unknown error" ) == 0 ); + BOOST_TEST( ex.code() == ec ); + } + + try { throw fs::filesystem_error( str_1, "p1", "p2", ec ); } + catch ( const fs::filesystem_error & ex ) + { + //std::cout << ex.what() << "*" << std::endl; + //BOOST_TEST( std::strcmp( ex.what(), + // "string-1: Unknown error: \"p1\", \"p2\"" ) == 0 ); + BOOST_TEST( ex.code() == ec ); + BOOST_TEST( ex.path1().string() == "p1" ); + BOOST_TEST( ex.path2().string() == "p2" ); + } + } + + + // name_function_tests ---------------------------------------------------// + + void name_function_tests() + { + std::cout << "name_function_tests..." << std::endl; + + BOOST_TEST( fs::portable_posix_name( std::string( "x" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "x" ) ) ); + BOOST_TEST( fs::portable_name( std::string( "x" ) ) ); + BOOST_TEST( fs::portable_directory_name( std::string( "x" ) ) ); + BOOST_TEST( fs::portable_file_name( std::string( "x" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "." ) ) ); + BOOST_TEST( fs::windows_name( std::string( "." ) ) ); + BOOST_TEST( fs::portable_name( std::string( "." ) ) ); + BOOST_TEST( fs::portable_directory_name( std::string( "." ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "." ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( ".." ) ) ); + BOOST_TEST( fs::windows_name( std::string( ".." ) ) ); + BOOST_TEST( fs::portable_name( std::string( ".." ) ) ); + BOOST_TEST( fs::portable_directory_name( std::string( ".." ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( ".." ) ) ); + + BOOST_TEST( !fs::native( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_posix_name( std::string( "" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "" ) ) ); + + BOOST_TEST( !fs::native( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_posix_name( std::string( " " ) ) ); + BOOST_TEST( !fs::windows_name( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_name( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( " " ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( " " ) ) ); + + BOOST_TEST( !fs::portable_posix_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( ":" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( ":" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "-" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "-" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "-" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "-" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "-" ) ) ); + + BOOST_TEST( !fs::portable_posix_name( std::string( "foo bar" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "foo bar" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( " bar" ) ) ); + BOOST_TEST( !fs::windows_name( std::string( "foo " ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "foo bar" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo bar" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "foo bar" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( fs::portable_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo.bar" ) ) ); + BOOST_TEST( fs::portable_file_name( std::string( "foo.bar" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( fs::windows_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( fs::portable_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo.barf" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "foo.barf" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( ".foo" ) ) ); + BOOST_TEST( fs::windows_name( std::string( ".foo" ) ) ); + BOOST_TEST( !fs::portable_name( std::string( ".foo" ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( ".foo" ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( ".foo" ) ) ); + + BOOST_TEST( fs::portable_posix_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::windows_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::portable_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::portable_directory_name( std::string( "foo." ) ) ); + BOOST_TEST( !fs::portable_file_name( std::string( "foo." ) ) ); + } + +} // unnamed namespace + +int main( int, char*[] ) +{ + // The choice of platform is make at runtime rather than compile-time + // so that compile errors for all platforms will be detected even though + // only the current platform is runtime tested. + platform = ( platform == "Win32" || platform == "Win64" || platform == "Cygwin" ) + ? "Windows" + : "POSIX"; + std::cout << "Platform is " << platform << '\n'; + + path p1( "fe/fi/fo/fum" ); + path p2( p1 ); + path p3; + BOOST_TEST( p1.string() != p3.string() ); + + // check each overload + BOOST_TEST( p1 != p3 ); + BOOST_TEST( p1 != p3.string() ); + BOOST_TEST( p1 != p3.string().c_str() ); + BOOST_TEST( p1.string() != p3 ); + BOOST_TEST( p1.string().c_str() != p3 ); + + p3 = p2; + BOOST_TEST( p1.string() == p3.string() ); + + // check each overload + BOOST_TEST( p1 == p3 ); + BOOST_TEST( p1 == p3.string() ); + BOOST_TEST( p1 == p3.string().c_str() ); + BOOST_TEST( p1.string() == p3 ); + BOOST_TEST( p1.string().c_str() == p3 ); + + path p4( "foobar" ); + BOOST_TEST( p4.string() == "foobar" ); + p4 = p4; // self-assignment + BOOST_TEST( p4.string() == "foobar" ); + + if ( platform == "Windows" ) + { + path p10 ("c:\\file"); + path p11 ("c:/file"); + // check each overload + BOOST_TEST( p10.string() == p11.string() ); + BOOST_TEST( p10 == p11 ); + BOOST_TEST( p10 == p11.string() ); + BOOST_TEST( p10 == p11.string().c_str() ); + BOOST_TEST( p10.string() == p11 ); + BOOST_TEST( p10.string().c_str() == p11 ); + BOOST_TEST( p10 == "c:\\file" ); + BOOST_TEST( p10 == "c:/file" ); + BOOST_TEST( p11 == "c:\\file" ); + BOOST_TEST( p11 == "c:/file" ); + BOOST_TEST( "c:\\file" == p10 ); + BOOST_TEST( "c:/file" == p10 ); + BOOST_TEST( "c:\\file" == p11 ); + BOOST_TEST( "c:/file" == p11 ); + } + + exception_tests(); + name_function_tests(); + + // These verify various overloads don't cause compiler errors + + fs::exists( p1 ); + fs::exists( "foo" ); + fs::exists( std::string( "foo" ) ); + + fs::exists( p1 / path( "foo" ) ); + fs::exists( p1 / "foo" ); + fs::ex... [truncated message content] |
From: <den...@us...> - 2010-01-01 18:55:24
|
Revision: 43 http://dsim.svn.sourceforge.net/dsim/?rev=43&view=rev Author: denis_arnaud Date: 2010-01-01 18:55:18 +0000 (Fri, 01 Jan 2010) Log Message: ----------- [Struct] The parsing of the input schedule file is now done during the initialisation. Modified Paths: -------------- trunk/dsim/dsim/DSIM_Service.hpp trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/test/dsim/simulate.cpp Modified: trunk/dsim/dsim/DSIM_Service.hpp =================================================================== --- trunk/dsim/dsim/DSIM_Service.hpp 2009-12-31 13:33:35 UTC (rev 42) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-01-01 18:55:18 UTC (rev 43) @@ -5,8 +5,10 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STL -#include <ostream> +#include <iosfwd> #include <string> +// StdAir +#include <stdair/STDAIR_Types.hpp> // Dsim #include <dsim/DSIM_Types.hpp> @@ -27,8 +29,9 @@ public: // ////////// Constructors and destructors ////////// /** Constructor. - @param std::ostream& Output log stream (for instance, std::cout). */ - DSIM_Service (const std::string&, std::ostream& ioLogStream); + @param std::ostream& Output log stream (for instance, std::cout). + @param const stdair::Filename_T& Filename of the input schedule file. */ + DSIM_Service (std::ostream& ioLogStream, const stdair::Filename_T&); /** Destructor. */ ~DSIM_Service(); @@ -41,8 +44,10 @@ /** Default copy constructor. */ DSIM_Service (const DSIM_Service&); - /** Initialise. */ - void init (const std::string&, std::ostream& ioLogStream); + /** Initialise. + @param std::ostream& Output log stream (for instance, std::cout). + @param const stdair::Filename_T& Filename of the input schedule file. */ + void init (std::ostream& ioLogStream, const stdair::Filename_T&); /** Finalise. */ void finalise (); Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2009-12-31 13:33:35 UTC (rev 42) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-01 18:55:18 UTC (rev 43) @@ -3,6 +3,7 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <cassert> +#include <ostream> // Boost #include <boost/date_time/gregorian/gregorian.hpp> #include <boost/date_time/posix_time/ptime.hpp> @@ -21,15 +22,14 @@ // ////////////////////////////////////////////////////////////////////// DSIM_Service:: - DSIM_Service (const std::string& iScheduleInputFilename, - std::ostream& ioLogStream) + DSIM_Service (std::ostream& ioLogStream, + const stdair::Filename_T& iScheduleInputFilename) : _dsimServiceContext (NULL) { - init (iScheduleInputFilename, ioLogStream); + init (ioLogStream, iScheduleInputFilename); } // ////////////////////////////////////////////////////////////////////// - DSIM_Service::DSIM_Service () - : _dsimServiceContext (NULL) { + DSIM_Service::DSIM_Service () : _dsimServiceContext (NULL) { assert (false); } @@ -51,8 +51,8 @@ } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::init (const std::string& iScheduleInputFilename, - std::ostream& ioLogStream) { + void DSIM_Service::init (std::ostream& ioLogStream, + const stdair::Filename_T& iScheduleInputFilename) { // Set the log file logInit (LOG::DEBUG, ioLogStream); @@ -65,6 +65,10 @@ // configuration file). // Initialise the SIMCRS service handler const SIMCRS::CRSCode_T lCRSCode = "1S"; + + // Note that the (Boost.)Smart Pointer keeps track of the references + // on the Service object, and deletes that object when it is no longer + // referenced (e.g., at the end of the process). SIMCRS_ServicePtr_T lSIMCRS_Service = SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (ioLogStream, lCRSCode, iScheduleInputFilename)); Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2009-12-31 13:33:35 UTC (rev 42) +++ trunk/dsim/test/dsim/simulate.cpp 2010-01-01 18:55:18 UTC (rev 43) @@ -26,7 +26,7 @@ logOutputFile.clear(); // Initialise the list of classes/buckets - DSIM::DSIM_Service dsimService (lScheduleInputFilename, logOutputFile); + DSIM::DSIM_Service dsimService (logOutputFile, lScheduleInputFilename); // Perform a simulation dsimService.simulate(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-20 20:11:06
|
Revision: 51 http://dsim.svn.sourceforge.net/dsim/?rev=51&view=rev Author: denis_arnaud Date: 2010-01-20 20:11:00 +0000 (Wed, 20 Jan 2010) Log Message: ----------- [Dev] Moved the Log service into the StdAir library. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/dsim/core/Makefile.am Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-01-20 17:24:13 UTC (rev 50) +++ trunk/dsim/configure.ac 2010-01-20 20:11:00 UTC (rev 51) @@ -406,6 +406,7 @@ stdair/bom/Makefile stdair/factory/Makefile stdair/config/Makefile + stdair/service/Makefile stdair/core/Makefile trademgen/Makefile trademgen/basic/Makefile Modified: trunk/dsim/dsim/core/Makefile.am =================================================================== --- trunk/dsim/dsim/core/Makefile.am 2010-01-20 17:24:13 UTC (rev 50) +++ trunk/dsim/dsim/core/Makefile.am 2010-01-20 20:11:00 UTC (rev 51) @@ -20,9 +20,8 @@ $(top_builddir)/dsim/command/libcmd.la \ $(top_builddir)/dsim/service/libsvc.la libdsim_la_LDFLAGS = \ - $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ + $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ + $(top_builddir)/stdair/core/libstdair.la \ + $(top_builddir)/airsched/core/libairsched.la \ + $(top_builddir)/simcrs/core/libsimcrs.la \ -version-info $(GENERIC_LIBRARY_VERSION) - -# Header files -#pkginclude_HEADERS = $(service_h_sources) -#nobase_nodist_pkginclude_HEADERS = $(top_builddir)/dsim/config.h This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-21 13:25:25
|
Revision: 52 http://dsim.svn.sourceforge.net/dsim/?rev=52&view=rev Author: denis_arnaud Date: 2010-01-21 13:25:10 +0000 (Thu, 21 Jan 2010) Log Message: ----------- [Dev] The log output stream initialisation has been moved into the StdAir library. Modified Paths: -------------- trunk/dsim/dsim/DSIM_Service.hpp trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/test/dsim/simulate.cpp Modified: trunk/dsim/dsim/DSIM_Service.hpp =================================================================== --- trunk/dsim/dsim/DSIM_Service.hpp 2010-01-20 20:11:00 UTC (rev 51) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-01-21 13:25:10 UTC (rev 52) @@ -4,11 +4,9 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// STL -#include <iosfwd> -#include <string> // StdAir #include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> // Dsim #include <dsim/DSIM_Types.hpp> @@ -29,10 +27,25 @@ public: // ////////// Constructors and destructors ////////// /** Constructor. - @param std::ostream& Output log stream (for instance, std::cout). + <br>The init() method is called; see the corresponding documentation + for more details. + <br>Moreover, a reference on an output stream is given, so + that log outputs can be directed onto that stream. + @param const stdair::BasLogParams& Parameters for the output log stream. @param const stdair::Filename_T& Filename of the input schedule file. */ - DSIM_Service (std::ostream& ioLogStream, const stdair::Filename_T&); + DSIM_Service (const stdair::BasLogParams&, const stdair::Filename_T&); + /** Constructor. + <br>The init() method is called; see the corresponding documentation + for more details. + <br>Moreover, as no reference on any output stream is given, + it is assumed that the StdAir log service has already been + initialised with the proper log output stream by some other + methods in the calling chain (for instance, when the DSIM_Service + is itself being initialised by another library service). + @param const stdair::Filename_T& Filename of the input schedule file. */ + DSIM_Service (const stdair::Filename_T&); + /** Destructor. */ ~DSIM_Service(); @@ -44,10 +57,12 @@ /** Default copy constructor. */ DSIM_Service (const DSIM_Service&); + /** Initialise the log. */ + void logInit (const stdair::BasLogParams&); + /** Initialise. - @param std::ostream& Output log stream (for instance, std::cout). @param const stdair::Filename_T& Filename of the input schedule file. */ - void init (std::ostream& ioLogStream, const stdair::Filename_T&); + void init (const stdair::Filename_T&); /** Finalise. */ void finalise (); Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-20 20:11:00 UTC (rev 51) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-01-21 13:25:10 UTC (rev 52) @@ -4,11 +4,10 @@ // STL #include <cassert> #include <ostream> -// Boost -#include <boost/date_time/gregorian/gregorian.hpp> -#include <boost/date_time/posix_time/ptime.hpp> // StdAir #include <stdair/basic/BasChronometer.hpp> +#include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/service/Logger.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> // Dsim @@ -16,20 +15,11 @@ #include <dsim/command/Simulator.hpp> #include <dsim/factory/FacDsimServiceContext.hpp> #include <dsim/service/DSIM_ServiceContext.hpp> -#include <dsim/service/Logger.hpp> #include <dsim/DSIM_Service.hpp> namespace DSIM { // ////////////////////////////////////////////////////////////////////// - DSIM_Service:: - DSIM_Service (std::ostream& ioLogStream, - const stdair::Filename_T& iScheduleInputFilename) - : _dsimServiceContext (NULL) { - init (ioLogStream, iScheduleInputFilename); - } - - // ////////////////////////////////////////////////////////////////////// DSIM_Service::DSIM_Service () : _dsimServiceContext (NULL) { assert (false); } @@ -40,23 +30,38 @@ } // ////////////////////////////////////////////////////////////////////// + DSIM_Service::DSIM_Service (const stdair::Filename_T& iScheduleInputFilename) + : _dsimServiceContext (NULL) { + + // Initialise the context + init (iScheduleInputFilename); + } + + // ////////////////////////////////////////////////////////////////////// + DSIM_Service::DSIM_Service (const stdair::BasLogParams& iLogParams, + const stdair::Filename_T& iScheduleInputFilename) + : _dsimServiceContext (NULL) { + + // Set the log file + logInit (iLogParams); + + // Initialise the (remaining of the) context + init (iScheduleInputFilename); + } + + // ////////////////////////////////////////////////////////////////////// DSIM_Service::~DSIM_Service () { // Delete/Clean all the objects from memory finalise(); } // ////////////////////////////////////////////////////////////////////// - void logInit (const LOG::EN_LogLevel iLogLevel, - std::ostream& ioLogOutputFile) { - Logger::instance().setLogParameters (iLogLevel, ioLogOutputFile); + void DSIM_Service::logInit (const stdair::BasLogParams& iLogParams) { + stdair::Logger::init (iLogParams); } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::init (std::ostream& ioLogStream, - const stdair::Filename_T& iScheduleInputFilename) { - // Set the log file - logInit (LOG::DEBUG, ioLogStream); - + void DSIM_Service::init (const stdair::Filename_T& iScheduleInputFilename) { // Initialise the context DSIM_ServiceContext& lDSIM_ServiceContext = FacDsimServiceContext::instance().create (); @@ -71,7 +76,7 @@ // on the Service object, and deletes that object when it is no longer // referenced (e.g., at the end of the process). SIMCRS_ServicePtr_T lSIMCRS_Service = - SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (ioLogStream, lCRSCode, + SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (lCRSCode, iScheduleInputFilename)); lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service); } @@ -103,11 +108,11 @@ const double lSimulationMeasure = lSimulationChronometer.elapsed(); // DEBUG - DSIM_LOG_DEBUG ("Simulation: " << lSimulationMeasure << " - " - << lDSIM_ServiceContext.display()); + STDAIR_LOG_DEBUG ("Simulation: " << lSimulationMeasure << " - " + << lDSIM_ServiceContext.display()); } catch (const std::exception& error) { - DSIM_LOG_ERROR ("Exception: " << error.what()); + STDAIR_LOG_ERROR ("Exception: " << error.what()); throw SimulationException(); } } Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2010-01-20 20:11:00 UTC (rev 51) +++ trunk/dsim/test/dsim/simulate.cpp 2010-01-21 13:25:10 UTC (rev 52) @@ -26,7 +26,8 @@ logOutputFile.clear(); // Initialise the list of classes/buckets - DSIM::DSIM_Service dsimService (logOutputFile, lScheduleInputFilename); + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + DSIM::DSIM_Service dsimService (lLogParams, lScheduleInputFilename); // Perform a simulation dsimService.simulate(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-01-29 15:59:39
|
Revision: 57 http://dsim.svn.sourceforge.net/dsim/?rev=57&view=rev Author: denis_arnaud Date: 2010-01-29 15:59:32 +0000 (Fri, 29 Jan 2010) Log Message: ----------- [Test] Added test on Boost.SmartPointers. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/boost/Makefile.am Added Paths: ----------- trunk/dsim/test/boost/smart_pointers/ trunk/dsim/test/boost/smart_pointers/Makefile.am trunk/dsim/test/boost/smart_pointers/reference_lost.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-01-28 19:38:14 UTC (rev 56) +++ trunk/dsim/configure.ac 2010-01-29 15:59:32 UTC (rev 57) @@ -507,6 +507,7 @@ test/boost/spirit/Makefile test/boost/serialization/Makefile test/boost/signals/Makefile + test/boost/smart_pointers/Makefile test/stdair/Makefile test/trademgen/Makefile test/airsched/Makefile Modified: trunk/dsim/test/boost/Makefile.am =================================================================== --- trunk/dsim/test/boost/Makefile.am 2010-01-28 19:38:14 UTC (rev 56) +++ trunk/dsim/test/boost/Makefile.am 2010-01-29 15:59:32 UTC (rev 57) @@ -5,6 +5,7 @@ MAINTAINERCLEANFILES = Makefile.in ## -SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit +SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit \ + smart_pointers EXTRA_DIST = Property changes on: trunk/dsim/test/boost/smart_pointers ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile reference_lost Copied: trunk/dsim/test/boost/smart_pointers/Makefile.am (from rev 56, trunk/dsim/test/boost/filesystem/Makefile.am) =================================================================== --- trunk/dsim/test/boost/smart_pointers/Makefile.am (rev 0) +++ trunk/dsim/test/boost/smart_pointers/Makefile.am 2010-01-29 15:59:32 UTC (rev 57) @@ -0,0 +1,19 @@ +## test/boost/smart_pointers sub-directory +include $(top_srcdir)/Makefile.common + +# +MAINTAINERCLEANFILES = Makefile.in + +# +SUBDIRS = + +EXTRA_DIST = + +# +check_PROGRAMS = reference_lost + +# +reference_lost_SOURCES = reference_lost.cpp +reference_lost_CXXFLAGS = $(BOOST_CFLAGS) +reference_lost_LDADD = +reference_lost_LDFLAGS = $(BOOST_LIBS) Copied: trunk/dsim/test/boost/smart_pointers/reference_lost.cpp (from rev 56, trunk/dsim/test/boost/filesystem/simple_ls.cpp) =================================================================== --- trunk/dsim/test/boost/smart_pointers/reference_lost.cpp (rev 0) +++ trunk/dsim/test/boost/smart_pointers/reference_lost.cpp 2010-01-29 15:59:32 UTC (rev 57) @@ -0,0 +1,53 @@ +// STL +#include <cassert> +#include <iostream> +// Boost +#include <boost/shared_ptr.hpp> + +/** Simple object. */ +class Object { +public: + Object() { + std::cout << "Object constructor" << std::endl; + } + Object(const Object&) { + std::cout << "Object copy constructor" << std::endl; + } + ~Object() { + std::cout << "Object destructor" << std::endl; + } + void display() const { + std::cout << "Description: " << _description << std::endl; + } + +private: + /** Description. */ + std::string _description; +}; + + +/** Pointer on the STDAIR Service handler. */ +typedef boost::shared_ptr<Object> ObjectPtr_T; + + +// ////////////////////// M A I N /////////////////////// +int main (int argc, char* argv[]) { + + Object* lObject_ptr = new Object; + assert (lObject_ptr != NULL); + Object& lObject = *lObject_ptr; + + std::cout << "The reference is good?" << std::endl; + lObject.display(); + std::cout << "Yes, the reference is good!" << std::endl; + + { + ObjectPtr_T lObjectSmartPtr = ObjectPtr_T (lObject_ptr); + } + + std::cout << "The reference is still good?" << std::endl; + lObject.display(); + std::cout << "Yes, the reference is still good!" << std::endl; + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-06 17:58:50
|
Revision: 61 http://dsim.svn.sourceforge.net/dsim/?rev=61&view=rev Author: denis_arnaud Date: 2010-02-06 17:58:43 +0000 (Sat, 06 Feb 2010) Log Message: ----------- [DB] Added support for database management (still a little work to do). Modified Paths: -------------- trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/test/dsim/simulate.cpp Property Changed: ---------------- trunk/dsim/ Property changes on: trunk/dsim ___________________________________________________________________ Modified: svn:externals - config https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/trademgen airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/airsched avlcal https://avlcal.svn.sourceforge.net/svnroot/avlcal/trunk/avlcal/avlcal airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/airinv simfqt https://simfqt.svn.sourceforge.net/svnroot/simfqt/trunk/simfqt/simfqt simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/simcrs rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/rmol travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/travelccm extracppunit https://extracc.svn.sourceforge.net/svnroot/extracc/trunk/extracc/extracppunit + config https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/config db https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/db stdair https://stdair.svn.sourceforge.net/svnroot/stdair/trunk/stdair/stdair trademgen https://trademgen.svn.sourceforge.net/svnroot/trademgen/trunk/trademgen/trademgen airsched https://air-sched.svn.sourceforge.net/svnroot/air-sched/trunk/airsched/airsched avlcal https://avlcal.svn.sourceforge.net/svnroot/avlcal/trunk/avlcal/avlcal airinv https://airinv.svn.sourceforge.net/svnroot/airinv/trunk/airinv/airinv simfqt https://simfqt.svn.sourceforge.net/svnroot/simfqt/trunk/simfqt/simfqt simcrs https://simcrs.svn.sourceforge.net/svnroot/simcrs/trunk/simcrs/simcrs rmol https://rmol.svn.sourceforge.net/svnroot/rmol/trunk/rmol/rmol travelccm https://travel-ccm.svn.sourceforge.net/svnroot/travel-ccm/trunk/travelccm/travelccm extracppunit https://extracc.svn.sourceforge.net/svnroot/extracc/trunk/extracc/extracppunit Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-03 16:28:56 UTC (rev 60) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-06 17:58:43 UTC (rev 61) @@ -140,15 +140,16 @@ iScheduleInputFilename)); lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service); - // TODO: do not hardcode the DBParams. + // TODO: do not hardcode the stdair::BasDBParams. + // TODO: do not hardcode the demand input file. // Initialise the TRADEMGEN service handler - const TRADEMGEN::DBParams lDBParams = - TRADEMGEN::DBParams ("anguyen", "anguyen", "ncemysqlp.nce.amadeus.net", - "3321", "sim_anguyen"); + const stdair::Filename_T lDemandInputFilename ("../../test/samples/demand01.csv"); + const stdair::BasDBParams lDBParams = + stdair::BasDBParams ("dsim", "dsim", "localhost", "3306", "dsim"); TRADEMGEN_ServicePtr_T lTRADEMGEN_Service = - TRADEMGEN_ServicePtr_T (new TRADEMGEN::TRADEMGEN_Service (lDBParams)); + TRADEMGEN_ServicePtr_T (new TRADEMGEN::TRADEMGEN_Service (ioSTDAIR_ServicePtr, + lDemandInputFilename)); lDSIM_ServiceContext.setTRADEMGEN_Service (lTRADEMGEN_Service); - } // ////////////////////////////////////////////////////////////////////// Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2010-02-03 16:28:56 UTC (rev 60) +++ trunk/dsim/test/dsim/simulate.cpp 2010-02-06 17:58:43 UTC (rev 61) @@ -11,8 +11,6 @@ // ///////// M A I N //////////// int main (int argc, char* argv[]) { - try { - // Schedule input file name std::string lScheduleInputFilename ("../samples/schedule01.csv"); @@ -32,13 +30,6 @@ // Perform a simulation dsimService.simulate(); - } catch (const std::exception& stde) { - std::cerr << "Standard exception: " << stde.what() << std::endl; - return -1; - - } catch (...) { - return -1; - } - return 0; } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-07 02:41:50
|
Revision: 62 http://dsim.svn.sourceforge.net/dsim/?rev=62&view=rev Author: denis_arnaud Date: 2010-02-07 02:41:42 +0000 (Sun, 07 Feb 2010) Log Message: ----------- [DB] Now fully support database storage (with a simple example for airline names). Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/dsim/DSIM_Service.hpp trunk/dsim/dsim/batches/Makefile.am trunk/dsim/dsim/batches/sources.mk trunk/dsim/dsim/command/Makefile.am trunk/dsim/dsim/command/sources.mk trunk/dsim/dsim/service/DSIM_Service.cpp trunk/dsim/dsim/service/DSIM_ServiceContext.hpp trunk/dsim/test/dsim/Makefile.am trunk/dsim/test/dsim/simulate.cpp Added Paths: ----------- trunk/dsim/dsim/batches/simulate.cpp trunk/dsim/dsim/command/DBManager.cpp trunk/dsim/dsim/command/DBManager.hpp trunk/dsim/test/dsim/SimulationTestSuite.cpp trunk/dsim/test/dsim/SimulationTestSuite.hpp Property Changed: ---------------- trunk/dsim/dsim/batches/ trunk/dsim/test/dsim/ Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/configure.ac 2010-02-07 02:41:42 UTC (rev 62) @@ -171,20 +171,20 @@ # ----------------------------------------------------------- # OpenMPI: http://www.open-mpi.org # ----------------------------------------------------------- -#AX_OPENMPI -#AC_SUBST(MPIGEN_VERSION) -#AC_SUBST(MPIGEN_CFLAGS) -#AC_SUBST(MPIGEN_LIBS) +AX_OPENMPI +AC_SUBST(MPIGEN_VERSION) +AC_SUBST(MPIGEN_CFLAGS) +AC_SUBST(MPIGEN_LIBS) # ----------------------------------------------------------- # MPICH2: http://www.mcs.anl.gov/research/projects/mpich2 # Note: Boost.MPI depends on MPICH2 by default, rather than # on OpenMPI # ----------------------------------------------------------- -AX_MPICH2 -AC_SUBST(MPIGEN_VERSION) -AC_SUBST(MPIGEN_CFLAGS) -AC_SUBST(MPIGEN_LIBS) +#AX_MPICH2 +#AC_SUBST(MPIGEN_VERSION) +#AC_SUBST(MPIGEN_CFLAGS) +#AC_SUBST(MPIGEN_LIBS) # --------------------------------------------------------------- # Support for Boost (Extension of the STL): http://www.boost.org @@ -404,6 +404,7 @@ stdair/Makefile stdair/basic/Makefile stdair/bom/Makefile + stdair/dbadaptor/Makefile stdair/factory/Makefile stdair/config/Makefile stdair/service/Makefile Modified: trunk/dsim/dsim/DSIM_Service.hpp =================================================================== --- trunk/dsim/dsim/DSIM_Service.hpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -6,10 +6,17 @@ // ////////////////////////////////////////////////////////////////////// // StdAir #include <stdair/STDAIR_Types.hpp> -#include <stdair/basic/BasLogParams.hpp> // Dsim #include <dsim/DSIM_Types.hpp> +// Forward declarations. +namespace stdair { + class AirlineFeatureSet; + class STDAIR_Service; + struct BasLogParams; + struct BasDBParams; +} + namespace DSIM { // Forward declaration @@ -19,37 +26,50 @@ /** Interface for the DSIM Services. */ class DSIM_Service { public: - // /////////// Business Methods ///////////// - /** Perform a simulation. */ - void simulate(); - - - public: // ////////// Constructors and destructors ////////// /** Constructor. <br>The init() method is called; see the corresponding documentation for more details. - <br>Moreover, a reference on an output stream is given, so - that log outputs can be directed onto that stream. + <br>A reference on an output stream is given, so that log + outputs can be directed onto that stream. + <br>Moreover, database connection parameters are given, so that a + session can be created on the corresponding database. @param const stdair::BasLogParams& Parameters for the output log stream. - @param const stdair::Filename_T& Filename of the input schedule file. */ - DSIM_Service (const stdair::BasLogParams&, const stdair::Filename_T&); + @param const stdair::BasDBParams& Parameters for the database access. + @param const stdair::Filename_T& Filename of the input schedule file. + @param const stdair::Filename_T& Filename of the input demand file. */ + DSIM_Service (const stdair::BasLogParams&, const stdair::BasDBParams&, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilenames); /** Constructor. <br>The init() method is called; see the corresponding documentation for more details. <br>Moreover, as no reference on any output stream is given, - it is assumed that the StdAir log service has already been - initialised with the proper log output stream by some other - methods in the calling chain (for instance, when the DSIM_Service - is itself being initialised by another library service). - @param const stdair::Filename_T& Filename of the input schedule file. */ - DSIM_Service (const stdair::Filename_T&); + neither any database access parameter is given, it is assumed + that the StdAir log service has already been initialised with + the proper log output stream by some other methods in the + calling chain (for instance, when the DSIM_Service is + itself being initialised by another library service). + @param const stdair::Filename_T& Filename of the input schedule file. + @param const stdair::Filename_T& Filename of the input demand file. */ + DSIM_Service (stdair::STDAIR_ServicePtr_T, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilenames); /** Destructor. */ ~DSIM_Service(); + public: + // /////////// Business Methods ///////////// + /** Perform a simulation. */ + void simulate(); + + /** Display the list of airlines. */ + void displayAirlineListFromDB(); + + private: // /////// Construction and Destruction helper methods /////// /** Default constructor. */ @@ -57,13 +77,6 @@ /** Default copy constructor. */ DSIM_Service (const DSIM_Service&); - /** Initialise the log. */ - void logInit (const stdair::BasLogParams&); - - /** Initialise. - @param const stdair::Filename_T& Filename of the input schedule file. */ - void init (stdair::STDAIR_ServicePtr_T, const stdair::Filename_T&); - /** Initialise the (DSIM) service context (i.e., the DSIM_ServiceContext object). */ void initServiceContext (); @@ -72,9 +85,20 @@ <br>A reference on the root of the BOM tree, namely the BomRoot object, is stored within the service context for later use. @param const stdair::BasLogParams& Parameters for the output log stream. - */ - stdair::STDAIR_ServicePtr_T initStdAirService (const stdair::BasLogParams&); - + @param const stdair::BasDBParams& Parameters for the database access. + @param const stdair::AirlineFeatureSet& Set of airline features. */ + void initStdAirService (const stdair::BasLogParams&, + const stdair::BasDBParams&); + + /** Initialise. + <br>The CSV file, describing the airline schedules for the + simulator, is parsed and the inventories are generated accordingly. + @param const stdair::AirlineFeatureSet& Set of airline features. + @param const stdair::Filename_T& Filename of the input schedule file. + @param const stdair::Filename_T& Filename of the input demand file. */ + void init (const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename); + /** Finalise. */ void finalise (); Property changes on: trunk/dsim/dsim/batches ___________________________________________________________________ Modified: svn:ignore - .deps .libs Makefile.in Makefile dsim + .deps .libs Makefile.in Makefile simulate simulate.log Modified: trunk/dsim/dsim/batches/Makefile.am =================================================================== --- trunk/dsim/dsim/batches/Makefile.am 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/batches/Makefile.am 2010-02-07 02:41:42 UTC (rev 62) @@ -6,10 +6,12 @@ MAINTAINERCLEANFILES = Makefile.in + # Binaries (batches) -bin_PROGRAMS = +bin_PROGRAMS = simulate -#airinv_SOURCES = $(batches_h_sources) $(batches_cc_sources) -#airinv_CXXFLAGS = $(BOOST_CFLAGS) -#airinv_LDADD = -#airinv_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(top_builddir)/airinv/core/libairinv.la +simulate_SOURCES = $(batches_h_sources) $(batches_cc_sources) +simulate_CXXFLAGS = $(BOOST_CFLAGS) +simulate_LDADD = +simulate_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(SOCI_LIBS) \ + $(top_builddir)/dsim/core/libdsim.la Added: trunk/dsim/dsim/batches/simulate.cpp =================================================================== --- trunk/dsim/dsim/batches/simulate.cpp (rev 0) +++ trunk/dsim/dsim/batches/simulate.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,338 @@ +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <fstream> +#include <vector> +#include <string> +// Boost (Extended STL) +#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/date_time/gregorian/gregorian.hpp> +#include <boost/tokenizer.hpp> +#include <boost/program_options.hpp> +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> +#include <stdair/factory/FacBomContent.hpp> +#include <stdair/bom/AirlineFeatureSet.hpp> +#include <stdair/bom/AirlineFeature.hpp> +// DSIM +#include <dsim/DSIM_Service.hpp> +#include <dsim/config/dsim-paths.hpp> + +// //////// Type definitions /////// +typedef std::vector<std::string> WordList_T; + + +// //////// Constants ////// +/** Default name and location for the log file. */ +const std::string K_DSIM_DEFAULT_LOG_FILENAME ("simulate.log"); + +/** Default name and location for the (CSV) demand input file. */ +const std::string K_DSIM_DEFAULT_DEMAND_INPUT_FILENAME ("../../test/samples/demand01.csv"); + +/** Default name and location for the (CSV) schedule input file. */ +const std::string K_DSIM_DEFAULT_SCHEDULE_INPUT_FILENAME ("../../test/samples/schedule01.csv"); + +/** Default query string. */ +const std::string K_DSIM_DEFAULT_QUERY_STRING ("my good old query"); + +/** Default name and location for the Xapian database. */ +const std::string K_DSIM_DEFAULT_DB_USER ("dsim"); +const std::string K_DSIM_DEFAULT_DB_PASSWD ("dsim"); +const std::string K_DSIM_DEFAULT_DB_DBNAME ("dsim"); +const std::string K_DSIM_DEFAULT_DB_HOST ("localhost"); +const std::string K_DSIM_DEFAULT_DB_PORT ("3306"); + + +// ////////////////////////////////////////////////////////////////////// +void tokeniseStringIntoWordList (const std::string& iPhrase, + WordList_T& ioWordList) { + // Empty the word list + ioWordList.clear(); + + // Boost Tokeniser + typedef boost::tokenizer<boost::char_separator<char> > Tokeniser_T; + + // Define the separators + const boost::char_separator<char> lSepatorList(" .,;:|+-*/_=!@#$%`~^&(){}[]?'<>\""); + + // Initialise the phrase to be tokenised + Tokeniser_T lTokens (iPhrase, lSepatorList); + for (Tokeniser_T::const_iterator tok_iter = lTokens.begin(); + tok_iter != lTokens.end(); ++tok_iter) { + const std::string& lTerm = *tok_iter; + ioWordList.push_back (lTerm); + } + +} + +// ////////////////////////////////////////////////////////////////////// +std::string createStringFromWordList (const WordList_T& iWordList) { + std::ostringstream oStr; + + unsigned short idx = iWordList.size(); + for (WordList_T::const_iterator itWord = iWordList.begin(); + itWord != iWordList.end(); ++itWord, --idx) { + const std::string& lWord = *itWord; + oStr << lWord; + if (idx > 1) { + oStr << " "; + } + } + + return oStr.str(); +} + + +// ///////// Parsing of Options & Configuration ///////// +// A helper function to simplify the main part. +template<class T> std::ostream& operator<< (std::ostream& os, + const std::vector<T>& v) { + std::copy (v.begin(), v.end(), std::ostream_iterator<T> (std::cout, " ")); + return os; +} + +/** Early return status (so that it can be differentiated from an error). */ +const int K_DSIM_EARLY_RETURN_STATUS = 99; + +/** Read and parse the command line options. */ +int readConfiguration (int argc, char* argv[], + std::string& ioQueryString, + stdair::Filename_T& ioScheduleInputFilename, + stdair::Filename_T& ioDemandInputFilename, + std::string& ioLogFilename, + std::string& ioDBUser, std::string& ioDBPasswd, + std::string& ioDBHost, std::string& ioDBPort, + std::string& ioDBDBName) { + + // Initialise the travel query string, if that one is empty + if (ioQueryString.empty() == true) { + ioQueryString = K_DSIM_DEFAULT_QUERY_STRING; + } + + // Transform the query string into a list of words (STL strings) + WordList_T lWordList; + tokeniseStringIntoWordList (ioQueryString, lWordList); + + // Declare a group of options that will be allowed only on command line + boost::program_options::options_description generic ("Generic options"); + generic.add_options() + ("prefix", "print installation prefix") + ("version,v", "print version string") + ("help,h", "produce help message"); + + // Declare a group of options that will be allowed both on command + // line and in config file + boost::program_options::options_description config ("Configuration"); + config.add_options() + ("demand,d", + boost::program_options::value< std::string >(&ioScheduleInputFilename)->default_value(K_DSIM_DEFAULT_DEMAND_INPUT_FILENAME), + "(CVS) input file for the demand distributions") + ("schedule,s", + boost::program_options::value< std::string >(&ioDemandInputFilename)->default_value(K_DSIM_DEFAULT_SCHEDULE_INPUT_FILENAME), + "(CVS) input file for the schedules") + ("log,l", + boost::program_options::value< std::string >(&ioLogFilename)->default_value(K_DSIM_DEFAULT_LOG_FILENAME), + "Filepath for the logs") + ("user,u", + boost::program_options::value< std::string >(&ioDBUser)->default_value(K_DSIM_DEFAULT_DB_USER), + "SQL database hostname (e.g., dsim)") + ("passwd,p", + boost::program_options::value< std::string >(&ioDBPasswd)->default_value(K_DSIM_DEFAULT_DB_PASSWD), + "SQL database hostname (e.g., dsim)") + ("host,H", + boost::program_options::value< std::string >(&ioDBHost)->default_value(K_DSIM_DEFAULT_DB_HOST), + "SQL database hostname (e.g., localhost)") + ("port,P", + boost::program_options::value< std::string >(&ioDBPort)->default_value(K_DSIM_DEFAULT_DB_PORT), + "SQL database port (e.g., 3306)") + ("dbname,m", + boost::program_options::value< std::string >(&ioDBDBName)->default_value(K_DSIM_DEFAULT_DB_DBNAME), + "SQL database name (e.g., dsim)") + ("query,q", + boost::program_options::value< WordList_T >(&lWordList)->multitoken(), + "Query word list") + ; + + // Hidden options, will be allowed both on command line and + // in config file, but will not be shown to the user. + boost::program_options::options_description hidden ("Hidden options"); + hidden.add_options() + ("copyright", + boost::program_options::value< std::vector<std::string> >(), + "Show the copyright (license)"); + + boost::program_options::options_description cmdline_options; + cmdline_options.add(generic).add(config).add(hidden); + + boost::program_options::options_description config_file_options; + config_file_options.add(config).add(hidden); + + boost::program_options::options_description visible ("Allowed options"); + visible.add(generic).add(config); + + boost::program_options::positional_options_description p; + p.add ("copyright", -1); + + boost::program_options::variables_map vm; + boost::program_options:: + store (boost::program_options::command_line_parser (argc, argv). + options (cmdline_options).positional(p).run(), vm); + + std::ifstream ifs ("simulate.cfg"); + boost::program_options::store (parse_config_file (ifs, config_file_options), + vm); + boost::program_options::notify (vm); + + if (vm.count ("help")) { + std::cout << visible << std::endl; + return K_DSIM_EARLY_RETURN_STATUS; + } + + if (vm.count ("version")) { + std::cout << PACKAGE_NAME << ", version " << PACKAGE_VERSION << std::endl; + return K_DSIM_EARLY_RETURN_STATUS; + } + + if (vm.count ("prefix")) { + std::cout << "Installation prefix: " << PREFIXDIR << std::endl; + return K_DSIM_EARLY_RETURN_STATUS; + } + + if (vm.count ("schedule")) { + ioScheduleInputFilename = vm["schedule"].as< std::string >(); + std::cout << "Schedule input filename is: " << ioScheduleInputFilename + << std::endl; + } + + if (vm.count ("demand")) { + ioDemandInputFilename = vm["demand"].as< std::string >(); + std::cout << "Demand input filename is: " << ioDemandInputFilename + << std::endl; + } + + if (vm.count ("log")) { + ioLogFilename = vm["log"].as< std::string >(); + std::cout << "Log filename is: " << ioLogFilename << std::endl; + } + + if (vm.count ("user")) { + ioDBUser = vm["user"].as< std::string >(); + std::cout << "SQL database user name is: " << ioDBUser << std::endl; + } + + if (vm.count ("passwd")) { + ioDBPasswd = vm["passwd"].as< std::string >(); + //std::cout << "SQL database user password is: " << ioDBPasswd << std::endl; + } + + if (vm.count ("host")) { + ioDBHost = vm["host"].as< std::string >(); + std::cout << "SQL database host name is: " << ioDBHost << std::endl; + } + + if (vm.count ("port")) { + ioDBPort = vm["port"].as< std::string >(); + std::cout << "SQL database port number is: " << ioDBPort << std::endl; + } + + if (vm.count ("dbname")) { + ioDBDBName = vm["dbname"].as< std::string >(); + std::cout << "SQL database name is: " << ioDBDBName << std::endl; + } + + ioQueryString = createStringFromWordList (lWordList); + std::cout << "The query string is: " << ioQueryString << std::endl; + + return 0; +} + +// ///////// M A I N //////////// +int main (int argc, char* argv[]) { + + try { + + // Query + std::string lQuery; + + // Schedule input file name + stdair::Filename_T lScheduleInputFilename; + + // Demand input file name + stdair::Filename_T lDemandInputFilename; + + // Output log File + std::string lLogFilename; + + // SQL database parameters + std::string lDBUser; + std::string lDBPasswd; + std::string lDBHost; + std::string lDBPort; + std::string lDBDBName; + + // Airline code + stdair::AirlineCode_T lAirlineCode ("BA"); + + // Call the command-line option parser + const int lOptionParserStatus = + readConfiguration (argc, argv, lQuery, lScheduleInputFilename, + lDemandInputFilename, lLogFilename, + lDBUser, lDBPasswd, lDBHost, lDBPort, lDBDBName); + + if (lOptionParserStatus == K_DSIM_EARLY_RETURN_STATUS) { + return 0; + } + + // Set the database parameters + stdair::BasDBParams lDBParams (lDBUser, lDBPasswd, lDBHost, lDBPort, + lDBDBName); + + // Set the log parameters + std::ofstream logOutputFile; + // open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + // Initialise the set of required airline features + stdair::AirlineFeatureSet& lAirlineFeatureSet = + stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>(); + + // Initialise an AirlineFeature object + stdair::AirlineFeatureKey_T lAirlineFeatureKey (lAirlineCode); + stdair::AirlineFeature& lAirlineFeature = stdair::FacBomContent:: + instance().create<stdair::AirlineFeature> (lAirlineFeatureKey); + stdair::FacBomContent:: + linkWithParent<stdair::AirlineFeature> (lAirlineFeature, + lAirlineFeatureSet); + + // Initialise the simulation context + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + DSIM::DSIM_Service dsimService (lLogParams, lDBParams, + lScheduleInputFilename, + lDemandInputFilename); + + // Perform a simulation + dsimService.simulate(); + + // DEBUG + // Display the airlines stored in the database + dsimService.displayAirlineListFromDB(); + + } catch (const DSIM::RootException& otexp) { + std::cerr << "Standard exception: " << otexp.what() << std::endl; + return -1; + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return -1; + + } catch (...) { + return -1; + } + + return 0; +} + Modified: trunk/dsim/dsim/batches/sources.mk =================================================================== --- trunk/dsim/dsim/batches/sources.mk 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/batches/sources.mk 2010-02-07 02:41:42 UTC (rev 62) @@ -1,2 +1,2 @@ batches_h_sources = -batches_cc_sources = +batches_cc_sources = $(top_srcdir)/dsim/batches/simulate.cpp Added: trunk/dsim/dsim/command/DBManager.cpp =================================================================== --- trunk/dsim/dsim/command/DBManager.cpp (rev 0) +++ trunk/dsim/dsim/command/DBManager.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,166 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// SOCI +#include <soci/core/soci.h> +#include <soci/backends/mysql/soci-mysql.h> +// StdAir +#include <stdair/bom/AirlineStruct.hpp> +#include <stdair/dbadaptor/DbaAirline.hpp> +#include <stdair/service/Logger.hpp> +// Dsim +#include <dsim/command/DBManager.hpp> + +namespace DSIM { + + // ////////////////////////////////////////////////////////////////////// + void DBManager:: + prepareSelectStatement (stdair::DBSession_T& ioSociSession, + stdair::DBRequestStatement_T& ioSelectStatement, + stdair::AirlineStruct& ioAirline) { + + try { + + // Instanciate a SQL statement (no request is performed at that stage) + /** + select code, name + from airlines; + */ + + ioSelectStatement = (ioSociSession.prepare + << "select iata_code, name " + << "from airlines ", soci::into (ioAirline)); + + // Execute the SQL query + ioSelectStatement.execute(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + void DBManager:: + prepareSelectOnAirlineCodeStatement (stdair::DBSession_T& ioSociSession, + stdair::DBRequestStatement_T& ioSelectStatement, + const stdair::AirlineCode_T& iAirlineCode, + stdair::AirlineStruct& ioAirline) { + + try { + + // Instanciate a SQL statement (no request is performed at that stage) + /** + select code, name + from airlines + where code = iAirlineCode; + */ + + ioSelectStatement = (ioSociSession.prepare + << "select iata_code, name " + << "from airlines " + << "where iata_code = :airline_code ", + soci::into (ioAirline), soci::use (iAirlineCode)); + + // Execute the SQL query + ioSelectStatement.execute(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + bool DBManager::iterateOnStatement (stdair::DBRequestStatement_T& ioStatement, + stdair::AirlineStruct& ioAirline) { + bool hasStillData = false; + + try { + + // Retrieve the next row of Airline object + hasStillData = ioStatement.fetch(); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + + return hasStillData; + } + + // ////////////////////////////////////////////////////////////////////// + void DBManager::updateAirlineInDB (stdair::DBSession_T& ioSociSession, + const stdair::AirlineStruct& iAirline) { + + try { + + // Begin a transaction on the database + ioSociSession.begin(); + + // Retrieve the airline code + const std::string& lAirlineCode = iAirline.getAirlineCode(); + + // Retrieve the airline name + const std::string& lAirlineName = iAirline.getAirlineName(); + + // Instanciate a SQL statement (no request is performed at that stage) + stdair::DBRequestStatement_T lUpdateStatement = + (ioSociSession.prepare + << "update airlines " + << "set name = :name " + << "where iata_code = :iata_code", + soci::use (lAirlineName), soci::use (lAirlineCode)); + + // Execute the SQL query + lUpdateStatement.execute (true); + + // Commit the transaction on the database + ioSociSession.commit(); + + // Debug + // STDAIR_LOG_DEBUG ("[" << lAirlineCode << "] " << iAirline); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + } + + // ////////////////////////////////////////////////////////////////////// + bool DBManager::retrieveAirline (stdair::DBSession_T& ioSociSession, + const stdair::AirlineCode_T& iAirlineCode, + stdair::AirlineStruct& ioAirline) { + bool oHasRetrievedAirline = false; + + try { + + // Prepare the SQL request corresponding to the select statement + stdair::DBRequestStatement_T lSelectStatement (ioSociSession); + DBManager::prepareSelectOnAirlineCodeStatement (ioSociSession, + lSelectStatement, + iAirlineCode, ioAirline); + const bool shouldDoReset = true; + bool hasStillData = iterateOnStatement (lSelectStatement, ioAirline); + if (hasStillData == true) { + oHasRetrievedAirline = true; + } + + // Sanity check + const bool shouldNotDoReset = false; + hasStillData = iterateOnStatement (lSelectStatement, ioAirline); + + // Debug + // STDAIR_LOG_DEBUG ("[" << iDocID << "] " << ioAirline); + + } catch (std::exception const& lException) { + STDAIR_LOG_ERROR ("Error: " << lException.what()); + throw SQLDatabaseException(); + } + + return oHasRetrievedAirline; + } + +} Added: trunk/dsim/dsim/command/DBManager.hpp =================================================================== --- trunk/dsim/dsim/command/DBManager.hpp (rev 0) +++ trunk/dsim/dsim/command/DBManager.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,77 @@ +#ifndef __DSIM_CMD_DBMANAGER_HPP +#define __DSIM_CMD_DBMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/STDAIR_Types.hpp> +// Dsim +#include <dsim/DSIM_Types.hpp> + +namespace DSIM { + + // Forward declarations + struct AirlineStruct; + + /** Class building the Business Object Model (BOM) from data retrieved + from the database. */ + class DBManager { + public: + /** Update the fields of the database row + corresponding to the given BOM object. + @parameter stdair::DBSession_T& + @parameter stdair::AirlineStruct& . */ + static void updateAirlineInDB (stdair::DBSession_T&, + const stdair::AirlineStruct&); + + /** Retrieve, from the (MySQL) database, the row corresponding to + the given BOM code, and fill the given BOM object with that retrieved + data. + @parameter stdair::DBSession_T& + @parameter const stdair::AirlineCode_T& + @parameter stdair::AirlineStruct& . */ + static bool retrieveAirline (stdair::DBSession_T&, + const stdair::AirlineCode_T&, + stdair::AirlineStruct&); + + + public: + /** Prepare (parse and put in cache) the SQL statement. + @parameter stdair::DBSession_T& + @parameter stdair::DBRequestStatement_T& + @parameter stdair::AirlineStruct& . */ + static void prepareSelectStatement (stdair::DBSession_T&, + stdair::DBRequestStatement_T&, + stdair::AirlineStruct&); + + /** Iterate on the SQL statement. + <br>The SQL has to be already prepared. + @parameter stdair::DBRequestStatement_T& + @parameter stdair::AirlineStruct& . */ + static bool iterateOnStatement (stdair::DBRequestStatement_T&, + stdair::AirlineStruct&); + + + private: + /** Prepare (parse and put in cache) the SQL statement. + @parameter stdair::DBSession_T& + @parameter stdair::DBRequestStatement_T& + @parameter const stdair::AirlineCode_T& + @parameter stdair::AirlineStruct& */ + static void prepareSelectOnAirlineCodeStatement (stdair::DBSession_T&, + stdair::DBRequestStatement_T&, + const stdair::AirlineCode_T&, + stdair::AirlineStruct&); + + + private: + /** Constructors. */ + DBManager() {} + DBManager(const DBManager&) {} + /** Destructor. */ + ~DBManager() {} + }; + +} +#endif // __DSIM_CMD_DBMANAGER_HPP Modified: trunk/dsim/dsim/command/Makefile.am =================================================================== --- trunk/dsim/dsim/command/Makefile.am 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/command/Makefile.am 2010-02-07 02:41:42 UTC (rev 62) @@ -5,9 +5,9 @@ noinst_LTLIBRARIES= libcmd.la libcmd_la_SOURCES= $(cmd_h_sources) $(cmd_cc_sources) -libcmd_la_CXXFLAGS = $(BOOST_CFLAGS) +libcmd_la_CXXFLAGS = $(BOOST_CFLAGS) $(SOCI_CFLAGS) libcmd_la_LIBADD = -libcmd_la_LDFLAGS = $(BOOST_LIBS) \ +libcmd_la_LDFLAGS = $(BOOST_LIBS) $(SOCI_LIBS) \ $(top_builddir)/simcrs/core/libsimcrs.la \ $(top_builddir)/trademgen/core/libtrademgen.la Modified: trunk/dsim/dsim/command/sources.mk =================================================================== --- trunk/dsim/dsim/command/sources.mk 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/command/sources.mk 2010-02-07 02:41:42 UTC (rev 62) @@ -1,6 +1,8 @@ cmd_h_sources = \ $(top_srcdir)/dsim/command/CmdAbstract.hpp \ + $(top_srcdir)/dsim/command/DBManager.hpp \ $(top_srcdir)/dsim/command/Simulator.hpp cmd_cc_sources = \ $(top_srcdir)/dsim/command/CmdAbstract.cpp \ + $(top_srcdir)/dsim/command/DBManager.cpp \ $(top_srcdir)/dsim/command/Simulator.cpp \ No newline at end of file Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -4,24 +4,29 @@ // STL #include <cassert> #include <ostream> +// SOCI +#include <soci/core/soci.h> // StdAir #include <stdair/basic/BasChronometer.hpp> #include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/bom/BomRoot.hpp> +#include <stdair/bom/AirlineStruct.hpp> #include <stdair/bom/AirlineFeature.hpp> #include <stdair/bom/AirlineFeatureSet.hpp> -#include <stdair/bom/BomRoot.hpp> #include <stdair/factory/FacBomContent.hpp> #include <stdair/service/Logger.hpp> +#include <stdair/service/DBSessionManager.hpp> #include <stdair/STDAIR_Service.hpp> // Distribution #include <simcrs/SIMCRS_Service.hpp> -// TRADEMGEN +// TraDemGen #include <trademgen/TRADEMGEN_Service.hpp> #include <trademgen/DBParams.hpp> // Dsim #include <dsim/basic/BasConst_DSIM_Service.hpp> +#include <dsim/factory/FacDsimServiceContext.hpp> +#include <dsim/command/DBManager.hpp> #include <dsim/command/Simulator.hpp> -#include <dsim/factory/FacDsimServiceContext.hpp> #include <dsim/service/DSIM_ServiceContext.hpp> #include <dsim/DSIM_Service.hpp> @@ -38,31 +43,40 @@ } // ////////////////////////////////////////////////////////////////////// - DSIM_Service::DSIM_Service (const stdair::Filename_T& iScheduleInputFilename) + DSIM_Service::DSIM_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_ServicePtr, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename) : _dsimServiceContext (NULL) { // Initialise the service context initServiceContext (); + + // Retrieve the Trademgen service context + assert (_dsimServiceContext != NULL); + DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext; + + // Store the STDAIR service object within the (TRADEMGEN) service context + lDSIM_ServiceContext.setSTDAIR_Service (ioSTDAIR_ServicePtr); + // Initialise the context - //init (iScheduleInputFilename); - - assert (false); + init (iScheduleInputFilename, iDemandInputFilename); } // ////////////////////////////////////////////////////////////////////// DSIM_Service::DSIM_Service (const stdair::BasLogParams& iLogParams, - const stdair::Filename_T& iScheduleInputFilename) + const stdair::BasDBParams& iDBParams, + const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename) : _dsimServiceContext (NULL) { // Initialise the service context initServiceContext (); // Initialise the STDAIR service handler - stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = - initStdAirService (iLogParams); + initStdAirService (iLogParams, iDBParams); // Initialise the (remaining of the) context - init (lSTDAIR_Service_ptr, iScheduleInputFilename); + init (iScheduleInputFilename, iDemandInputFilename); } // ////////////////////////////////////////////////////////////////////// @@ -80,8 +94,8 @@ } // ////////////////////////////////////////////////////////////////////// - stdair::STDAIR_ServicePtr_T DSIM_Service:: - initStdAirService (const stdair::BasLogParams& iLogParams) { + void DSIM_Service::initStdAirService (const stdair::BasLogParams& iLogParams, + const stdair::BasDBParams& iDBParams) { // Retrieve the Dsim service context assert (_dsimServiceContext != NULL); @@ -90,13 +104,14 @@ // Initialise the STDAIR service handler // Note that the track on the object memory is kept thanks to the Boost // Smart Pointers component. - stdair::STDAIR_ServicePtr_T oSTDAIR_Service_ptr = - stdair::STDAIR_ServicePtr_T (new stdair::STDAIR_Service (iLogParams)); + stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = + stdair::STDAIR_ServicePtr_T (new stdair::STDAIR_Service (iLogParams, + iDBParams)); // Retrieve the root of the BOM tree, on which all of the other BOM objects // will be attached - assert (oSTDAIR_Service_ptr != NULL); - stdair::BomRoot& lBomRoot = oSTDAIR_Service_ptr->getBomRoot(); + assert (lSTDAIR_Service_ptr != NULL); + stdair::BomRoot& lBomRoot = lSTDAIR_Service_ptr->getBomRoot(); // TODO: do not hardcode the initialisation of AirlineFeatureSet // Initialise the set of required airline features @@ -116,16 +131,22 @@ // Set the AirlineFeatureSet for the BomRoot. lBomRoot.setAirlineFeatureSet (&lAirlineFeatureSet); - return oSTDAIR_Service_ptr; + // Store the STDAIR service object within the (TRADEMGEN) service context + lDSIM_ServiceContext.setSTDAIR_Service (lSTDAIR_Service_ptr); } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::init (stdair::STDAIR_ServicePtr_T ioSTDAIR_ServicePtr, - const stdair::Filename_T& iScheduleInputFilename) { + void DSIM_Service::init (const stdair::Filename_T& iScheduleInputFilename, + const stdair::Filename_T& iDemandInputFilename) { // Retrieve the service context assert (_dsimServiceContext != NULL); DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext; + // Retrieve the StdAir service context + stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = + lDSIM_ServiceContext.getSTDAIR_Service(); + assert (lSTDAIR_Service_ptr != NULL); + // TODO: do not hardcode the CRS code (e.g., take it from a // configuration file). // Initialise the SIMCRS service handler @@ -135,20 +156,17 @@ // on the Service object, and deletes that object when it is no longer // referenced (e.g., at the end of the process). SIMCRS_ServicePtr_T lSIMCRS_Service = - SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (ioSTDAIR_ServicePtr, + SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (lSTDAIR_Service_ptr, lCRSCode, iScheduleInputFilename)); lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service); - // TODO: do not hardcode the stdair::BasDBParams. // TODO: do not hardcode the demand input file. // Initialise the TRADEMGEN service handler - const stdair::Filename_T lDemandInputFilename ("../../test/samples/demand01.csv"); - const stdair::BasDBParams lDBParams = - stdair::BasDBParams ("dsim", "dsim", "localhost", "3306", "dsim"); TRADEMGEN_ServicePtr_T lTRADEMGEN_Service = - TRADEMGEN_ServicePtr_T (new TRADEMGEN::TRADEMGEN_Service (ioSTDAIR_ServicePtr, - lDemandInputFilename)); + TRADEMGEN_ServicePtr_T (new TRADEMGEN:: + TRADEMGEN_Service (lSTDAIR_Service_ptr, + iDemandInputFilename)); lDSIM_ServiceContext.setTRADEMGEN_Service (lTRADEMGEN_Service); } @@ -191,4 +209,62 @@ } } + // ////////////////////////////////////////////////////////////////////// + void DSIM_Service::displayAirlineListFromDB () { + if (_dsimServiceContext == NULL) { + throw NonInitialisedServiceException(); + } + assert (_dsimServiceContext != NULL); + DSIM_ServiceContext& lDSIM_ServiceContext = *_dsimServiceContext; + + // Get the date-time for the present time + boost::posix_time::ptime lNowDateTime = + boost::posix_time::second_clock::local_time(); + boost::gregorian::date lNowDate = lNowDateTime.date(); + + // DEBUG + STDAIR_LOG_DEBUG (std::endl + << "===================================================" + << std::endl + << lNowDateTime); + + try { + + // Delegate the query execution to the dedicated command + stdair::BasChronometer lDsimChronometer; + lDsimChronometer.start(); + + // Retrieve the database session handler + stdair::DBSession_T& lDBSession = + stdair::DBSessionManager::instance().getDBSession(); + + // Prepare and execute the select statement + stdair::AirlineStruct lAirline; + stdair::DBRequestStatement_T lSelectStatement (lDBSession); + DBManager::prepareSelectStatement(lDBSession, lSelectStatement, lAirline); + + // Prepare the SQL request corresponding to the select statement + bool hasStillData = true; + unsigned int idx = 0; + while (hasStillData == true) { + hasStillData = DBManager::iterateOnStatement (lSelectStatement, + lAirline); + // DEBUG + STDAIR_LOG_DEBUG ("[" << idx << "]: " << lAirline); + + // Iteration + ++idx; + } + + const double lDsimMeasure = lDsimChronometer.elapsed(); + + // DEBUG + STDAIR_LOG_DEBUG ("Sample service for Dsim: " << lDsimMeasure); + + } catch (const std::exception& error) { + STDAIR_LOG_ERROR ("Exception: " << error.what()); + throw SimulationException(); + } + } + } Modified: trunk/dsim/dsim/service/DSIM_ServiceContext.hpp =================================================================== --- trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -8,6 +8,8 @@ #include <string> // Boost #include <boost/shared_ptr.hpp> +// StdAir +#include <stdair/STDAIR_Types.hpp> // Dsim #include <dsim/DSIM_Types.hpp> #include <dsim/bom/ConfigurationParameters.hpp> @@ -36,6 +38,11 @@ friend class FacDsimServiceContext; public: // ///////// Getters ////////// + /** Get the pointer on the STDAIR service handler. */ + stdair::STDAIR_ServicePtr_T getSTDAIR_Service () const { + return _stdairService; + } + /** Get the simulator ID. */ const SimulatorID_T& getSimulatorID () const { return _simulatorID; @@ -62,6 +69,11 @@ } // ///////// Setters ////////// + /** Set the pointer on the STDAIR service handler. */ + void setSTDAIR_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_ServicePtr) { + _stdairService = ioSTDAIR_ServicePtr; + } + /** Set the simulator ID. */ void setSimulatorID (const SimulatorID_T& iSimulatorID) { _simulatorID = iSimulatorID; @@ -106,6 +118,8 @@ private: // ///////////// Children //////////// + /** Standard Airline (StdAir) Service Handler. */ + stdair::STDAIR_ServicePtr_T _stdairService; /** CRS Service Handler. */ SIMCRS_ServicePtr_T _simcrsService; /** TRADEMGEN Service Handler. */ Property changes on: trunk/dsim/test/dsim ___________________________________________________________________ Modified: svn:ignore - .deps .libs Makefile.in Makefile simulate simulate.log + .deps .libs Makefile.in Makefile simulate simulate.log SimulationTestSuite SimulationTestSuite_results.xml Modified: trunk/dsim/test/dsim/Makefile.am =================================================================== --- trunk/dsim/test/dsim/Makefile.am 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/test/dsim/Makefile.am 2010-02-07 02:41:42 UTC (rev 62) @@ -1,4 +1,4 @@ -## test sub-directory +## test/dsim sub-directory include $(top_srcdir)/Makefile.common MAINTAINERCLEANFILES = Makefile.in @@ -9,20 +9,19 @@ EXTRA_DIST = ## -check_PROGRAMS = simulate +check_PROGRAMS = SimulationTestSuite TESTS = $(check_PROGRAMS) XFAIL_TESTS = # -#SimulationTestSuite_SOURCES = SimulationTestSuite.hpp \ - SimulationTestSuite.cpp -#SimulationTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) -#SimulationTestSuite_LDADD = $(top_builddir)/test/com/libcppunitcore.la -#SimulationTestSuite_LDFLAGS = \ -# $(BOOST_LIBS) $(CPPUNIT_LIBS) \ -# $(top_builddir)/dsim/libdsim.la - -simulate_SOURCES = simulate.cpp -simulate_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) -simulate_LDADD = -simulate_LDFLAGS = $(BOOST_LIBS) \ +SimulationTestSuite_SOURCES = SimulationTestSuite.hpp SimulationTestSuite.cpp +SimulationTestSuite_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) +SimulationTestSuite_LDADD = +SimulationTestSuite_LDFLAGS = \ + $(BOOST_LIBS) $(CPPUNIT_LIBS) \ + $(top_builddir)/extracppunit/libextracc-extracppunit.la \ $(top_builddir)/dsim/core/libdsim.la + +#simulate_SOURCES = simulate.cpp +#simulate_CXXFLAGS= $(CPPUNIT_CFLAGS) $(BOOST_CFLAGS) +#simulate_LDADD = +#simulate_LDFLAGS = $(BOOST_LIBS) $(top_builddir)/dsim/core/libdsim.la Added: trunk/dsim/test/dsim/SimulationTestSuite.cpp =================================================================== --- trunk/dsim/test/dsim/SimulationTestSuite.cpp (rev 0) +++ trunk/dsim/test/dsim/SimulationTestSuite.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,83 @@ +// STL +#include <sstream> +#include <fstream> +#include <string> +// CPPUNIT +#include <extracppunit/CppUnitCore.hpp> +// StdAir +#include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> +// Dsim +#include <dsim/DSIM_Types.hpp> +#include <dsim/DSIM_Service.hpp> +// Dsim Test Suite +#include <test/dsim/SimulationTestSuite.hpp> + +// ////////////////////////////////////////////////////////////////////// +// Test is based on ... +// ////////////////////////////////////////////////////////////////////// + +// ////////////////////////////////////////////////////////////////////// +void SimulationTestSuite::simpleSimulationHelper() { + + try { + + // Schedule input file name + const std::string lScheduleInputFilename ("../samples/schedule01.csv"); + + // Demand input file name + const stdair::Filename_T lDemandInputFilename ("../samples/demand01.csv"); + + // Output log File + const std::string lLogFilename ("simulate.log"); + + // Set the log parameters + std::ofstream logOutputFile; + // Open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + // Initialise the simulation context + const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); + const stdair::BasDBParams lDBParams ("dsim", "dsim", "localhost", "3306", + "dsim"); + DSIM::DSIM_Service dsimService (lLogParams, lDBParams, + lScheduleInputFilename, + lDemandInputFilename); + + // Perform a simulation + dsimService.simulate(); + + } catch (const DSIM::RootException& otexp) { + std::cerr << "Standard exception: " << otexp.what() << std::endl; + return; + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return; + + } catch (...) { + return; + } + +} + +// ////////////////////////////////////////////////////////////////////// +void SimulationTestSuite::simpleSimulation () { + // TODO: Check that the simulation goes as expected + CPPUNIT_ASSERT_NO_THROW ( simpleSimulationHelper();); +} + +// ////////////////////////////////////////////////////////////////////// +// void SimulationTestSuite::errorCase () { +// CPPUNIT_ASSERT (false); +// } + +// ////////////////////////////////////////////////////////////////////// +SimulationTestSuite::SimulationTestSuite () { + _describeKey << "Running test on simulation"; +} + +// /////////////// M A I N ///////////////// +CPPUNIT_MAIN() + Added: trunk/dsim/test/dsim/SimulationTestSuite.hpp =================================================================== --- trunk/dsim/test/dsim/SimulationTestSuite.hpp (rev 0) +++ trunk/dsim/test/dsim/SimulationTestSuite.hpp 2010-02-07 02:41:42 UTC (rev 62) @@ -0,0 +1,31 @@ +// STL +#include <iosfwd> +// CPPUNIT +#include <cppunit/extensions/HelperMacros.h> + +/** Utility class for CPPUnit-based testing. */ +class SimulationTestSuite : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE (SimulationTestSuite); + CPPUNIT_TEST (simpleSimulation); + // CPPUNIT_TEST (errorCase); + CPPUNIT_TEST_SUITE_END (); +public: + + /** Test a simple simulation functionality. */ + void simpleSimulation(); + + /** Test some error detection functionalities. */ + // void errorCase (); + + /** Constructor. */ + SimulationTestSuite (); + +private: + /** Test a simple simulation functionality. */ + void simpleSimulationHelper(); + +protected: + std::stringstream _describeKey; +}; + +CPPUNIT_TEST_SUITE_REGISTRATION (SimulationTestSuite); Modified: trunk/dsim/test/dsim/simulate.cpp =================================================================== --- trunk/dsim/test/dsim/simulate.cpp 2010-02-06 17:58:43 UTC (rev 61) +++ trunk/dsim/test/dsim/simulate.cpp 2010-02-07 02:41:42 UTC (rev 62) @@ -4,6 +4,10 @@ #include <sstream> #include <fstream> #include <string> +// StdAir +#include <stdair/STDAIR_Types.hpp> +#include <stdair/basic/BasLogParams.hpp> +#include <stdair/basic/BasDBParams.hpp> // DSIM #include <dsim/DSIM_Service.hpp> #include <dsim/config/dsim-paths.hpp> @@ -11,11 +15,16 @@ // ///////// M A I N //////////// int main (int argc, char* argv[]) { + try { + // Schedule input file name - std::string lScheduleInputFilename ("../samples/schedule01.csv"); + const std::string lScheduleInputFilename ("../samples/schedule01.csv"); + // Demand input file name + const stdair::Filename_T lDemandInputFilename ("../samples/demand01.csv"); + // Output log File - std::string lLogFilename ("simulate.log"); + const std::string lLogFilename ("simulate.log"); // Set the log parameters std::ofstream logOutputFile; @@ -23,13 +32,29 @@ logOutputFile.open (lLogFilename.c_str()); logOutputFile.clear(); - // Initialise the list of classes/buckets + // Initialise the simulation context const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); - DSIM::DSIM_Service dsimService (lLogParams, lScheduleInputFilename); + const stdair::BasDBParams lDBParams ("dsim", "dsim", "localhost", "3306", + "dsim"); + DSIM::DSIM_Service dsimService (lLogParams, lDBParams, + lScheduleInputFilename, + lDemandInputFilename); // Perform a simulation dsimService.simulate(); + } catch (const DSIM::RootException& otexp) { + std::cerr << "Standard exception: " << otexp.what() << std::endl; + return -1; + + } catch (const std::exception& stde) { + std::cerr << "Standard exception: " << stde.what() << std::endl; + return -1; + + } catch (...) { + return -1; + } + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-07 19:45:38
|
Revision: 63 http://dsim.svn.sourceforge.net/dsim/?rev=63&view=rev Author: denis_arnaud Date: 2010-02-07 19:45:32 +0000 (Sun, 07 Feb 2010) Log Message: ----------- 1. Integrated more initialisation procedures within the STDAIR_Service object. 2. Added a sample stdair::DBManagerForAirlines class. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/dsim/DSIM_Service.hpp trunk/dsim/dsim/batches/simulate.cpp trunk/dsim/dsim/service/DSIM_Service.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/configure.ac 2010-02-07 19:45:32 UTC (rev 63) @@ -406,6 +406,7 @@ stdair/bom/Makefile stdair/dbadaptor/Makefile stdair/factory/Makefile + stdair/command/Makefile stdair/config/Makefile stdair/service/Makefile stdair/core/Makefile Modified: trunk/dsim/dsim/DSIM_Service.hpp =================================================================== --- trunk/dsim/dsim/DSIM_Service.hpp 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/dsim/DSIM_Service.hpp 2010-02-07 19:45:32 UTC (rev 63) @@ -67,7 +67,7 @@ void simulate(); /** Display the list of airlines. */ - void displayAirlineListFromDB(); + void displayAirlineListFromDB() const; private: Modified: trunk/dsim/dsim/batches/simulate.cpp =================================================================== --- trunk/dsim/dsim/batches/simulate.cpp 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/dsim/batches/simulate.cpp 2010-02-07 19:45:32 UTC (rev 63) @@ -15,8 +15,6 @@ #include <stdair/basic/BasLogParams.hpp> #include <stdair/basic/BasDBParams.hpp> #include <stdair/factory/FacBomContent.hpp> -#include <stdair/bom/AirlineFeatureSet.hpp> -#include <stdair/bom/AirlineFeature.hpp> // DSIM #include <dsim/DSIM_Service.hpp> #include <dsim/config/dsim-paths.hpp> @@ -296,18 +294,6 @@ logOutputFile.open (lLogFilename.c_str()); logOutputFile.clear(); - // Initialise the set of required airline features - stdair::AirlineFeatureSet& lAirlineFeatureSet = - stdair::FacBomContent::instance().create<stdair::AirlineFeatureSet>(); - - // Initialise an AirlineFeature object - stdair::AirlineFeatureKey_T lAirlineFeatureKey (lAirlineCode); - stdair::AirlineFeature& lAirlineFeature = stdair::FacBomContent:: - instance().create<stdair::AirlineFeature> (lAirlineFeatureKey); - stdair::FacBomContent:: - linkWithParent<stdair::AirlineFeature> (lAirlineFeature, - lAirlineFeatureSet); - // Initialise the simulation context const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); DSIM::DSIM_Service dsimService (lLogParams, lDBParams, Modified: trunk/dsim/dsim/service/DSIM_Service.cpp =================================================================== --- trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-07 02:41:42 UTC (rev 62) +++ trunk/dsim/dsim/service/DSIM_Service.cpp 2010-02-07 19:45:32 UTC (rev 63) @@ -210,7 +210,7 @@ } // ////////////////////////////////////////////////////////////////////// - void DSIM_Service::displayAirlineListFromDB () { + void DSIM_Service::displayAirlineListFromDB () const { if (_dsimServiceContext == NULL) { throw NonInitialisedServiceException(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-02-28 01:19:06
|
Revision: 71 http://dsim.svn.sourceforge.net/dsim/?rev=71&view=rev Author: denis_arnaud Date: 2010-02-28 01:18:59 +0000 (Sun, 28 Feb 2010) Log Message: ----------- [Test] Added a directory for Boost.IOStreams. Modified Paths: -------------- trunk/dsim/configure.ac Added Paths: ----------- trunk/dsim/test/boost/iostreams/ trunk/dsim/test/boost/iostreams/Makefile.am trunk/dsim/test/boost/iostreams/filereader.cpp trunk/dsim/test/boost/iostreams/filetoberead.csv Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-02-23 14:29:43 UTC (rev 70) +++ trunk/dsim/configure.ac 2010-02-28 01:18:59 UTC (rev 71) @@ -199,6 +199,7 @@ AC_SUBST(BOOST_THREAD_LIB) AC_SUBST(BOOST_PYTHON_LIB) AC_SUBST(BOOST_SIGNALS_LIB) +AC_SUBST(BOOST_IOSTREAMS_LIB) AC_SUBST(BOOST_ASIO_LIB) AC_SUBST(BOOST_MPI_LIB) AC_SUBST(BOOST_MPI_PYTHON_LIB) @@ -504,6 +505,7 @@ test/boost/asio/logd/Makefile test/boost/asio/logger/Makefile test/boost/filesystem/Makefile + test/boost/iostreams/Makefile test/boost/mpi/Makefile test/boost/mpl/Makefile test/boost/spirit/Makefile @@ -609,6 +611,7 @@ o BOOST_FS_LIB .... : ${BOOST_FILESYSTEM_LIB} o BOOST_THRD_LIB .. : ${BOOST_THREAD_LIB} o BOOST_PY_LIB .... : ${BOOST_PYTHON_LIB} + o BOOST_IOSTR_LIB . : ${BOOST_IOSTREAMS_LIB} o BOOST_ASIO_LIB .. : ${BOOST_ASIO_LIB} o BOOST_SIG_LIB ... : ${BOOST_SIGNALS_LIB} o BOOST_MPI_LIB ... : ${BOOST_MPI_LIB} Property changes on: trunk/dsim/test/boost/iostreams ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile.in Makefile filereader Added: trunk/dsim/test/boost/iostreams/Makefile.am =================================================================== --- trunk/dsim/test/boost/iostreams/Makefile.am (rev 0) +++ trunk/dsim/test/boost/iostreams/Makefile.am 2010-02-28 01:18:59 UTC (rev 71) @@ -0,0 +1,17 @@ +## test/boost/iostreams sub-directory +include $(top_srcdir)/Makefile.common + +## +SUBDIRS = + +MAINTAINERCLEANFILES = Makefile.in + +EXTRA_DIST = + +# +check_PROGRAMS = filereader + +filereader_SOURCES = filereader.cpp +filereader_CXXFLAGS = $(BOOST_CFLAGS) $(BOOST_CFLAGS) +filereader_LDFLAGS = $(BOOST_LIBS) $(BOOST_ASIO_LIB) $(BOOST_IOSTREAMS_LIB) +filereader_LDADD = Added: trunk/dsim/test/boost/iostreams/filereader.cpp =================================================================== --- trunk/dsim/test/boost/iostreams/filereader.cpp (rev 0) +++ trunk/dsim/test/boost/iostreams/filereader.cpp 2010-02-28 01:18:59 UTC (rev 71) @@ -0,0 +1,46 @@ +// STL +#include <cassert> +#include <string> +#include <iostream> +#include <sstream> +#include <fstream> +#include <streambuf> +// Boost + + +// ////////////////// M A I N //////////////////////// +int main (int argc, char* argv[]) { + + // Input file name + const std::string lInputFilename ("filetoberead.csv"); + + // Open the input file + std::ifstream lInputFile (lInputFilename.c_str()); + + // Get a handler (pointer) on the underlying buffer stream + std::streambuf* lInputFileBuffer_ptr = lInputFile.rdbuf(); + + // Get the number of characters within the input file + const unsigned long nbChars = lInputFileBuffer_ptr->in_avail(); + + // DEBUG + std::cout << "Number of characters in the file '" << lInputFilename << "': " + << nbChars << std::endl; + + // Instantiate a character buffer for that number of characters + char lBufferChar[nbChars]; + + // Read that number of characters from the input file, and put it directly into the + // character buffer + lInputFileBuffer_ptr->sgetn (lBufferChar, nbChars); + + // Instantiate an input stream with the character buffer + std::istringstream iStr (lBufferChar); + // std::ostringstream iStr (lBufferChar); + + // DEBUG + // std::cout << "The file contains: " << iStr.str() << std::endl; + + return 0; +} + Added: trunk/dsim/test/boost/iostreams/filetoberead.csv =================================================================== --- trunk/dsim/test/boost/iostreams/filetoberead.csv (rev 0) +++ trunk/dsim/test/boost/iostreams/filetoberead.csv 2010-02-28 01:18:59 UTC (rev 71) @@ -0,0 +1,7 @@ +NCE,CDG,1 +NCE,ORY,1 +NCE,LYS,1 +NCE,MRS,1 +NCE,TLS,1 +NCE,SXB,1 +NCE,CFE,1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-04-23 16:20:56
|
Revision: 77 http://dsim.svn.sourceforge.net/dsim/?rev=77&view=rev Author: denis_arnaud Date: 2010-04-23 16:20:50 +0000 (Fri, 23 Apr 2010) Log Message: ----------- [Structure] The AirRac is now compiled. Modified Paths: -------------- trunk/dsim/Makefile.am trunk/dsim/configure.ac trunk/dsim/test/Makefile.am Modified: trunk/dsim/Makefile.am =================================================================== --- trunk/dsim/Makefile.am 2010-04-23 15:59:54 UTC (rev 76) +++ trunk/dsim/Makefile.am 2010-04-23 16:20:50 UTC (rev 77) @@ -24,8 +24,8 @@ EXTRA_DIST = @PACKAGE@.spec @PACKAGE@.m4 @PACKAGE@.pc Makefile.common # Build in these directories: -SUBDIRS = stdair trademgen airsched rmol airinv avlcal simfqt simcrs travelccm \ - dsim extracppunit $(TEST_DIR) +SUBDIRS = stdair trademgen airsched airrac rmol airinv avlcal simfqt simcrs \ + travelccm dsim extracppunit $(TEST_DIR) # Configuration helpers Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-04-23 15:59:54 UTC (rev 76) +++ trunk/dsim/configure.ac 2010-04-23 16:20:50 UTC (rev 77) @@ -432,6 +432,15 @@ airsched/config/Makefile airsched/core/Makefile airsched/batches/Makefile + airrac/Makefile + airrac/basic/Makefile + airrac/bom/Makefile + airrac/factory/Makefile + airrac/command/Makefile + airrac/service/Makefile + airrac/config/Makefile + airrac/core/Makefile + airrac/batches/Makefile rmol/Makefile rmol/basic/Makefile rmol/field/Makefile @@ -516,6 +525,7 @@ test/stdair/Makefile test/trademgen/Makefile test/airsched/Makefile + test/airrac/Makefile test/rmol/Makefile test/airinv/Makefile test/avlcal/Makefile Modified: trunk/dsim/test/Makefile.am =================================================================== --- trunk/dsim/test/Makefile.am 2010-04-23 15:59:54 UTC (rev 76) +++ trunk/dsim/test/Makefile.am 2010-04-23 16:20:50 UTC (rev 77) @@ -5,7 +5,8 @@ ## SUBDIRS = boost samples \ - stdair trademgen airsched rmol airinv avlcal simfqt simcrs travelccm dsim + stdair trademgen airsched airrac rmol airinv avlcal simfqt simcrs \ + travelccm dsim EXTRA_DIST = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-06-13 19:42:05
|
Revision: 85 http://dsim.svn.sourceforge.net/dsim/?rev=85&view=rev Author: denis_arnaud Date: 2010-06-13 19:41:59 +0000 (Sun, 13 Jun 2010) Log Message: ----------- [Test] Updated the dependency for the new ExtraCPPUnit library name. Modified Paths: -------------- trunk/dsim/configure.ac trunk/dsim/test/dsim/Makefile.am trunk/dsim/test/dsim/SimulationTestSuite.cpp Modified: trunk/dsim/configure.ac =================================================================== --- trunk/dsim/configure.ac 2010-06-13 19:41:41 UTC (rev 84) +++ trunk/dsim/configure.ac 2010-06-13 19:41:59 UTC (rev 85) @@ -138,6 +138,7 @@ fi AC_SUBST(CXXFLAGS_OPT) + # ----------------------------------------------------------------------------- # Support for ExtraCC (Extra-CruiseControl): http://sf.net/projects/extracc # ----------------------------------------------------------------------------- @@ -644,6 +645,11 @@ o XERCES_CFLAGS ... : ${XERCES_CFLAGS} o XERCES_LIBS ..... : ${XERCES_LIBS} + - ExtraCC ........... : + o EXTRACC_VERSION . : ${EXTRACC_VERSION} + o EXTRACC_CFLAGS .. : ${EXTRACC_CFLAGS} + o EXTRACC_LIBS .... : ${EXTRACC_LIBS} + - CPPUNIT............ : o CPPUNIT_VERSION . : ${CPPUNIT_VERSION} o CPPUNIT_CFLAGS .. : ${CPPUNIT_CFLAGS} Modified: trunk/dsim/test/dsim/Makefile.am =================================================================== --- trunk/dsim/test/dsim/Makefile.am 2010-06-13 19:41:41 UTC (rev 84) +++ trunk/dsim/test/dsim/Makefile.am 2010-06-13 19:41:59 UTC (rev 85) @@ -18,7 +18,7 @@ SimulationTestSuite_LDADD = SimulationTestSuite_LDFLAGS = \ $(BOOST_LIBS) $(CPPUNIT_LIBS) \ - $(top_builddir)/extracppunit/libextracc-extracppunit.la \ + $(top_builddir)/extracppunit/libextracppunit.la \ $(top_builddir)/stdair/core/libstdair.la \ $(top_builddir)/dsim/core/libdsim.la @@ -28,3 +28,4 @@ #simulate_LDFLAGS = $(BOOST_LIBS) \ # $(top_builddir)/stdair/core/libstdair.la \ # $(top_builddir)/dsim/core/libdsim.la + Modified: trunk/dsim/test/dsim/SimulationTestSuite.cpp =================================================================== --- trunk/dsim/test/dsim/SimulationTestSuite.cpp 2010-06-13 19:41:41 UTC (rev 84) +++ trunk/dsim/test/dsim/SimulationTestSuite.cpp 2010-06-13 19:41:59 UTC (rev 85) @@ -39,9 +39,9 @@ // Initialise the simulation context const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG, logOutputFile); - const stdair::BasDBParams lDBParams ("anguyen", "anguyen", - "ncemysqlp.nce.amadeus.net", "3321", - "sim_anguyen"); + const stdair::BasDBParams lDBParams ("dsim", "dsim", + "localhost", "3306", + "sim_dsim"); DSIM::DSIM_Service dsimService (lLogParams, lDBParams, lScheduleInputFilename, lDemandInputFilename); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-07-20 22:17:50
|
Revision: 102 http://dsim.svn.sourceforge.net/dsim/?rev=102&view=rev Author: denis_arnaud Date: 2010-07-20 22:17:42 +0000 (Tue, 20 Jul 2010) Log Message: ----------- [Doc] Added structure to generate documentation (with Doxygen). Modified Paths: -------------- trunk/dsim/COPYING trunk/dsim/Makefile.am trunk/dsim/configure.ac Added Paths: ----------- trunk/dsim/doc/Makefile.am trunk/dsim/doc/doxygen_html.cfg.in trunk/dsim/doc/images/ trunk/dsim/doc/images/Makefile trunk/dsim/doc/images/Makefile.am trunk/dsim/doc/images/Makefile.in trunk/dsim/doc/images/dsim_logo.png trunk/dsim/doc/images/dsim_logo.xcf trunk/dsim/doc/images/favicon.ico trunk/dsim/doc/images/sfx_logo.png trunk/dsim/doc/local/ trunk/dsim/doc/local/Makefile trunk/dsim/doc/local/Makefile.am trunk/dsim/doc/local/Makefile.in trunk/dsim/doc/local/authors.doc trunk/dsim/doc/local/codingrules.doc trunk/dsim/doc/local/copyright.doc trunk/dsim/doc/local/documentation.doc trunk/dsim/doc/local/dsim_footer.html trunk/dsim/doc/local/dsim_header.html trunk/dsim/doc/local/features.doc trunk/dsim/doc/local/help_wanted.doc trunk/dsim/doc/local/index.doc.in trunk/dsim/doc/local/installation.doc trunk/dsim/doc/local/linking.doc trunk/dsim/doc/local/sources.mk trunk/dsim/doc/local/test.doc trunk/dsim/doc/local/users_guide.doc trunk/dsim/doc/local/verification.doc trunk/dsim/doc/sourceforge/ trunk/dsim/doc/sourceforge/howto_release_dsim.html.in trunk/dsim/doc/sourceforge/howto_release_stdair.html trunk/dsim/doc/tutorial/ trunk/dsim/doc/tutorial/Makefile trunk/dsim/doc/tutorial/Makefile.am trunk/dsim/doc/tutorial/Makefile.in trunk/dsim/doc/tutorial/bpsk.doc trunk/dsim/doc/tutorial/convcode.doc trunk/dsim/doc/tutorial/interleaver.doc trunk/dsim/doc/tutorial/itfile.doc trunk/dsim/doc/tutorial/ldpc_bersim_awgn.doc trunk/dsim/doc/tutorial/ldpc_gen_codes.doc trunk/dsim/doc/tutorial/matlab_itpp.doc trunk/dsim/doc/tutorial/mimoconv.doc trunk/dsim/doc/tutorial/mog.doc trunk/dsim/doc/tutorial/qpsk_simulation.doc trunk/dsim/doc/tutorial/rayleigh.doc trunk/dsim/doc/tutorial/reedsolomon.doc trunk/dsim/doc/tutorial/sources.mk trunk/dsim/doc/tutorial/spread.doc trunk/dsim/doc/tutorial/src/ trunk/dsim/doc/tutorial/src/Makefile trunk/dsim/doc/tutorial/src/Makefile.am trunk/dsim/doc/tutorial/src/Makefile.in trunk/dsim/doc/tutorial/src/bpsk.cpp trunk/dsim/doc/tutorial/src/bpsk.ref trunk/dsim/doc/tutorial/src/convcode.cpp trunk/dsim/doc/tutorial/src/convcode.ref trunk/dsim/doc/tutorial/src/interleaver.cpp trunk/dsim/doc/tutorial/src/interleaver.ref trunk/dsim/doc/tutorial/src/ldpc_bersim_awgn.cpp trunk/dsim/doc/tutorial/src/ldpc_gen_codes.cpp trunk/dsim/doc/tutorial/src/mimoconv.cpp trunk/dsim/doc/tutorial/src/mog.cpp trunk/dsim/doc/tutorial/src/qpsk_simulation.cpp trunk/dsim/doc/tutorial/src/qpsk_simulation.ref trunk/dsim/doc/tutorial/src/rayleigh.cpp trunk/dsim/doc/tutorial/src/read_it_file.cpp trunk/dsim/doc/tutorial/src/reedsolomon.cpp trunk/dsim/doc/tutorial/src/reedsolomon.ref trunk/dsim/doc/tutorial/src/sources.mk trunk/dsim/doc/tutorial/src/spread.cpp trunk/dsim/doc/tutorial/src/spread.ref trunk/dsim/doc/tutorial/src/timer.cpp trunk/dsim/doc/tutorial/src/timer.ref trunk/dsim/doc/tutorial/src/vector_and_matrix.cpp trunk/dsim/doc/tutorial/src/vector_and_matrix.ref trunk/dsim/doc/tutorial/src/write_it_file.cpp trunk/dsim/doc/tutorial/timer.doc trunk/dsim/doc/tutorial/tutorial.doc trunk/dsim/doc/tutorial/vector_and_matrix.doc Property Changed: ---------------- trunk/dsim/doc/ trunk/dsim/test/master_slave/ Modified: trunk/dsim/COPYING =================================================================== --- trunk/dsim/COPYING 2010-07-16 14:15:14 UTC (rev 101) +++ trunk/dsim/COPYING 2010-07-20 22:17:42 UTC (rev 102) @@ -1,674 +1,504 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. - Preamble +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] - The GNU General Public License is a free, copyleft license for -software and other kinds of works. + Preamble - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. - The precise terms and conditions for copying, distribution and -modification follow. + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. - TERMS AND CONDITIONS + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. - 0. Definitions. + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. - "This License" refers to version 3 of the GNU General Public License. + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. - A "covered work" means either the unmodified Program or a work based -on the Program. + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) - 1. Source Code. + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. + a) The modified work must itself be a software library. - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. - The Corresponding Source for a work in source code form is that -same work. + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. - 2. Basic Permissions. + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. - 4. Conveying Verbatim Copies. + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. - 5. Conveying Modified Source Versions. + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: - 6. Conveying Non-Source Forms. + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with this License. - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. - 13. Use with the GNU Affero General Public License. +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. - 14. Revised Versions of this License. +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. - 15. Disclaimer of Warranty. + NO WARRANTY - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - 16. Limitation of Liability. + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE ... [truncated message content] |