From: cherierm Date: Fri, 11 Jul 2008 15:11:48 +0000 (+0000) Subject: All of the examples use now the StringHelp class to simplify the string manipulation. X-Git-Tag: v3.3~243 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/1282bea34802164b8173a518bcd379fd845bb684 All of the examples use now the StringHelp class to simplify the string manipulation. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5864 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/cxx/autoDestination/Forwarder.cxx b/examples/cxx/autoDestination/Forwarder.cxx index 24e23728a5..7953686088 100644 --- a/examples/cxx/autoDestination/Forwarder.cxx +++ b/examples/cxx/autoDestination/Forwarder.cxx @@ -5,15 +5,13 @@ #include #include -#include -using namespace std; +#include MSG_IMPLEMENT_DYNAMIC(Forwarder, Process); - int Forwarder::main(int argc, char** argv) { - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); int aliasCount = argc; @@ -29,7 +27,7 @@ int Forwarder::main(int argc, char** argv) if(taskReceived->isInstanceOf("FinalizeTask")) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; + info("All tasks have been dispatched. Let's tell everybody the computation is over."); for (int i = 0; i < aliasCount; i++) { @@ -44,9 +42,9 @@ int Forwarder::main(int argc, char** argv) basicTask = reinterpret_cast(taskReceived); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << basicTask->getName() << "\" " << endl; + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << basicTask->getName() << "\" to \"" << argv[taskCount % aliasCount] << "\"" << endl; + info(TEXT_("Sending \"") + TEXT_(basicTask->getName()) + TEXT_("\" to \"") + TEXT_(argv[taskCount % aliasCount])); basicTask->send(argv[taskCount % aliasCount]); @@ -54,7 +52,7 @@ int Forwarder::main(int argc, char** argv) } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl; + info("I'm done. See you!"); delete this; diff --git a/examples/cxx/autoDestination/Master.cxx b/examples/cxx/autoDestination/Master.cxx index 9a2d9151f1..0fc3a1bbca 100644 --- a/examples/cxx/autoDestination/Master.cxx +++ b/examples/cxx/autoDestination/Master.cxx @@ -5,29 +5,26 @@ #include #include -#include -using namespace std; +#include + + -#ifndef BUFFMAX -#define BUFFMAX 260 -#endif MSG_IMPLEMENT_DYNAMIC(Master, Process); int Master::main(int argc, char** argv) { - char buff[BUFFMAX + 1] = {0}; int taskCount; double taskComputeSize; double taskCommunicateSize; - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "argc=" << argc << endl; + info(TEXT_("argc=") + TEXT_(argc)); for (int i = 0; i< argc; i++) - cout << "argv:" << argv[i] << endl; + info(TEXT_("argv:") + TEXT_(argv[i])); sscanf(argv[0],"%d", &taskCount); sscanf(argv[1],"%lg", &taskComputeSize); @@ -36,11 +33,7 @@ int Master::main(int argc, char** argv) BasicTaskPtr* basicTasks = new BasicTaskPtr[taskCount]; for (int i = 0; i < taskCount; i++) - { - sprintf(buff,"Task_%d",i); - basicTasks[i] = new BasicTask(buff, taskComputeSize, taskCommunicateSize); - memset(buff, 0 , BUFFMAX + 1); - } + basicTasks[i] = new BasicTask((TEXT_("Task_") + TEXT_(i)), taskComputeSize, taskCommunicateSize); int aliasCount = argc - 3; @@ -49,27 +42,27 @@ int Master::main(int argc, char** argv) for(int i = 3; i < argc ; i++) aliases[i - 3] = _strdup(argv[i]); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got "<< aliasCount << " alias(es) :" << endl; + info(TEXT_("Got ") + TEXT_(aliasCount) + TEXT_(" alias(es) :")); for (int i = 0; i < aliasCount; i++) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\t" << aliases[i] << endl; + info(TEXT_("\t") + TEXT_(aliases[i])); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got "<< taskCount << " task to process." << endl; + info(TEXT_("Got ") + TEXT_(taskCount) + TEXT_(" task to process.")); for (int i = 0; i < taskCount; i++) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << basicTasks[i]->getName() << "\" to \"" << aliases[i % aliasCount] << "\"" << endl; + info(TEXT_("Sending \"") + TEXT_(basicTasks[i]->getName()) + TEXT_("\" to \"") + TEXT_(aliases[i % aliasCount]) + TEXT_("\"")); /*if((Host::currentHost().getName()).equals((aliases[i % aliasCount].split(":"))[0])) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hey ! It's me ! "; + info("Hey ! It's me ! "); */ basicTasks[i]->send(aliases[i % aliasCount]); } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Send completed" << endl; + info("Send completed"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; + info("All tasks have been dispatched. Let's tell everybody the computation is over."); FinalizeTask* finalizeTask; @@ -80,7 +73,7 @@ int Master::main(int argc, char** argv) } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Goodbye now!" << endl; + info("Goodbye now!"); delete[] basicTasks; delete[] aliases; diff --git a/examples/cxx/autoDestination/Slave.cxx b/examples/cxx/autoDestination/Slave.cxx index 8df47121c1..31316d5bd6 100644 --- a/examples/cxx/autoDestination/Slave.cxx +++ b/examples/cxx/autoDestination/Slave.cxx @@ -5,14 +5,13 @@ #include #include -#include -using namespace std; +#include MSG_IMPLEMENT_DYNAMIC(Slave, Process); int Slave::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); Task* receivedTask; BasicTask* basicTask; @@ -29,18 +28,18 @@ int Slave::main(int argc, char** argv) basicTask = reinterpret_cast(receivedTask); - cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Received \"" << basicTask->getName() << "\" " << endl; + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Processing \"" << basicTask->getName() << "\" " << endl; + info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); basicTask->execute(); - cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "\"" << basicTask->getName() << "\" done " << endl; + info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done ")); delete basicTask; } - cout <<"[" << getName() << ":" << getHost().getName() << ": PID " << getPID() << "] " << "Received Finalize. I'm done. See you!" << endl; + info("Received Finalize. I'm done. See you!"); delete this; diff --git a/examples/cxx/basic/Forwarder.cxx b/examples/cxx/basic/Forwarder.cxx index d5fcdecfb7..8767ff7c46 100644 --- a/examples/cxx/basic/Forwarder.cxx +++ b/examples/cxx/basic/Forwarder.cxx @@ -4,15 +4,14 @@ #include #include -#include -using namespace std; +#include MSG_IMPLEMENT_DYNAMIC(Forwarder, Process); int Forwarder::main(int argc, char** argv) { - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); int slavesCount = argc; @@ -26,8 +25,8 @@ int Forwarder::main(int argc, char** argv) } catch (HostNotFoundException e) { - cerr << e.toString() << endl; - cerr << "Buggy deployment file" << endl; + error(TEXT_(e.toString())); + error("Buggy deployment file"); exit(1); } } @@ -40,21 +39,19 @@ int Forwarder::main(int argc, char** argv) if(t->isInstanceOf("FinalizeTask")) { - cout << getName() << ":" << getHost().getName() << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; + info("All tasks have been dispatched. Let's tell everybody the computation is over."); for (int cpt = 0; cpt< slavesCount; cpt++) - { slaves[cpt].put(0, new FinalizeTask()); - } delete t; break; } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << t->getName() << "\" " << endl; + info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" ")); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << t->getName() << "\" to \"" << slaves[taskCount % slavesCount].getName() <<"\"" << endl; + info(TEXT_("Sending \"") + TEXT_(t->getName()) + TEXT_("\" to \"") + TEXT_(slaves[taskCount % slavesCount].getName()) + TEXT_("\"")); slaves[taskCount % slavesCount].put(0, t); @@ -62,7 +59,7 @@ int Forwarder::main(int argc, char** argv) } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl; + info("I'm done. See you!"); delete[] slaves; diff --git a/examples/cxx/basic/Main.cxx b/examples/cxx/basic/Main.cxx index dbda264803..9f399a8be3 100644 --- a/examples/cxx/basic/Main.cxx +++ b/examples/cxx/basic/Main.cxx @@ -8,5 +8,5 @@ main(int argc, char* argv[]) Simulation s; return s.execute(argc, argv); - + } diff --git a/examples/cxx/basic/Master.cxx b/examples/cxx/basic/Master.cxx index cec35f140f..f49f4b99af 100644 --- a/examples/cxx/basic/Master.cxx +++ b/examples/cxx/basic/Master.cxx @@ -23,22 +23,24 @@ int Master::main(int argc, char** argv) int numberOfTasks; double taskComputeSize; double taskCommunicateSize; + StringHelper s; if (argc < 3) { - cerr <<"Master needs 3 arguments" << endl; + error("Master needs 3 arguments"); exit(1); } - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); int slaveCount = 0; Host* slaves = NULL; + - cout << "argc=" << argc << endl; + info( TEXT_("argc=") + TEXT_(argc)); for (int i = 0; i< argc; i++) - cout << "argv:" << argv[i] << endl; + info(TEXT_("argv:") + TEXT_(argv[i])); sscanf(argv[0],"%d", &numberOfTasks); @@ -49,11 +51,7 @@ int Master::main(int argc, char** argv) BasicTaskPtr* todo = new BasicTaskPtr[numberOfTasks]; for (int i = 0; i < numberOfTasks; i++) - { - sprintf(buff,"Task_%d",i); - todo[i] = new BasicTask(buff, taskComputeSize, taskCommunicateSize); - memset(buff, 0 , BUFFMAX + 1); - } + todo[i] = new BasicTask((TEXT_("Task_") + TEXT_(i)), taskComputeSize, taskCommunicateSize); slaveCount = argc - 3; slaves = new Host[slaveCount]; @@ -71,27 +69,27 @@ int Master::main(int argc, char** argv) exit(1); } } - - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got slave(s) :" << slaveCount << endl; + + info(TEXT_("Got slave(s) :") + TEXT_(slaveCount)); for (int i = 0; i < slaveCount; i++) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\t" << slaves[i].getName() << endl; + info(TEXT_("\t") + TEXT_(slaves[i].getName())); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got " << numberOfTasks << " task to process." << endl; + info(TEXT_("Got ") + TEXT_(numberOfTasks) + TEXT_(" task to process.")); for (int i = 0; i < numberOfTasks; i++) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << todo[i]->getName() << "\" to \"" << slaves[i % slaveCount].getName() << "\"" << endl; + info(TEXT_("Sending \"") + TEXT_(todo[i]->getName()) + TEXT_("\" to \"") + TEXT_(slaves[i % slaveCount].getName()) + TEXT_("\"")); if(!strcmp(Host::currentHost().getName(), slaves[i % slaveCount].getName())) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hey ! It's me ! "; + info("Hey ! It's me ! "); slaves[i % slaveCount].put(channel, todo[i]); } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Send completed" << endl; + info("Send completed"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; + info("All tasks have been dispatched. Let's tell everybody the computation is over."); for (int i = 0; i < slaveCount; i++) slaves[i].put(channel, new FinalizeTask()); @@ -99,7 +97,7 @@ int Master::main(int argc, char** argv) delete[] todo; delete[] slaves; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Goodbye now!" << endl; + info("Goodbye now!"); delete this; diff --git a/examples/cxx/basic/Slave.cxx b/examples/cxx/basic/Slave.cxx index 10be8fca4a..b1a914eec1 100644 --- a/examples/cxx/basic/Slave.cxx +++ b/examples/cxx/basic/Slave.cxx @@ -6,11 +6,13 @@ #include using namespace std; +#include + MSG_IMPLEMENT_DYNAMIC(Slave, Process); int Slave::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello");; while(true) { @@ -22,18 +24,18 @@ int Slave::main(int argc, char** argv) break; } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << t->getName() << "\" " << endl; + info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" ")); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Processing \"" << t->getName() << "\" " << endl; + info(TEXT_("Processing \"") + TEXT_(t->getName())); t->execute(); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\"" << t->getName() << "\" done " << endl; + info(TEXT_("\"") + TEXT_(t->getName()) + TEXT_("\" done ")); delete t; } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received Finalize. I'm done. See you!" << endl; + info("Received Finalize. I'm done. See you!"); delete this; diff --git a/examples/cxx/comm_time/Master.cxx b/examples/cxx/comm_time/Master.cxx index c68e8475e2..662c3d2236 100644 --- a/examples/cxx/comm_time/Master.cxx +++ b/examples/cxx/comm_time/Master.cxx @@ -5,31 +5,24 @@ #include #include -#include -using namespace std; - - -#ifndef BUFFMAX -#define BUFFMAX 260 -#endif +#include MSG_IMPLEMENT_DYNAMIC(Master, Process); int Master::main(int argc, char** argv) { int channel = 0; - char buff[BUFFMAX + 1] = {0}; int numberOfTasks; double taskComputeSize; double taskCommunicateSize; if (argc < 3) { - cerr <<"Master needs 3 arguments" << endl; + error("Master needs 3 arguments"); exit(1); } - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); int slaveCount = 0; Host* slaves = NULL; @@ -53,37 +46,36 @@ int Master::main(int argc, char** argv) catch(HostNotFoundException e) { - cerr << e.toString() <<". Stopping Now!" << endl; + error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); exit(1); } } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got slave(s) :" << slaveCount << endl; + info(TEXT_("Got slave(s) :" ) + TEXT_(slaveCount)); for (int i = 0; i < slaveCount; i++) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\t" << slaves[i].getName() << endl; + info(TEXT_("\t") + TEXT_(slaves[i].getName())); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got " << numberOfTasks << " task to process." << endl; + info(TEXT_("Got ") + TEXT_(numberOfTasks) + TEXT_(" task to process.")); for (int i = 0; i < numberOfTasks; i++) { - sprintf(buff,"Task_%d",i); - CommTimeTask* task = new CommTimeTask(buff, taskComputeSize, taskCommunicateSize); + CommTimeTask* task = new CommTimeTask(TEXT_("Task_") + TEXT_(i), taskComputeSize, taskCommunicateSize); task->setTime(getClock()); slaves[i % slaveCount].put(0, task); - memset(buff, 0 , BUFFMAX + 1); + } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; + info("All tasks have been dispatched. Let's tell everybody the computation is over."); for (int i = 0; i < slaveCount; i++) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Finalize host " << slaves[i].getName() << " [" << i << "]" << endl; + info(TEXT_("Finalize host ") + TEXT_(slaves[i].getName()) + TEXT_(" [") + TEXT_(i) + TEXT_("]")); slaves[i].put(0, new FinalizeTask()); } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All finalize messages have been dispatched. Goodbye now!" << endl; + info("All finalize messages have been dispatched. Goodbye now!"); delete[] slaves; diff --git a/examples/cxx/comm_time/Slave.cxx b/examples/cxx/comm_time/Slave.cxx index 4a3a78bfe0..e1b41e8801 100644 --- a/examples/cxx/comm_time/Slave.cxx +++ b/examples/cxx/comm_time/Slave.cxx @@ -5,14 +5,13 @@ #include #include -#include -using namespace std; +#include MSG_IMPLEMENT_DYNAMIC(Slave, Process); int Slave::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); while(true) { @@ -31,14 +30,14 @@ int Slave::main(int argc, char** argv) if(time1 < task->getTime()) time1 = task->getTime(); - // cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Processing \"" << task->getName() << "\" " << getHost().getName() << " (Communication time : " << (time2 - time1) << ")" << endl; + //info(TEXT_("Processing \"") + TEXT_(task->getName()) + TEXT_("\" ") + TEXT_(getHost().getName()) + TEXT_(" (Communication time : ") + TEXT_((time2 - time1)) + TEXT_(")")); task->execute(); delete task; } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received Finalize. I'm done. See you!" << endl; + info(TEXT_("Received Finalize. I'm done. See you!")); delete this; return 0; diff --git a/examples/cxx/explicitDestination/Forwarder.cxx b/examples/cxx/explicitDestination/Forwarder.cxx index 6ed093ccf9..f7220cd970 100644 --- a/examples/cxx/explicitDestination/Forwarder.cxx +++ b/examples/cxx/explicitDestination/Forwarder.cxx @@ -5,15 +5,15 @@ #include #include -#include -using namespace std; +#include + MSG_IMPLEMENT_DYNAMIC(Forwarder, Process); int Forwarder::main(int argc, char** argv) { - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); int aliasCount = argc; @@ -29,7 +29,7 @@ int Forwarder::main(int argc, char** argv) if(taskReceived->isInstanceOf("FinalizeTask")) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; + info("All tasks have been dispatched. Let's tell everybody the computation is over."); for (int i = 0; i < aliasCount; i++) { @@ -44,9 +44,9 @@ int Forwarder::main(int argc, char** argv) basicTask = reinterpret_cast(taskReceived); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << basicTask->getName() << "\" " << endl; + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << basicTask->getName() << "\" to \"" << argv[taskCount % aliasCount] << "\"" << endl; + info(TEXT_("Sending \"") + TEXT_(basicTask->getName()) + TEXT_("\" to \"") + TEXT_(argv[taskCount % aliasCount]) + TEXT_("\"")); basicTask->send(argv[taskCount % aliasCount]); @@ -54,7 +54,7 @@ int Forwarder::main(int argc, char** argv) } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "I'm done. See you!" << endl; + info("I'm done. See you!"); delete this; return 0; diff --git a/examples/cxx/explicitDestination/Master.cxx b/examples/cxx/explicitDestination/Master.cxx index 9184ee4199..cd83fe6b75 100644 --- a/examples/cxx/explicitDestination/Master.cxx +++ b/examples/cxx/explicitDestination/Master.cxx @@ -5,30 +5,23 @@ #include #include -#include -using namespace std; - - -#ifndef BUFFMAX -#define BUFFMAX 260 -#endif +#include MSG_IMPLEMENT_DYNAMIC(Master, Process); int Master::main(int argc, char** argv) { - char buff[BUFFMAX + 1] = {0}; int taskCount; double taskComputeSize; double taskCommunicateSize; - cout << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "argc=" << argc << endl; + info(TEXT_("argc=") + TEXT_(argc)); for (int i = 0; i< argc; i++) - cout << "argv:" << argv[i] << endl; + info(TEXT_("argv:") + TEXT_(argv[i])); sscanf(argv[0],"%d", &taskCount); @@ -39,41 +32,37 @@ int Master::main(int argc, char** argv) BasicTaskPtr* basicTasks = new BasicTaskPtr[taskCount]; for (int i = 0; i < taskCount; i++) - { - sprintf(buff,"Task_%d",i); - basicTasks[i] = new BasicTask(buff, taskComputeSize, taskCommunicateSize); - memset(buff, 0 , BUFFMAX + 1); - } + basicTasks[i] = new BasicTask(TEXT_("Task_") + TEXT_(i), taskComputeSize, taskCommunicateSize); int aliasCount = argc - 3; - char** aliases = (char**) calloc(aliasCount, sizeof(char*)); for(int i = 3; i < argc ; i++) aliases[i - 3] = _strdup(argv[i]); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got "<< aliasCount << " alias(es) :" << endl; + info(TEXT_("Got ") + TEXT_(aliasCount) + TEXT_(" alias(es) :")); for (int i = 0; i < aliasCount; i++) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\t" << aliases[i] << endl; + info(TEXT_("\t") + TEXT_(aliases[i])); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got "<< taskCount << " task to process." << endl; + info(TEXT_("Got ") + TEXT_(taskCount) + TEXT_(" task to process.")); for (int i = 0; i < taskCount; i++) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Sending \"" << basicTasks[i]->getName() << "\" to \"" << aliases[i % aliasCount] << "\"" << endl; + info(TEXT_("Sending \"") + TEXT_(basicTasks[i]->getName()) + TEXT_("\" to \"") + TEXT_(aliases[i % aliasCount]) + TEXT_("\"")); + /*if((Host::currentHost().getName()).equals((aliases[i % aliasCount].split(":"))[0])) - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hey ! It's me ! "; + info("Hey ! It's me ! "); */ basicTasks[i]->send(aliases[i % aliasCount]); } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Send completed" << endl; + info("Send completed"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "All tasks have been dispatched. Let's tell everybody the computation is over." << endl; + info("All tasks have been dispatched. Let's tell everybody the computation is over."); FinalizeTask* finalizeTask; @@ -84,7 +73,7 @@ int Master::main(int argc, char** argv) } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Goodbye now!" << endl; + info("Goodbye now!"); delete[] basicTasks; delete[] aliases; diff --git a/examples/cxx/explicitDestination/Slave.cxx b/examples/cxx/explicitDestination/Slave.cxx index 6b4de500f8..c7ebc3138d 100644 --- a/examples/cxx/explicitDestination/Slave.cxx +++ b/examples/cxx/explicitDestination/Slave.cxx @@ -5,14 +5,14 @@ #include #include -#include +#include using namespace std; MSG_IMPLEMENT_DYNAMIC(Slave, Process); int Slave::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); Task* receivedTask; BasicTask* basicTask; @@ -29,16 +29,16 @@ int Slave::main(int argc, char** argv) basicTask = reinterpret_cast(receivedTask); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received \"" << basicTask->getName() << "\" " << endl; + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Processing \"" << basicTask->getName() << "\" " << endl; + info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); basicTask->execute(); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "\"" << basicTask->getName() << "\" done " << endl; + info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done ")); delete basicTask; } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Received Finalize. I'm done. See you!" << endl; + info("Received Finalize. I'm done. See you!"); delete this; return 0; diff --git a/examples/cxx/ping_pong/Receiver.cxx b/examples/cxx/ping_pong/Receiver.cxx index fec2c36152..41ad22013c 100644 --- a/examples/cxx/ping_pong/Receiver.cxx +++ b/examples/cxx/ping_pong/Receiver.cxx @@ -4,8 +4,7 @@ #include #include -#include -using namespace std; +#include MSG_IMPLEMENT_DYNAMIC(Receiver, Process); @@ -14,11 +13,12 @@ const double commSizeBw = 100000000; int Receiver::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); double communicationTime=0; double time = getClock(); + StringHelper bw; - cout <<"[" << getName() << ":" << getHost().getName() << "try to get a task" << endl; + info("Try to get a task"); PingPongTask* task = reinterpret_cast(Task::get(0)); @@ -27,18 +27,18 @@ int Receiver::main(int argc, char** argv) delete task; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Got at time " << timeGot << endl; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Was sent at time " << timeSent << endl; + info(TEXT_("Got at time ") + TEXT_(timeGot)); + info(TEXT_("Was sent at time ") + TEXT_(timeSent)); time = timeSent; communicationTime = timeGot - time; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Communication time : " << communicationTime << endl; + info(TEXT_( "Communication time : ") + TEXT_(communicationTime)); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << " --- bw " << commSizeBw/communicationTime << " ----" << endl; + info(TEXT_(" --- BW ") + bw.append(commSizeBw/communicationTime,"%07lf") + TEXT_(" ----")); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "goodbye!" << endl; + info("Goodbye!"); delete this; diff --git a/examples/cxx/ping_pong/Sender.cxx b/examples/cxx/ping_pong/Sender.cxx index d0518bab87..8c3f364c86 100644 --- a/examples/cxx/ping_pong/Sender.cxx +++ b/examples/cxx/ping_pong/Sender.cxx @@ -4,7 +4,7 @@ #include #include -#include +#include using namespace std; const double commSizeLat = 1; @@ -14,11 +14,11 @@ MSG_IMPLEMENT_DYNAMIC(Sender, Process); int Sender::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); int hostCount = argc; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "host count : " << hostCount << endl; + info(TEXT_("Host count : ") + TEXT_(hostCount)); Host* hostTable = new Host[hostCount]; double time; @@ -33,7 +33,7 @@ int Sender::main(int argc, char** argv) } catch(HostNotFoundException e) { - cerr << e.toString() <<". Stopping Now!" << endl; + error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); exit(1); } } @@ -42,7 +42,7 @@ int Sender::main(int argc, char** argv) { time = getClock(); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "sender time : " << time << endl; + info(TEXT_("Sender time : ") + TEXT_(time)); task = new PingPongTask("no name",computeDuration,commSizeLat); task->setTime(time); @@ -50,7 +50,8 @@ int Sender::main(int argc, char** argv) hostTable[pos].put(0,task); } - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "goodbye!" << endl; + info("Goodbye!"); + delete[] hostTable; diff --git a/examples/cxx/suspend/DreamMaster.cxx b/examples/cxx/suspend/DreamMaster.cxx index 0bf21ec012..62ed58f119 100644 --- a/examples/cxx/suspend/DreamMaster.cxx +++ b/examples/cxx/suspend/DreamMaster.cxx @@ -4,17 +4,17 @@ #include #include -#include -using namespace std; +#include + MSG_IMPLEMENT_DYNAMIC(DreamMaster, Process); int DreamMaster::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello I'm " << getName() << " on " << getHost().getName() << "!" << endl; + info("Hello"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's create a lazy guy."; + info("Let's create a lazy guy."); LazyGuy* lazy; @@ -23,15 +23,15 @@ int DreamMaster::main(int argc, char** argv) { Host currentHost = Host::currentHost(); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Current host name : " << currentHost.getName() << endl; + info(TEXT_("Current host name : ") + TEXT_(currentHost.getName())); lazy = new LazyGuy(currentHost,"LazyGuy"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's wait a little bit..." << endl; + info("Let's wait a little bit..."); Process::sleep(10.0); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Let's wake the lazy guy up! >:) " << endl; + info("Let's wake the lazy guy up! >:) "); lazy->resume(); @@ -39,13 +39,13 @@ int DreamMaster::main(int argc, char** argv) } catch(HostNotFoundException e) { - cerr << e.toString() <<". Stopping Now!" << endl; + error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); exit(1); } //lazy->migrate(currentHost); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "OK, goodbye now." << endl; + info("OK, goodbye now."); delete this; diff --git a/examples/cxx/suspend/LazyGuy.cxx b/examples/cxx/suspend/LazyGuy.cxx index ba12220e43..7db90b7ed4 100644 --- a/examples/cxx/suspend/LazyGuy.cxx +++ b/examples/cxx/suspend/LazyGuy.cxx @@ -1,21 +1,21 @@ #include "LazyGuy.hpp" #include -#include -using namespace std; +#include MSG_IMPLEMENT_DYNAMIC(LazyGuy, Process); int LazyGuy::main(int argc, char** argv) { - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Hello !" << endl; + info("Hello !"); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Nobody's watching me ? Let's go to sleep." << endl; + info("Nobody's watching me ? Let's go to sleep."); Process::currentProcess().suspend(); - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Uuuh ? Did somebody call me ?" << endl; - cout <<"[" << getName() << ":" << getHost().getName() << "] " << "Mmmh, goodbye now." << endl; + info("Uuuh ? Did somebody call me ?"); + + info("Mmmh, goodbye now."); delete this;