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