From: cherierm Date: Fri, 11 Jul 2008 15:13:11 +0000 (+0000) Subject: Some code refactoring X-Git-Tag: v3.3~242 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/eed6e6f89161ef7ed3c153aed6711ff8ce0df837 Some code refactoring git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5865 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/cxx/Application.cxx b/src/cxx/Application.cxx index ea249e6cbf..c188ffb854 100644 --- a/src/cxx/Application.cxx +++ b/src/cxx/Application.cxx @@ -133,6 +133,9 @@ namespace SimGrid surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg); surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty); surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess); + + // initialize the process factory used by the process handler to build the processes. + ApplicationHandler::onStartDocument(); surf_parse_open(file); diff --git a/src/cxx/Host.hpp b/src/cxx/Host.hpp index 1c18f0dd8a..02280975cf 100644 --- a/src/cxx/Host.hpp +++ b/src/cxx/Host.hpp @@ -58,6 +58,7 @@ catch(HostNotFoundException e) #include #include #include +#include diff --git a/src/cxx/Msg.cxx b/src/cxx/Msg.cxx index 443ac6b2f9..daac88e4b1 100644 --- a/src/cxx/Msg.cxx +++ b/src/cxx/Msg.cxx @@ -16,11 +16,21 @@ #include +#include +#include + #include #include -#include +#include +using std::cout; +using std::endl; +using std::streamsize; + +#include +using std::setprecision; +using std::setw; @@ -46,10 +56,72 @@ namespace SimGrid } + void info(const StringHelper& s) + { + StringHelper clock; + + cout << "["; + cout << Host::currentHost().getName(); + cout << ":"; + cout << Process::currentProcess().getName(); + cout << ":("; + cout << Process::currentProcess().getPID(); + cout << ") " ; + cout << clock.append(getClock(), "%07lf"); + cout << "] [cxx4msg/INFO] "; + cout << s; + cout << endl; + } + void info(const char* s) { - //INFO1("%s",s); - printf("[SimGridX/info] %s\n", s); + StringHelper clock; + + cout << "["; + cout << Host::currentHost().getName(); + cout << ":"; + cout << Process::currentProcess().getName(); + cout << ":("; + cout << Process::currentProcess().getPID(); + cout << ") " ; + cout << clock.append(getClock(), "%07lf"); + cout << "] [cxx4msg/INFO] "; + cout << s; + cout << endl; + } + + void error(const StringHelper& s) + { + StringHelper clock; + + cout << "["; + cout << Host::currentHost().getName(); + cout << ":"; + cout << Process::currentProcess().getName(); + cout << ":("; + cout << Process::currentProcess().getPID(); + cout << ") " ; + cout << clock.append(getClock(), "%07lf"); + cout << "] [cxx4msg/ERROR] "; + cout << s; + cout << endl; + } + + void error(const char* s) + { + StringHelper clock; + + cout << "["; + cout << Host::currentHost().getName(); + cout << ":"; + cout << Process::currentProcess().getName(); + cout << ":("; + cout << Process::currentProcess().getPID(); + cout << ") " ; + cout << clock.append(getClock(), "%07lf"); + cout << "] [cxx4msg/ERROR] "; + cout << s; + cout << endl; } double getClock(void) diff --git a/src/cxx/Msg.hpp b/src/cxx/Msg.hpp index 2ed2f96e29..048e38c7eb 100644 --- a/src/cxx/Msg.hpp +++ b/src/cxx/Msg.hpp @@ -24,6 +24,8 @@ #include #include +#include + namespace SimGrid { @@ -51,8 +53,15 @@ namespace SimGrid * * \param s The information to display. */ + SIMGRIDX_EXPORT void info(const StringHelper& s); + SIMGRIDX_EXPORT void info(const char* s); + SIMGRIDX_EXPORT void error(const StringHelper& s); + + SIMGRIDX_EXPORT void error(const char* s); + + /*! \brief getClock() - Retrieve the simulation time * * \return The current simulation time.