[Opentrep-svn] SF.net SVN: opentrep:[119] trunk/opentrep
Status: Beta
Brought to you by:
denis_arnaud
From: <den...@us...> - 2009-07-12 12:59:06
|
Revision: 119 http://opentrep.svn.sourceforge.net/opentrep/?rev=119&view=rev Author: denis_arnaud Date: 2009-07-12 12:59:01 +0000 (Sun, 12 Jul 2009) Log Message: ----------- [Structure] Re-organised a little bit the hierarchy of directories, so as to add core, config and batches. Modified Paths: -------------- trunk/opentrep/config/soci.m4 trunk/opentrep/configure.ac trunk/opentrep/opentrep/Makefile.am trunk/opentrep/opentrep/dbadaptor/Makefile.am trunk/opentrep/opentrep/sources.mk trunk/opentrep/po/POTFILES.in trunk/opentrep/test/testIndexer.sh trunk/opentrep/test/testSearcher.sh Added Paths: ----------- trunk/opentrep/opentrep/batches/ trunk/opentrep/opentrep/batches/Makefile.am trunk/opentrep/opentrep/batches/indexer.cpp trunk/opentrep/opentrep/batches/searcher.cpp trunk/opentrep/opentrep/batches/sources.mk trunk/opentrep/opentrep/config/ trunk/opentrep/opentrep/config/Makefile.am trunk/opentrep/opentrep/core/ trunk/opentrep/opentrep/core/Makefile.am trunk/opentrep/opentrep/core/sources.mk Removed Paths: ------------- trunk/opentrep/opentrep/indexer.cpp trunk/opentrep/opentrep/searcher.cpp Property Changed: ---------------- trunk/opentrep/config/ trunk/opentrep/opentrep/ Property changes on: trunk/opentrep/config ___________________________________________________________________ Modified: svn:ignore - install-sh missing depcomp mdate-sh texinfo.tex ltmain.sh lib-ld.m4 lib-link.m4 lib-prefix.m4 config.rpath config.sub config.guess mkinstalldirs printf-posix.m4 uintmax_t.m4 signed.m4 iconv.m4 longlong.m4 inttypes.m4 glibc21.m4 codeset.m4 inttypes_h.m4 longdouble.m4 nls.m4 po.m4 intmax.m4 xsize.m4 lcmessage.m4 wint_t.m4 ulonglong.m4 progtest.m4 inttypes-pri.m4 stdint_h.m4 intdiv0.m4 isc-posix.m4 size_max.m4 gettext.m4 wchar_t.m4 + install-sh missing depcomp mdate-sh texinfo.tex ltmain.sh libtool.m4 lt~obsolete.m4 ltsugar.m4 ltversion.m4 ltoptions.m4 lib-ld.m4 lib-link.m4 lib-prefix.m4 config.rpath config.sub config.guess mkinstalldirs printf-posix.m4 uintmax_t.m4 signed.m4 iconv.m4 longlong.m4 inttypes.m4 glibc21.m4 codeset.m4 inttypes_h.m4 longdouble.m4 nls.m4 po.m4 intmax.m4 xsize.m4 lcmessage.m4 wint_t.m4 ulonglong.m4 progtest.m4 inttypes-pri.m4 stdint_h.m4 intdiv0.m4 isc-posix.m4 size_max.m4 gettext.m4 wchar_t.m4 Modified: trunk/opentrep/config/soci.m4 =================================================================== --- trunk/opentrep/config/soci.m4 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/config/soci.m4 2009-07-12 12:59:01 UTC (rev 119) @@ -4,115 +4,137 @@ dnl dnl We define the following configure script flags: dnl -dnl --with-soci: Give prefix for both library and headers, and try -dnl to guess subdirectory names for each. (e.g. add /lib and -dnl /include onto given dir names, and other common schemes.) +dnl --with-soci: Give prefix for both library and headers, and try +dnl to guess subdirectory names for each. (e.g. Tack /lib and +dnl /include onto given dir name, and other common schemes.) +dnl --with-soci-lib: Similar to --with-soci, but for library only. +dnl --with-soci-include: Similar to --with-soci, but for headers +dnl only. dnl -dnl @version 1.3, 2009/05/02 -dnl @author Denis Arnaud <den...@us...> -dnl dnl @version 1.2, 2007/02/20 dnl @author Warren Young <so...@et...> AC_DEFUN([AX_SOCI], [ -# -# Set up configure script macros -# -AC_ARG_WITH(soci, - [--with-soci=<path> root directory path of Soci installation], - [SOCI_lib_check="$with_soci/lib64/soci $with_soci/lib/soci $with_soci/lib64 $with_soci/lib" - SOCI_inc_check="$with_soci/include $with_soci/include/soci"], - [SOCI_lib_check="/usr/lib64 /usr/lib /usr/lib64/soci /usr/lib/soci /usr/local/lib64 /usr/local/lib /opt/soci/lib64 /opt/soci/lib /usr/local/lib64/soci /usr/local/lib/soci /usr/local/soci/lib64 /usr/local/soci/lib /opt/soci/lib64/soci /opt/soci/lib/soci" - SOCI_inc_check="/usr/include /usr/include/soci /usr/local/include /opt/soci/include /usr/local/include/soci /usr/local/soci/include /usr/local/soci/include/soci /opt/soci/include/soci"]) + # + # Set up configure script macros + # + AC_ARG_WITH(soci, + [ --with-soci=<path> root directory path of Soci installation], + [SOCI_lib_check="$with_soci/lib64/soci $with_soci/lib/soci $with_soci/lib64 $with_soci/lib" + SOCI_inc_check="$with_soci/include $with_soci/include/soci"], + [SOCI_lib_check="/usr/lib64 /usr/lib /usr/lib64/soci /usr/lib/soci /usr/local/lib64 /usr/local/lib /usr/local/lib/soci /usr/local/soci/lib /usr/local/soci/lib/soci /opt/soci/lib /opt/soci/lib/soci" + SOCI_inc_check="/usr/include /usr/include/soci /usr/local/include/soci /usr/local/soci/include /usr/local/soci/include/soci /opt/soci/include /opt/soci/include/soci"]) -# SOCI library -SOCI_CORE_LIB=soci_core -SOCI_MYSQL_LIB=soci_mysql + AC_ARG_WITH(soci-lib, + [ --with-soci-lib=<path> directory path of Soci library installation], + [SOCI_lib_check="$with_soci_lib $with_soci_lib/lib64 $with_soci_lib/lib $with_soci_lib/lib64/soci $with_soci_lib/lib/soci"]) -# -# Look for Soci Core API library -# -AC_MSG_CHECKING([for Soci library directory]) -SOCI_libdir= -for m in $SOCI_lib_check -do - if test -d "$m" && \ - (test -f "$m/lib$SOCI_CORE_LIB.so" || test -f "$m/lib$SOCI_CORE_LIB.a") + AC_ARG_WITH(soci-include, + [ --with-soci-include=<path> directory path of Soci header installation], + [SOCI_inc_check="$with_soci_include $with_soci_include/include $with_soci_include/include/soci"]) + + # SOCI library + SOCI_CORE_LIB=soci_core + SOCI_MYSQL_LIB=soci_mysql + SOCI_LIB_SUFFIX=gcc-3_0 + + # + # Look for Soci Core API library + # + AC_MSG_CHECKING([for Soci library directory]) + SOCI_libdir= + for m in $SOCI_lib_check + do + if test -d "$m" + then + for socilib in "$SOCI_CORE_LIB $SOCI_CORE_LIB-${SOCI_LIB_SUFFIX}" + do + if (test -f "$m/lib$SOCI_CORE_LIB.so" || test -f "$m/lib$SOCI_CORE_LIB.a") + then + SOCI_libdir=$m + fi + if (test -f "$m/lib${SOCI_CORE_LIB}-${SOCI_LIB_SUFFIX}.so" \ + || test -f "$m/lib${SOCI_CORE_LIB}-${SOCI_LIB_SUFFIX}.a") + then + SOCI_CORE_LIB=${SOCI_CORE_LIB}-${SOCI_LIB_SUFFIX} + SOCI_MYSQL_LIB=${SOCI_MYSQL_LIB}-${SOCI_LIB_SUFFIX} + SOCI_libdir=$m + fi + done + break + fi + done + + if test -z "$SOCI_libdir" then - SOCI_libdir=$m - break + AC_MSG_ERROR([Didn't find $SOCI_CORE_LIB library in '$SOCI_lib_check']) fi -done -if test -z "$SOCI_libdir" -then - AC_MSG_ERROR([Didn't find $SOCI_CORE_LIB library in '$SOCI_lib_check']) -fi + case "$SOCI_libdir" in + /* ) ;; + * ) AC_MSG_ERROR([The Soci library directory ($SOCI_libdir) must be an absolute path.]) ;; + esac -case "$SOCI_libdir" in - /* ) ;; - * ) AC_MSG_ERROR([The Soci library directory ($SOCI_libdir) must be an absolute path.]) ;; -esac + AC_MSG_RESULT([$SOCI_libdir]) -AC_MSG_RESULT([$SOCI_libdir]) + case "$SOCI_libdir" in + /usr/lib) ;; + *) LDFLAGS="$LDFLAGS -L${SOCI_libdir}" ;; + esac -case "$SOCI_libdir" in - /usr/lib64) ;; - /usr/lib) ;; - *) SOCI_LIBS="-L${SOCI_libdir}" ;; -esac -LDFLAGS="$LDFLAGS ${SOCI_LIBS}" + # + # Look for Soci Core API headers + # + AC_MSG_CHECKING([for Soci include directory]) + SOCI_incdir= + for m in $SOCI_inc_check + do + if test -d "$m" && (test -f "$m/soci/core/soci.h" || test -f "$m/soci/soci.h") + then + SOCI_incdir=$m + break + fi + done -# -# Look for Soci Core API headers -# -AC_MSG_CHECKING([for Soci include directory]) -SOCI_incdir= -for m in $SOCI_inc_check -do - if test -d "$m" && test -f "$m/soci/core/soci.h" + if test -z "$SOCI_incdir" then - SOCI_incdir=$m - break + AC_MSG_ERROR([Didn't find the Soci include dir in '$SOCI_inc_check']) fi -done -if test -z "$SOCI_incdir" -then - AC_MSG_ERROR([Didn't find the Soci include dir in '$SOCI_inc_check']) -fi + case "$SOCI_incdir" in + /* ) ;; + * ) AC_MSG_ERROR([The Soci include directory ($SOCI_incdir) must be an absolute path.]) ;; + esac -case "$SOCI_incdir" in - /* ) ;; - * ) AC_MSG_ERROR([The Soci include directory ($SOCI_incdir) must be an absolute path.]) ;; -esac + AC_MSG_RESULT([$SOCI_incdir]) -AC_MSG_RESULT([$SOCI_incdir]) + if test "$SOCI_incdir" != "/usr/include" + then + SOCI_CFLAGS="-I${SOCI_incdir}" + fi + if test "$SOCI_libdir" != "/usr/lib" -a "$SOCI_libdir" != "/usr/lib64" + 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" + AC_SUBST(SOCI_CFLAGS) + AC_SUBST(SOCI_LIBS) -case "$SOCI_incdir" in - /usr/include) ;; - *) SOCI_CFLAGS="-I${SOCI_incdir}" ;; -esac - -SOCI_LIBS="${SOCI_LIBS} -l${SOCI_CORE_LIB} -l${SOCI_MYSQL_LIB} -ldl" - -AC_SUBST(SOCI_CFLAGS) -AC_SUBST(SOCI_LIBS) - # Test linking with soci (note that it needs MySQL client to have been defined # before) -save_LIBS="$LIBS" -if test -z "$MYSQL_LIBS" -then - MYSQL_LIBS="-L/usr/lib64/mysql -L/usr/lib/mysql -lmysqlclient" -fi -LIBS="$LIBS $MYSQL_LIBS $SOCI_LIBS" -AC_CHECK_LIB($SOCI_CORE_LIB, soci_begin, - [], - [AC_MSG_ERROR([Could not find working Soci client library!])] - ) -LIBS="$save_LIBS" -AC_SUBST(SOCI_CORE_LIB) + save_LIBS="$LIBS" + if test -z "$MYSQL_LIBS" + then + MYSQL_LIBS="-L/usr/lib64/mysql -L/usr/lib/mysql -lmysqlclient" + fi + LIBS="$LIBS $MYSQL_LIBS $SOCI_LIBS" + AC_CHECK_LIB($SOCI_CORE_LIB, soci_begin, + [], + [AC_MSG_ERROR([Could not find working Soci client library!])] + ) + LIBS="$save_LIBS" + AC_SUBST(SOCI_CORE_LIB) ]) dnl AX_SOCI Modified: trunk/opentrep/configure.ac =================================================================== --- trunk/opentrep/configure.ac 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/configure.ac 2009-07-12 12:59:01 UTC (rev 119) @@ -218,6 +218,9 @@ opentrep/dbadaptor/Makefile opentrep/command/Makefile opentrep/service/Makefile + opentrep/config/Makefile + opentrep/core/Makefile + opentrep/batches/Makefile man/Makefile info/Makefile doc/Makefile Property changes on: trunk/opentrep/opentrep ___________________________________________________________________ Modified: svn:ignore - .libs .deps stamp-h1 config.h config.h.in Makefile Makefile.in opentrep-paths.hpp opentrep_indexer opentrep_searcher + .libs .deps stamp-h1 config.h config.h.in Makefile Makefile.in Modified: trunk/opentrep/opentrep/Makefile.am =================================================================== --- trunk/opentrep/opentrep/Makefile.am 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/opentrep/Makefile.am 2009-07-12 12:59:01 UTC (rev 119) @@ -7,7 +7,7 @@ MAINTAINERCLEANFILES = Makefile.in -SUBDIRS = basic bom factory dbadaptor command service +SUBDIRS = basic bom factory dbadaptor command service core config batches EXTRA_DIST = config_msvc.h @@ -24,33 +24,6 @@ $(top_builddir)/@PACKAGE@/service/libsvc.la lib@PACKAGE@_la_LDFLAGS = -version-info $(GENERIC_LIBRARY_VERSION) -# Binaries -bin_PROGRAMS = opentrep_indexer opentrep_searcher - -opentrep_indexer_SOURCES = $(bin_idx_h_sources) $(bin_idx_cc_sources) -opentrep_indexer_CXXFLAGS = $(BOOST_CFLAGS) -opentrep_indexer_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(SOCI_LIBS) -opentrep_indexer_LDADD = lib@PACKAGE@.la - -opentrep_searcher_SOURCES = $(bin_srh_h_sources) $(bin_srh_cc_sources) -opentrep_searcher_CXXFLAGS = $(BOOST_CFLAGS) -opentrep_searcher_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(SOCI_LIBS) -opentrep_searcher_LDADD = lib@PACKAGE@.la - # Header files nobase_pkginclude_HEADERS = $(service_h_sources) nobase_nodist_pkginclude_HEADERS = $(top_builddir)/@PACKAGE@/config.h - - -# Targets -all-local: @PACKAGE@-paths.hpp - -@PACKAGE@-paths.hpp: Makefile - @echo '#ifndef __OPENTREP_PATHS_HPP' > $@ - @echo '#define __OPENTREP_PATHS_HPP' >> $@ - @echo '#define PREFIXDIR "$(prefix)"' >> $@ - @echo '#define BINDIR "$(bindir)"' >> $@ - @echo '#define LIBEXECDIR "$(libexecdir)"' >> $@ - @echo '#define DATADIR "$(datadir)"' >> $@ - @echo '#define DOCDIR "$(docdir)"' >> $@ - @echo '#endif // __OPENTREP_PATHS_HPP' >> $@ Property changes on: trunk/opentrep/opentrep/batches ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile Makefile.in opentrep_indexer opentrep_searcher Added: trunk/opentrep/opentrep/batches/Makefile.am =================================================================== --- trunk/opentrep/opentrep/batches/Makefile.am (rev 0) +++ trunk/opentrep/opentrep/batches/Makefile.am 2009-07-12 12:59:01 UTC (rev 119) @@ -0,0 +1,23 @@ +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +## Source directory + +MAINTAINERCLEANFILES = Makefile.in + + +# Binaries (batches) +bin_PROGRAMS = opentrep_indexer opentrep_searcher + +opentrep_indexer_SOURCES = $(batches_idx_h_sources) $(batches_idx_cc_sources) +opentrep_indexer_CXXFLAGS = $(BOOST_CFLAGS) +#opentrep_indexer_LDADD = +opentrep_indexer_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(SOCI_LIBS) \ + $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la + + +opentrep_searcher_SOURCES = $(batches_srh_h_sources) $(batches_srh_cc_sources) +opentrep_searcher_CXXFLAGS = $(BOOST_CFLAGS) +#opentrep_searcher_LDADD = +opentrep_searcher_LDFLAGS = $(BOOST_PROGRAM_OPTIONS_LIB) $(SOCI_LIBS) \ + $(top_builddir)/@PACKAGE@/core/lib@PACKAGE@.la Copied: trunk/opentrep/opentrep/batches/indexer.cpp (from rev 114, trunk/opentrep/opentrep/indexer.cpp) =================================================================== --- trunk/opentrep/opentrep/batches/indexer.cpp (rev 0) +++ trunk/opentrep/opentrep/batches/indexer.cpp 2009-07-12 12:59:01 UTC (rev 119) @@ -0,0 +1,153 @@ +// C +#include <assert.h> +// STL +#include <iostream> +#include <sstream> +#include <fstream> +#include <map> +#include <vector> +// Boost (Extended STL) +#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/date_time/gregorian/gregorian.hpp> +#include <boost/program_options.hpp> +// OPENTREP +#include <opentrep/OPENTREP_Service.hpp> + +// ///////// 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; +} + +int readConfiguration (int argc, char* argv[]) { + int opt; + + // Declare a group of options that will be + // allowed only on command line + boost::program_options::options_description generic("Generic options"); + generic.add_options() + ("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() + ("optimization", + boost::program_options::value<int>(&opt)->default_value(10), + "optimization level") + ("include-path,I", + boost::program_options::value< std::vector<std::string> >()->composing(), + "include path"); + + // 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() + ("input-file", + boost::program_options::value< std::vector<std::string> >(), + "input file"); + + 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("input-file", -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 ("request_parser.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 0; + } + + if (vm.count ("version")) { + std::cout << "Open Travel Request Parser, version 1.0" << std::endl; + return 0; + } + + if (vm.count ("include-path")) { + std::cout << "Include paths are: " + << vm["include-path"].as< std::vector<std::string> >() + << std::endl; + } + + if (vm.count ("input-file")) { + std::cout << "Input files are: " + << vm["input-file"].as< std::vector<std::string> >() + << std::endl; + } + + std::cout << "Optimization level is " << opt << std::endl; + + return 0; +} + + +// /////////////// M A I N ///////////////// +int main (int argc, char* argv[]) { + try { + + // Output log File + std::string lLogFilename ("indexer.log"); + + // Xapian database name (directory of the index) + OPENTREP::TravelDatabaseName_T lXapianDatabaseName ("traveldb"); + + if (argc >= 1 && argv[1] != NULL) { + std::istringstream istr (argv[1]); + istr >> lLogFilename; + } + + if (argc >= 2 && argv[2] != NULL) { + std::istringstream istr (argv[2]); + istr >> lXapianDatabaseName; + } + + // Set the log parameters + std::ofstream logOutputFile; + // open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + // Initialise the context + OPENTREP::OPENTREP_Service opentrepService; + opentrepService.init (logOutputFile, lXapianDatabaseName); + + // Launch the indexation + opentrepService.buildSearchIndex(); + + // Close the Log outputFile + logOutputFile.close(); + + + } catch (const OPENTREP::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; +} Copied: trunk/opentrep/opentrep/batches/searcher.cpp (from rev 114, trunk/opentrep/opentrep/searcher.cpp) =================================================================== --- trunk/opentrep/opentrep/batches/searcher.cpp (rev 0) +++ trunk/opentrep/opentrep/batches/searcher.cpp 2009-07-12 12:59:01 UTC (rev 119) @@ -0,0 +1,160 @@ +// C +#include <assert.h> +// STL +#include <iostream> +#include <sstream> +#include <fstream> +#include <map> +#include <vector> +// Boost (Extended STL) +#include <boost/date_time/posix_time/posix_time.hpp> +#include <boost/date_time/gregorian/gregorian.hpp> +#include <boost/program_options.hpp> +// OPENTREP +#include <opentrep/OPENTREP_Service.hpp> + +// ///////// 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; +} + +int readConfiguration (int argc, char* argv[]) { + int opt; + + // Declare a group of options that will be + // allowed only on command line + boost::program_options::options_description generic("Generic options"); + generic.add_options() + ("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() + ("optimization", + boost::program_options::value<int>(&opt)->default_value(10), + "optimization level") + ("include-path,I", + boost::program_options::value< std::vector<std::string> >()->composing(), + "include path"); + + // 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() + ("input-file", + boost::program_options::value< std::vector<std::string> >(), + "input file"); + + 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("input-file", -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 ("request_parser.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 0; + } + + if (vm.count ("version")) { + std::cout << "Open Travel Request Parser, version 1.0" << std::endl; + return 0; + } + + if (vm.count ("include-path")) { + std::cout << "Include paths are: " + << vm["include-path"].as< std::vector<std::string> >() + << std::endl; + } + + if (vm.count ("input-file")) { + std::cout << "Input files are: " + << vm["input-file"].as< std::vector<std::string> >() + << std::endl; + } + + std::cout << "Optimization level is " << opt << std::endl; + + return 0; +} + + +// /////////////// M A I N ///////////////// +int main (int argc, char* argv[]) { + try { + + // Travel query + OPENTREP::TravelQuery_T lTravelQuery ("cdg"); + + // Output log File + std::string lLogFilename ("searcher.log"); + + // Xapian database name (directory of the index) + OPENTREP::TravelDatabaseName_T lXapianDatabaseName ("traveldb"); + + if (argc >= 1 && argv[1] != NULL) { + std::istringstream istr (argv[1]); + istr >> lTravelQuery; + } + + if (argc >= 2 && argv[2] != NULL) { + std::istringstream istr (argv[2]); + istr >> lLogFilename; + } + + if (argc >= 3 && argv[3] != NULL) { + std::istringstream istr (argv[3]); + istr >> lXapianDatabaseName; + } + + // Set the log parameters + std::ofstream logOutputFile; + // open and clean the log outputfile + logOutputFile.open (lLogFilename.c_str()); + logOutputFile.clear(); + + // Initialise the context + OPENTREP::OPENTREP_Service opentrepService; + opentrepService.init (logOutputFile, lXapianDatabaseName); + + // Query the Xapian database (index) + opentrepService.interpretTravelRequest (lTravelQuery); + + // Close the Log outputFile + logOutputFile.close(); + + } catch (const OPENTREP::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; +} Added: trunk/opentrep/opentrep/batches/sources.mk =================================================================== --- trunk/opentrep/opentrep/batches/sources.mk (rev 0) +++ trunk/opentrep/opentrep/batches/sources.mk 2009-07-12 12:59:01 UTC (rev 119) @@ -0,0 +1,4 @@ +batches_idx_h_sources = +batches_idx_cc_sources = $(top_srcdir)/opentrep/batches/indexer.cpp +batches_srh_h_sources = +batches_srh_cc_sources = $(top_srcdir)/opentrep/batches/searcher.cpp Property changes on: trunk/opentrep/opentrep/config ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile Makefile.in opentrep-paths.hpp Added: trunk/opentrep/opentrep/config/Makefile.am =================================================================== --- trunk/opentrep/opentrep/config/Makefile.am (rev 0) +++ trunk/opentrep/opentrep/config/Makefile.am 2009-07-12 12:59:01 UTC (rev 119) @@ -0,0 +1,25 @@ +include $(top_srcdir)/Makefile.common + +## Source directory + +DISTCLEANFILES = @PACKAGE@-paths.hpp + +MAINTAINERCLEANFILES = Makefile.in + +EXTRA_DIST = @PACKAGE@-paths.hpp + +# Targets +all-local: @PACKAGE@-paths.hpp + +@PACKAGE@-paths.hpp: Makefile + @echo '#ifndef __@PACKAGE_NAME@_PATHS_HPP' > $@ + @echo '#define __@PACKAGE_NAME@_PATHS_HPP' >> $@ + @echo '#define PACKAGE "@PACKAGE@"' >> $@ + @echo '#define PACKAGE_NAME "@PACKAGE_NAME@"' >> $@ + @echo '#define PACKAGE_VERSION "@VERSION@"' >> $@ + @echo '#define PREFIXDIR "$(prefix)"' >> $@ + @echo '#define BINDIR "$(bindir)"' >> $@ + @echo '#define LIBEXECDIR "$(libexecdir)"' >> $@ + @echo '#define DATADIR "$(datadir)"' >> $@ + @echo '#define DOCDIR "$(docdir)"' >> $@ + @echo '#endif // __@PACKAGE_NAME@_PATHS_HPP' >> $@ Property changes on: trunk/opentrep/opentrep/core ___________________________________________________________________ Added: svn:ignore + .deps .libs Makefile Makefile.in Added: trunk/opentrep/opentrep/core/Makefile.am =================================================================== --- trunk/opentrep/opentrep/core/Makefile.am (rev 0) +++ trunk/opentrep/opentrep/core/Makefile.am 2009-07-12 12:59:01 UTC (rev 119) @@ -0,0 +1,24 @@ +include $(top_srcdir)/Makefile.common +include $(srcdir)/sources.mk + +## Source directory + +MAINTAINERCLEANFILES = Makefile.in + +SUBDIRS = + + +# Library +lib_LTLIBRARIES = lib@PACKAGE@.la + +lib@PACKAGE@_la_SOURCES = $(service_h_sources) $(service_cc_sources) +lib@PACKAGE@_la_LIBADD = \ + $(top_builddir)/@PACKAGE@/basic/libbas.la \ + $(top_builddir)/@PACKAGE@/bom/libbom.la \ + $(top_builddir)/@PACKAGE@/factory/libfac.la \ + $(top_builddir)/@PACKAGE@/dbadaptor/libdba.la \ + $(top_builddir)/@PACKAGE@/command/libcmd.la \ + $(top_builddir)/@PACKAGE@/service/libsvc.la +lib@PACKAGE@_la_LDFLAGS = \ + $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) \ + $(SOCI_LIBS) -version-info $(GENERIC_LIBRARY_VERSION) Added: trunk/opentrep/opentrep/core/sources.mk =================================================================== --- trunk/opentrep/opentrep/core/sources.mk (rev 0) +++ trunk/opentrep/opentrep/core/sources.mk 2009-07-12 12:59:01 UTC (rev 119) @@ -0,0 +1,3 @@ +service_h_sources = $(top_srcdir)/opentrep/OPENTREP_Types.hpp \ + $(top_srcdir)/opentrep/OPENTREP_Service.hpp +service_cc_sources = Modified: trunk/opentrep/opentrep/dbadaptor/Makefile.am =================================================================== --- trunk/opentrep/opentrep/dbadaptor/Makefile.am 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/opentrep/dbadaptor/Makefile.am 2009-07-12 12:59:01 UTC (rev 119) @@ -3,16 +3,10 @@ include $(srcdir)/sources.mk noinst_LTLIBRARIES= libdba.la -if ENABLE_DEBUG -noinst_LTLIBRARIES += libdba_debug.la -endif + libdba_la_SOURCES= $(dba_h_sources) $(dba_cc_sources) libdba_la_CXXFLAGS = $(CXXFLAGS_OPT) $(SOCI_CFLAGS) libdba_la_LIBADD = $(SOCI_LIBS) -libdba_debug_la_SOURCES = $(dba_h_sources) $(dba_cc_sources) -libdba_debug_la_CXXFLAGS = $(CXXFLAGS_DEBUG) $(SOCI_CFLAGS) -libdba_debug_la_LIBADD = $(SOCI_LIBS) - #pkgincludedir = $(includedir)/@PACKAGE@/dba #pkginclude_HEADERS = $(dba_h_sources) Deleted: trunk/opentrep/opentrep/indexer.cpp =================================================================== --- trunk/opentrep/opentrep/indexer.cpp 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/opentrep/indexer.cpp 2009-07-12 12:59:01 UTC (rev 119) @@ -1,153 +0,0 @@ -// C -#include <assert.h> -// STL -#include <iostream> -#include <sstream> -#include <fstream> -#include <map> -#include <vector> -// Boost (Extended STL) -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/date_time/gregorian/gregorian.hpp> -#include <boost/program_options.hpp> -// OPENTREP -#include <opentrep/OPENTREP_Service.hpp> - -// ///////// 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; -} - -int readConfiguration (int argc, char* argv[]) { - int opt; - - // Declare a group of options that will be - // allowed only on command line - boost::program_options::options_description generic("Generic options"); - generic.add_options() - ("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() - ("optimization", - boost::program_options::value<int>(&opt)->default_value(10), - "optimization level") - ("include-path,I", - boost::program_options::value< std::vector<std::string> >()->composing(), - "include path"); - - // 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() - ("input-file", - boost::program_options::value< std::vector<std::string> >(), - "input file"); - - 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("input-file", -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 ("request_parser.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 0; - } - - if (vm.count ("version")) { - std::cout << "Open Travel Request Parser, version 1.0" << std::endl; - return 0; - } - - if (vm.count ("include-path")) { - std::cout << "Include paths are: " - << vm["include-path"].as< std::vector<std::string> >() - << std::endl; - } - - if (vm.count ("input-file")) { - std::cout << "Input files are: " - << vm["input-file"].as< std::vector<std::string> >() - << std::endl; - } - - std::cout << "Optimization level is " << opt << std::endl; - - return 0; -} - - -// /////////////// M A I N ///////////////// -int main (int argc, char* argv[]) { - try { - - // Output log File - std::string lLogFilename ("indexer.log"); - - // Xapian database name (directory of the index) - OPENTREP::TravelDatabaseName_T lXapianDatabaseName ("traveldb"); - - if (argc >= 1 && argv[1] != NULL) { - std::istringstream istr (argv[1]); - istr >> lLogFilename; - } - - if (argc >= 2 && argv[2] != NULL) { - std::istringstream istr (argv[2]); - istr >> lXapianDatabaseName; - } - - // Set the log parameters - std::ofstream logOutputFile; - // open and clean the log outputfile - logOutputFile.open (lLogFilename.c_str()); - logOutputFile.clear(); - - // Initialise the context - OPENTREP::OPENTREP_Service opentrepService; - opentrepService.init (logOutputFile, lXapianDatabaseName); - - // Launch the indexation - opentrepService.buildSearchIndex(); - - // Close the Log outputFile - logOutputFile.close(); - - - } catch (const OPENTREP::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; -} Deleted: trunk/opentrep/opentrep/searcher.cpp =================================================================== --- trunk/opentrep/opentrep/searcher.cpp 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/opentrep/searcher.cpp 2009-07-12 12:59:01 UTC (rev 119) @@ -1,160 +0,0 @@ -// C -#include <assert.h> -// STL -#include <iostream> -#include <sstream> -#include <fstream> -#include <map> -#include <vector> -// Boost (Extended STL) -#include <boost/date_time/posix_time/posix_time.hpp> -#include <boost/date_time/gregorian/gregorian.hpp> -#include <boost/program_options.hpp> -// OPENTREP -#include <opentrep/OPENTREP_Service.hpp> - -// ///////// 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; -} - -int readConfiguration (int argc, char* argv[]) { - int opt; - - // Declare a group of options that will be - // allowed only on command line - boost::program_options::options_description generic("Generic options"); - generic.add_options() - ("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() - ("optimization", - boost::program_options::value<int>(&opt)->default_value(10), - "optimization level") - ("include-path,I", - boost::program_options::value< std::vector<std::string> >()->composing(), - "include path"); - - // 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() - ("input-file", - boost::program_options::value< std::vector<std::string> >(), - "input file"); - - 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("input-file", -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 ("request_parser.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 0; - } - - if (vm.count ("version")) { - std::cout << "Open Travel Request Parser, version 1.0" << std::endl; - return 0; - } - - if (vm.count ("include-path")) { - std::cout << "Include paths are: " - << vm["include-path"].as< std::vector<std::string> >() - << std::endl; - } - - if (vm.count ("input-file")) { - std::cout << "Input files are: " - << vm["input-file"].as< std::vector<std::string> >() - << std::endl; - } - - std::cout << "Optimization level is " << opt << std::endl; - - return 0; -} - - -// /////////////// M A I N ///////////////// -int main (int argc, char* argv[]) { - try { - - // Travel query - OPENTREP::TravelQuery_T lTravelQuery ("cdg"); - - // Output log File - std::string lLogFilename ("searcher.log"); - - // Xapian database name (directory of the index) - OPENTREP::TravelDatabaseName_T lXapianDatabaseName ("traveldb"); - - if (argc >= 1 && argv[1] != NULL) { - std::istringstream istr (argv[1]); - istr >> lTravelQuery; - } - - if (argc >= 2 && argv[2] != NULL) { - std::istringstream istr (argv[2]); - istr >> lLogFilename; - } - - if (argc >= 3 && argv[3] != NULL) { - std::istringstream istr (argv[3]); - istr >> lXapianDatabaseName; - } - - // Set the log parameters - std::ofstream logOutputFile; - // open and clean the log outputfile - logOutputFile.open (lLogFilename.c_str()); - logOutputFile.clear(); - - // Initialise the context - OPENTREP::OPENTREP_Service opentrepService; - opentrepService.init (logOutputFile, lXapianDatabaseName); - - // Query the Xapian database (index) - opentrepService.interpretTravelRequest (lTravelQuery); - - // Close the Log outputFile - logOutputFile.close(); - - } catch (const OPENTREP::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/opentrep/opentrep/sources.mk =================================================================== --- trunk/opentrep/opentrep/sources.mk 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/opentrep/sources.mk 2009-07-12 12:59:01 UTC (rev 119) @@ -1,7 +1,4 @@ -service_h_sources = $(top_srcdir)/opentrep/OPENTREP_Types.hpp \ +service_h_sources = \ + $(top_srcdir)/opentrep/OPENTREP_Types.hpp \ $(top_srcdir)/opentrep/OPENTREP_Service.hpp service_cc_sources = -bin_idx_h_sources = -bin_idx_cc_sources = $(top_srcdir)/opentrep/indexer.cpp -bin_srh_h_sources = -bin_srh_cc_sources = $(top_srcdir)/opentrep/searcher.cpp Modified: trunk/opentrep/po/POTFILES.in =================================================================== --- trunk/opentrep/po/POTFILES.in 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/po/POTFILES.in 2009-07-12 12:59:01 UTC (rev 119) @@ -7,8 +7,8 @@ opentrep/service/Logger.hpp opentrep/service/OPENTREP_ServiceContext.cpp opentrep/service/OPENTREP_ServiceContext.hpp -opentrep/indexer.cpp -opentrep/searcher.cpp +opentrep/batches/indexer.cpp +opentrep/batches/searcher.cpp opentrep/dbadaptor/DbaPlace.hpp opentrep/dbadaptor/DbaAbstract.cpp opentrep/dbadaptor/DbaPlace.cpp Modified: trunk/opentrep/test/testIndexer.sh =================================================================== --- trunk/opentrep/test/testIndexer.sh 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/test/testIndexer.sh 2009-07-12 12:59:01 UTC (rev 119) @@ -1,7 +1,7 @@ #!/bin/sh INSTALL_DIR=`grep "^prefix =" ../Makefile | cut -d"=" -d" " -f3` -TST_PROG=../opentrep/opentrep_indexer +TST_PROG=../opentrep/batches/opentrep_indexer OPENTREP=`grep "^PACKAGE_VERSION =" ../Makefile | cut -d"=" -d" " -f3` OPENTREP_LIBRARY_NAME=`grep "^PACKAGE =" ../Makefile | cut -d"=" -d" " -f3` OPENTREP_LIB=lib${OPENTREP_LIBRARY_NAME}-${OPENTREP_API_VERSION}.so Modified: trunk/opentrep/test/testSearcher.sh =================================================================== --- trunk/opentrep/test/testSearcher.sh 2009-05-30 16:41:07 UTC (rev 118) +++ trunk/opentrep/test/testSearcher.sh 2009-07-12 12:59:01 UTC (rev 119) @@ -1,7 +1,7 @@ #!/bin/sh INSTALL_DIR=`grep "^prefix =" ../Makefile | cut -d"=" -d" " -f3` -TST_PROG=../opentrep/opentrep_searcher +TST_PROG=../opentrep/batches/opentrep_searcher OPENTREP=`grep "^PACKAGE_VERSION =" ../Makefile | cut -d"=" -d" " -f3` OPENTREP_LIBRARY_NAME=`grep "^PACKAGE =" ../Makefile | cut -d"=" -d" " -f3` OPENTREP_LIB=lib${OPENTREP_LIBRARY_NAME}-${OPENTREP_API_VERSION}.so This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |