10 #include <boost/python.hpp>
12 #include <stdair/stdair_basic_types.hpp>
13 #include <stdair/stdair_exceptions.hpp>
14 #include <stdair/basic/BasFileMgr.hpp>
15 #include <stdair/basic/BasLogParams.hpp>
16 #include <stdair/basic/BasDBParams.hpp>
26 std::ostringstream oStream;
29 if (_logOutputStream == NULL) {
30 oStream <<
"The log filepath is not valid." << std::endl;
33 assert (_logOutputStream != NULL);
38 *_logOutputStream <<
"Python search for '" << iQuery <<
"'"
41 if (_trademgenService == NULL) {
42 oStream <<
"The Trademgen service has not been initialised, "
43 <<
"i.e., the init() method has not been called "
44 <<
"correctly on the Trademgener object. Please "
45 <<
"check that all the parameters are not empty and "
46 <<
"point to actual files.";
47 *_logOutputStream << oStream.str();
50 assert (_trademgenService != NULL);
56 *_logOutputStream <<
"Python search for '" << iQuery
57 <<
"' returned '" << std::endl;
60 *_logOutputStream <<
"TraDemGen output: "
61 << oStream.str() << std::endl;
63 }
catch (
const stdair::RootException& eTrademgenError) {
64 *_logOutputStream <<
"TraDemGen error: " << eTrademgenError.what()
67 }
catch (
const std::exception& eStdError) {
68 *_logOutputStream <<
"Error: " << eStdError.what() << std::endl;
71 *_logOutputStream <<
"Unknown error" << std::endl;
79 Trademgener() : _trademgenService (NULL), _logOutputStream (NULL) {
84 : _trademgenService (iTrademgener._trademgenService),
85 _logOutputStream (iTrademgener._logOutputStream) {
90 _trademgenService = NULL;
91 _logOutputStream = NULL;
95 bool init (
const std::string& iLogFilepath,
96 const stdair::RandomSeed_T& iRandomSeed,
97 const stdair::Filename_T& iDemandInputFilename,
98 const std::string& iDBUser,
const std::string& iDBPasswd,
99 const std::string& iDBHost,
const std::string& iDBPort,
100 const std::string& iDBDBName) {
101 bool isEverythingOK =
true;
106 const bool isWriteable = (iLogFilepath.empty() ==
false);
108 if (isWriteable ==
false) {
109 isEverythingOK =
false;
110 return isEverythingOK;
114 _logOutputStream =
new std::ofstream;
115 assert (_logOutputStream != NULL);
118 _logOutputStream->open (iLogFilepath.c_str());
119 _logOutputStream->clear();
122 *_logOutputStream <<
"Python wrapper initialisation" << std::endl;
123 const stdair::BasLogParams lLogParams (stdair::LOG::DEBUG,
127 stdair::BasDBParams lDBParams (iDBUser, iDBPasswd, iDBHost, iDBPort,
131 assert (_trademgenService != NULL);
137 *_logOutputStream <<
"Python wrapper initialised" << std::endl;
139 }
catch (
const stdair::RootException& eTrademgenError) {
140 *_logOutputStream <<
"Trademgen error: " << eTrademgenError.what()
143 }
catch (
const std::exception& eStdError) {
144 *_logOutputStream <<
"Error: " << eStdError.what() << std::endl;
147 *_logOutputStream <<
"Unknown error" << std::endl;
150 return isEverythingOK;
156 std::ofstream* _logOutputStream;
163 boost::python::class_<TRADEMGEN::Trademgener> (
"Trademgener")