Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
not needed now
[simgrid.git] / src / cxx / Msg.cxx
1 \r
2 /*\r
3  * Msg.cxx\r
4  *\r
5  * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
6  * All right reserved. \r
7  *\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
11  *\r
12  */\r
13  \r
14  /* Msg functions implementation.\r
15   */  \r
16 \r
17 \r
18 #include <Msg.hpp>\r
19 \r
20 #include <msg/msg.h>\r
21 #include <msg/private.h>\r
22 #include <stdio.h>\r
23 \r
24 \r
25 \r
26 \r
27 namespace SimGrid\r
28 {\r
29         namespace Msg\r
30         {\r
31                 #define SIMGRIDX_DEFAULT_CHANNEL_NUMBER ((int)10)\r
32                 \r
33                 void init(int argc, char** argv)\r
34                 {\r
35                         MSG_global_init(&argc,argv);\r
36 \r
37                         if(getMaxChannelNumber() == 0)\r
38                                 setMaxChannelNumber(SIMGRIDX_DEFAULT_CHANNEL_NUMBER);\r
39                 }       \r
40                 \r
41                 void finalize(void)\r
42                 throw (MsgException)\r
43                 {\r
44                         if(MSG_OK != MSG_clean())\r
45                                 throw MsgException("MSG_clean() failed");\r
46                         \r
47                 }\r
48                 \r
49                 void info(const char* s)\r
50                 {\r
51                          //INFO1("%s",s);\r
52                         printf("[SimGridX/info] %s\n", s);\r
53                 }\r
54 \r
55                 double getClock(void)\r
56                 {\r
57                         return MSG_get_clock();\r
58                 }\r
59 \r
60                 void setMaxChannelNumber(int number)\r
61                 throw(InvalidArgumentException, LogicException)\r
62                 {\r
63                         if(msg_global->max_channel > 0)\r
64                                 throw LogicException("Max channel number already setted");\r
65 \r
66                         if(number < 0)\r
67                                 throw InvalidArgumentException("number");\r
68 \r
69                         msg_global->max_channel = number;\r
70                 }\r
71 \r
72                 int getMaxChannelNumber(void)\r
73                 {\r
74                         return msg_global->max_channel;\r
75                 }\r
76 \r
77         } // namespace Msg\r
78 \r
79 } // namespace SimGrid\r
80 \r