|
From: <den...@us...> - 2009-07-06 12:50:33
|
Revision: 4
http://stdair.svn.sourceforge.net/stdair/?rev=4&view=rev
Author: denis_arnaud
Date: 2009-07-06 12:29:21 +0000 (Mon, 06 Jul 2009)
Log Message:
-----------
[Tests] Added the MPL testing sub-directory within test.
Modified Paths:
--------------
trunk/stdair/test/Makefile.am
Added Paths:
-----------
trunk/stdair/test/mpl/
trunk/stdair/test/mpl/Makefile.am
trunk/stdair/test/mpl/mpl.cpp
trunk/stdair/test/mpl/test_mpl.sh
Modified: trunk/stdair/test/Makefile.am
===================================================================
--- trunk/stdair/test/Makefile.am 2009-07-01 19:37:46 UTC (rev 3)
+++ trunk/stdair/test/Makefile.am 2009-07-06 12:29:21 UTC (rev 4)
@@ -4,7 +4,7 @@
MAINTAINERCLEANFILES = Makefile.in
##
-SUBDIRS = com
+SUBDIRS = com mpl
EXTRA_DIST =
##
Property changes on: trunk/stdair/test/mpl
___________________________________________________________________
Added: svn:ignore
+ .deps
.libs
Makefile.in
Makefile
mpl
Added: trunk/stdair/test/mpl/Makefile.am
===================================================================
--- trunk/stdair/test/mpl/Makefile.am (rev 0)
+++ trunk/stdair/test/mpl/Makefile.am 2009-07-06 12:29:21 UTC (rev 4)
@@ -0,0 +1,12 @@
+## command sub-directory
+include $(top_srcdir)/Makefile.common
+
+MAINTAINERCLEANFILES = Makefile.in
+
+check_PROGRAMS = mpl
+
+mpl_SOURCES = mpl.cpp
+mpl_CXXFLAGS = $(BOOST_CFLAGS)
+mpl_LDADD = $(BOOST_LIB)
+
+EXTRA_DIST = test_mpl.sh
Added: trunk/stdair/test/mpl/mpl.cpp
===================================================================
--- trunk/stdair/test/mpl/mpl.cpp (rev 0)
+++ trunk/stdair/test/mpl/mpl.cpp 2009-07-06 12:29:21 UTC (rev 4)
@@ -0,0 +1,83 @@
+// Marginal Revenue Transformation (method from T. Fiig & K. Isler)
+// STL
+#include <iostream>
+#include <sstream>
+#include <string>
+#include <vector>
+// MPL
+#include <boost/mpl/push_back.hpp>
+#include <boost/mpl/vector.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_same.hpp>
+
+// //////////////////////////////////////////////////////////////////
+namespace STDAIR {
+
+ /** BookingClass */
+ struct BookingClass {
+ std::string _classCode;
+ /** Constructor. */
+ BookingClass (const std::string& iClassCode)
+ : _classCode (iClassCode) {
+ }
+
+ /** Display .*/
+ std::string toString() const {
+ std::ostringstream oStr;
+ oStr << _classCode;
+ return oStr.str();
+ }
+ };
+
+ /** Cabin */
+ struct Cabin {
+ BookingClass _bookingClass;
+ Cabin (const BookingClass& iBkgClass)
+ : _bookingClass (iBkgClass) {
+ }
+
+ /** Display .*/
+ std::string toString() const {
+ std::ostringstream oStr;
+ oStr << _bookingClass._classCode;
+ return oStr.str();
+ }
+
+ /** Child type. */
+ typedef BookingClass child;
+ };
+
+}
+
+// /////////// M A I N ////////////////
+int main (int argc, char* argv[]) {
+
+ typedef boost::mpl::vector<STDAIR::BookingClass> MPL_BookingClass;
+ typedef boost::mpl::push_back<MPL_BookingClass, STDAIR::Cabin>::type types;
+
+ const STDAIR::BookingClass lA ("A");
+ const STDAIR::Cabin lCabin (lA);
+
+ // lCabin::type
+ if (boost::is_same<STDAIR::BookingClass, STDAIR::Cabin::child>::value) {
+ std::cout << "The type of the child of a Cabin is a BookingClass"
+ << std::endl;
+
+ } else {
+ std::cout << "The type of " << lCabin.toString() << " is unknown"
+ << std::endl;
+ }
+
+ if (boost::is_same<boost::mpl::at_c<types, 1>::type, STDAIR::Cabin>::value) {
+ std::cout << "The 2nd type is STDAIR::Cabin" << std::endl;
+
+ } else {
+ std::cout << "Problem!" << std::endl;
+ }
+
+ BOOST_MPL_ASSERT ((boost::is_same<boost::mpl::at_c<types, 1>::type,
+ STDAIR::Cabin>::value));
+
+ return 0;
+}
Added: trunk/stdair/test/mpl/test_mpl.sh
===================================================================
--- trunk/stdair/test/mpl/test_mpl.sh (rev 0)
+++ trunk/stdair/test/mpl/test_mpl.sh 2009-07-06 12:29:21 UTC (rev 4)
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+INSTALL_DIR=`grep "^prefix =" ../Makefile | cut -d"=" -d" " -f3`
+TST_PROG=./mpl
+LATUS_API_VERSION=`grep "^LATUS_API_VERSION =" ../Makefile | cut -d"=" -d" " -f3`
+LATUS_LIBRARY_NAME=`grep "^LATUS_LIBRARY_NAME =" ../Makefile | cut -d"=" -d" " -f3`
+LATUS_LIB=lib${LATUS_LIBRARY_NAME}-${LATUS_API_VERSION}.so
+
+if [ ! -x ${TST_PROG} ];
+then
+ echo "The sample program does not seem to have been compiled. Try 'make check' first."
+ exit -1
+fi
+
+if [ "$1" = "-h" -o "$1" = "-H" -o "$1" = "--h" -o "$1" = "--help" ];
+then
+ echo "Usage: $0 [<String to be parsed>]"
+ echo " The list to be parsed should contain floating point numbers"
+ echo " separated by commas, and should not contain spaces."
+ echo " Example: 10.2,5.4"
+ echo "The program parses a line and fills a flight-period structure."
+ exit 0
+fi
+
+${TST_PROG} $1
Property changes on: trunk/stdair/test/mpl/test_mpl.sh
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|