Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
All of the examples use now the StringHelp class to simplify the string manipulation.
[simgrid.git] / examples / cxx / basic / Forwarder.cxx
index d5fcdec..8767ff7 100644 (file)
@@ -4,15 +4,14 @@
 #include <Host.hpp>\r
 #include <HostNotFoundException.hpp>\r
 \r
-#include <iostream>\r
-using namespace std;\r
+#include <Msg.hpp>\r
 \r
 MSG_IMPLEMENT_DYNAMIC(Forwarder, Process);\r
 \r
 \r
 int Forwarder::main(int argc, char** argv)\r
 {\r
-       cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl;\r
+       info("Hello");\r
        \r
        int slavesCount = argc;\r
        \r
@@ -26,8 +25,8 @@ int Forwarder::main(int argc, char** argv)
                } \r
                catch (HostNotFoundException e) \r
                {\r
-                       cerr << e.toString() << endl;\r
-                       cerr << "Buggy deployment file" << endl;\r
+                       error(TEXT_(e.toString()));\r
+                       error("Buggy deployment file");\r
                        exit(1);\r
                }\r
        }\r
@@ -40,21 +39,19 @@ int Forwarder::main(int argc, char** argv)
        \r
                if(t->isInstanceOf("FinalizeTask")) \r
                {\r
-                       cout << getName() << ":" << getHost().getName() << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl;\r
+                       info("All tasks have been dispatched. Let's tell everybody the computation is over.");\r
        \r
                        for (int cpt = 0; cpt< slavesCount; cpt++) \r
-                       {\r
                                slaves[cpt].put(0, new FinalizeTask());\r
-                       }\r
 \r
                        delete t;\r
 \r
                        break;\r
                }\r
 \r
-               cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << t->getName() << "\" " << endl;\r
+               info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" "));\r
        \r
-               cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << t->getName() << "\" to \"" << slaves[taskCount % slavesCount].getName() <<"\"" << endl;\r
+               info(TEXT_("Sending \"") + TEXT_(t->getName()) + TEXT_("\" to \"") + TEXT_(slaves[taskCount % slavesCount].getName()) + TEXT_("\""));\r
                \r
                slaves[taskCount % slavesCount].put(0, t);\r
        \r
@@ -62,7 +59,7 @@ int Forwarder::main(int argc, char** argv)
        }\r
        \r
        \r
-       cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl;\r
+       info("I'm done. See you!");\r
        \r
        delete[] slaves;\r
 \r