Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some code refactoring
authorcherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 11 Jul 2008 15:13:11 +0000 (15:13 +0000)
committercherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Fri, 11 Jul 2008 15:13:11 +0000 (15:13 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5865 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/cxx/Application.cxx
src/cxx/Host.hpp
src/cxx/Msg.cxx
src/cxx/Msg.hpp

index ea249e6..c188ffb 100644 (file)
@@ -133,6 +133,9 @@ namespace SimGrid
                        surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);\r
                        surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
                        surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);\r
+                       \r
+                       // initialize the process factory used by the process handler to build the processes.\r
+                       ApplicationHandler::onStartDocument();\r
 \r
                        surf_parse_open(file);\r
                        \r
index 1c18f0d..0228097 100644 (file)
@@ -58,6 +58,7 @@ catch(HostNotFoundException e)
 #include <BadAllocException.hpp>\r
 #include <HostNotFoundException.hpp>\r
 #include <MsgException.hpp>\r
+#include <NullPointerException.hpp>\r
 \r
 \r
 \r
index 443ac6b..daac88e 100644 (file)
 \r
 \r
 #include <Msg.hpp>\r
+#include <Host.hpp>\r
+#include <Process.hpp>\r
+\r
 \r
 #include <msg/msg.h>\r
 #include <msg/private.h>\r
-#include <stdio.h>\r
 \r
+#include <iostream>\r
+using std::cout;\r
+using std::endl;\r
+using std::streamsize;\r
+\r
+#include <iomanip>\r
+using std::setprecision;\r
+using std::setw;\r
 \r
 \r
 \r
@@ -46,10 +56,72 @@ namespace SimGrid
                        \r
                }\r
                \r
+               void info(const StringHelper& s)\r
+               {\r
+                       StringHelper clock;\r
+                       \r
+                       cout << "[";\r
+                       cout << Host::currentHost().getName();\r
+                       cout << ":";\r
+                       cout << Process::currentProcess().getName();\r
+                       cout << ":(";\r
+                       cout << Process::currentProcess().getPID();\r
+                       cout << ") " ;\r
+                       cout << clock.append(getClock(), "%07lf");\r
+                       cout << "] [cxx4msg/INFO] ";\r
+                       cout << s;\r
+                       cout << endl;\r
+               }\r
+\r
                void info(const char* s)\r
                {\r
-                        //INFO1("%s",s);\r
-                       printf("[SimGridX/info] %s\n", s);\r
+                       StringHelper clock;\r
+                       \r
+                       cout << "[";\r
+                       cout << Host::currentHost().getName();\r
+                       cout << ":";\r
+                       cout << Process::currentProcess().getName();\r
+                       cout << ":(";\r
+                       cout << Process::currentProcess().getPID();\r
+                       cout << ") " ;\r
+                       cout << clock.append(getClock(), "%07lf");\r
+                       cout << "] [cxx4msg/INFO] ";\r
+                       cout << s;\r
+                       cout << endl;\r
+               }\r
+\r
+               void error(const StringHelper& s)\r
+               {\r
+                       StringHelper clock;\r
+                       \r
+                       cout << "[";\r
+                       cout << Host::currentHost().getName();\r
+                       cout << ":";\r
+                       cout << Process::currentProcess().getName();\r
+                       cout << ":(";\r
+                       cout << Process::currentProcess().getPID();\r
+                       cout << ") " ;\r
+                       cout << clock.append(getClock(), "%07lf");\r
+                       cout << "] [cxx4msg/ERROR] ";\r
+                       cout << s;\r
+                       cout << endl;\r
+               }\r
+\r
+               void error(const char* s)\r
+               {\r
+                       StringHelper clock;\r
+                       \r
+                       cout << "[";\r
+                       cout << Host::currentHost().getName();\r
+                       cout << ":";\r
+                       cout << Process::currentProcess().getName();\r
+                       cout << ":(";\r
+                       cout << Process::currentProcess().getPID();\r
+                       cout << ") " ;\r
+                       cout << clock.append(getClock(), "%07lf");\r
+                       cout << "] [cxx4msg/ERROR] ";\r
+                       cout << s;\r
+                       cout << endl;\r
                }\r
 \r
                double getClock(void)\r
index 2ed2f96..048e38c 100644 (file)
@@ -24,6 +24,8 @@
 #include <InvalidArgumentException.hpp>\r
 #include <LogicException.hpp>\r
 \r
+#include <StringHelper.hpp>\r
+\r
 \r
 namespace SimGrid\r
 {\r
@@ -51,8 +53,15 @@ namespace SimGrid
                 *\r
                 * \param s                             The information to display.\r
                 */\r
+               SIMGRIDX_EXPORT void info(const StringHelper& s);\r
+\r
                SIMGRIDX_EXPORT void info(const char* s);\r
 \r
+               SIMGRIDX_EXPORT void error(const StringHelper& s);\r
+\r
+               SIMGRIDX_EXPORT void error(const char* s);\r
+\r
+\r
                /*! \brief getClock() -  Retrieve the simulation time\r
                 *\r
                 * \return                              The current simulation time.\r