-\r
-/*\r
- * Msg.cxx\r
- *\r
- * Copyright 2006,2007 Martin Quinson, Malek Cherier \r
- * All right reserved. \r
- *\r
- * This program is free software; you can redistribute \r
- * it and/or modify it under the terms of the license \r
- *(GNU LGPL) which comes with this package. \r
- *\r
- */\r
- \r
- /* Msg functions implementation.\r
- */ \r
-\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
-\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
-namespace SimGrid\r
-{\r
- namespace Msg\r
- {\r
- #define SIMGRIDX_DEFAULT_CHANNEL_NUMBER ((int)10)\r
- \r
- void init(int argc, char** argv)\r
- {\r
- MSG_global_init(&argc,argv);\r
-\r
- if(getMaxChannelNumber() == 0)\r
- setMaxChannelNumber(SIMGRIDX_DEFAULT_CHANNEL_NUMBER);\r
- } \r
- \r
- void finalize(void)\r
- throw (MsgException)\r
- {\r
- if(MSG_OK != MSG_clean())\r
- throw MsgException("MSG_clean() failed");\r
- \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
- 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
- {\r
- return MSG_get_clock();\r
- }\r
-\r
- void setMaxChannelNumber(int number)\r
- throw(InvalidArgumentException, LogicException)\r
- {\r
- if(msg_global->max_channel > 0)\r
- throw LogicException("Max channel number already setted");\r
-\r
- if(number < 0)\r
- throw InvalidArgumentException("number");\r
-\r
- msg_global->max_channel = number;\r
- }\r
-\r
- int getMaxChannelNumber(void)\r
- {\r
- return msg_global->max_channel;\r
- }\r
-\r
- } // namespace Msg\r
-\r
-} // namespace SimGrid\r
-\r
+
+/*
+ * Msg.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier
+ * All right reserved.
+ *
+ * This program is free software; you can redistribute
+ * it and/or modify it under the terms of the license
+ *(GNU LGPL) which comes with this package.
+ *
+ */
+
+ /* Msg functions implementation.
+ */
+
+
+#include <Msg.hpp>
+#include <MsgHost.hpp>
+#include <MsgProcess.hpp>
+
+
+#include <msg/msg.h>
+#include <msg/private.h>
+
+#include <iostream>
+using std::cout;
+using std::endl;
+using std::streamsize;
+
+#include <iomanip>
+using std::setprecision;
+using std::setw;
+
+
+
+namespace SimGrid
+{
+ namespace Msg
+ {
+ #define SIMGRIDX_DEFAULT_CHANNEL_NUMBER ((int)10)
+
+ void init(int argc, char** argv)
+ {
+ MSG_global_init(&argc,argv);
+
+ if(getMaxChannelNumber() == 0)
+ setMaxChannelNumber(SIMGRIDX_DEFAULT_CHANNEL_NUMBER);
+ }
+
+ void finalize(void)
+ throw (MsgException)
+ {
+ if(MSG_OK != MSG_clean())
+ throw MsgException("MSG_clean() failed");
+
+ }
+
+ 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)
+ {
+ 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)
+ {
+ return MSG_get_clock();
+ }
+
+ void setMaxChannelNumber(int number)
+ throw(InvalidArgumentException, LogicException)
+ {
+ if(msg_global->max_channel > 0)
+ throw LogicException("Max channel number already setted");
+
+ if(number < 0)
+ throw InvalidArgumentException("number");
+
+ msg_global->max_channel = number;
+ }
+
+ int getMaxChannelNumber(void)
+ {
+ return msg_global->max_channel;
+ }
+
+ } // namespace Msg
+
+} // namespace SimGrid
+