5 * Copyright 2006,2007 Martin Quinson, Malek Cherier
\r
6 * All right reserved.
\r
8 * This program is free software; you can redistribute
\r
9 * it and/or modify it under the terms of the license
\r
10 *(GNU LGPL) which comes with this package.
\r
14 /* Msg functions implementation.
\r
20 #include <Process.hpp>
\r
23 #include <msg/msg.h>
\r
24 #include <msg/private.h>
\r
29 using std::streamsize;
\r
32 using std::setprecision;
\r
41 #define SIMGRIDX_DEFAULT_CHANNEL_NUMBER ((int)10)
\r
43 void init(int argc, char** argv)
\r
45 MSG_global_init(&argc,argv);
\r
47 if(getMaxChannelNumber() == 0)
\r
48 setMaxChannelNumber(SIMGRIDX_DEFAULT_CHANNEL_NUMBER);
\r
52 throw (MsgException)
\r
54 if(MSG_OK != MSG_clean())
\r
55 throw MsgException("MSG_clean() failed");
\r
59 void info(const StringHelper& s)
\r
64 cout << Host::currentHost().getName();
\r
66 cout << Process::currentProcess().getName();
\r
68 cout << Process::currentProcess().getPID();
\r
70 cout << clock.append(getClock(), "%07lf");
\r
71 cout << "] [cxx4msg/INFO] ";
\r
76 void info(const char* s)
\r
81 cout << Host::currentHost().getName();
\r
83 cout << Process::currentProcess().getName();
\r
85 cout << Process::currentProcess().getPID();
\r
87 cout << clock.append(getClock(), "%07lf");
\r
88 cout << "] [cxx4msg/INFO] ";
\r
93 void error(const StringHelper& s)
\r
98 cout << Host::currentHost().getName();
\r
100 cout << Process::currentProcess().getName();
\r
102 cout << Process::currentProcess().getPID();
\r
104 cout << clock.append(getClock(), "%07lf");
\r
105 cout << "] [cxx4msg/ERROR] ";
\r
110 void error(const char* s)
\r
112 StringHelper clock;
\r
115 cout << Host::currentHost().getName();
\r
117 cout << Process::currentProcess().getName();
\r
119 cout << Process::currentProcess().getPID();
\r
121 cout << clock.append(getClock(), "%07lf");
\r
122 cout << "] [cxx4msg/ERROR] ";
\r
127 double getClock(void)
\r
129 return MSG_get_clock();
\r
132 void setMaxChannelNumber(int number)
\r
133 throw(InvalidArgumentException, LogicException)
\r
135 if(msg_global->max_channel > 0)
\r
136 throw LogicException("Max channel number already setted");
\r
139 throw InvalidArgumentException("number");
\r
141 msg_global->max_channel = number;
\r
144 int getMaxChannelNumber(void)
\r
146 return msg_global->max_channel;
\r
151 } // namespace SimGrid
\r