Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Last Changes of CPP version of Msg
[simgrid.git] / src / cxx / Process.hpp
1 /*\r
2  * Process.hpp\r
3  *\r
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
5  * All right reserved. \r
6  *\r
7  * This program is free software; you can redistribute \r
8  * it and/or modify it under the terms of the license \r
9  *(GNU LGPL) which comes with this package. \r
10  *\r
11  */  \r
12  \r
13 #ifndef MSG_PROCESS_HPP\r
14 #define MSG_PROCESS_HPP\r
15 \r
16 // Compilation C++ recquise\r
17 #ifndef __cplusplus\r
18         #error Process.hpp requires C++ compilation (use a .cxx suffix)\r
19 #endif\r
20 \r
21 #include <msg/datatypes.h>\r
22 \r
23 #include <ApplicationHandler.hpp>\r
24 #include <Object.hpp>\r
25 \r
26 namespace SimGrid\r
27 {\r
28         namespace Msg\r
29         {\r
30                 class NullPointerException;\r
31                 class HostNotFoundException;\r
32                 class ProcessNotFoundException;\r
33                 class InvalidArgumentException;\r
34                 class BadAllocException;\r
35                 class LogicException;\r
36                 class MsgException;\r
37 \r
38                 class ApplicationHandler;\r
39                 class Host;\r
40                 class Task;\r
41 \r
42                 // SimGrid::Msg::Process class declaration.\r
43                 class SIMGRIDX_EXPORT Process : public Object\r
44                 {\r
45                         \r
46                         friend ApplicationHandler::ProcessFactory;\r
47                         \r
48                         MSG_DECLARE_DYNAMIC(Process);\r
49 \r
50                         public:\r
51                                 // Disable the default constructor.\r
52                                 Process();\r
53                         \r
54                         \r
55                                 /*! \brief  Constructs a process from the name of the host and its name.\r
56                                  *\r
57                                  * \param hostName              The host name of the process to create.\r
58                                  * \param name                  The name of the process to create.\r
59                                  *\r
60                                  * \exception                   If the constructor failed, it throws one of the exceptions described\r
61                                  *                                              below:\r
62                                  *                                              \r
63                                  *                                              [NullPointerException]          if the name of the process is NULL or if the\r
64                                  *                                                                                                      name of the host is NULL.\r
65                                  *                                              [HostNotFoundException]         if the host is not found.\r
66                                  */     \r
67                                 Process(const char* hostName, const char* name)\r
68                                 throw(NullPointerException, HostNotFoundException);\r
69                         \r
70                                 /*! \brief Constructs a process from a reference to an host object and its name.\r
71                                  *\r
72                                  * \param rHost                 A reference to the host object representing the native\r
73                                  *                                              MSG host where to create the process.\r
74                                  * \param name                  The name of the process to create.\r
75                                  *\r
76                                  * \exception                   If the constructor failed, it throws the exception described\r
77                                  *                                              below:\r
78                                  *\r
79                                  *                                              [NullPointerException]          if the name of process is NULL.\r
80                                  */ \r
81                                 Process(const Host& rHost, const char* name)\r
82                                 throw(NullPointerException);\r
83                                 \r
84                                 /*! brief Construct a proces from reference to an host object and the name of the process.\r
85                                  * This constuctor takes also the list of the arguments of the process.\r
86                                  *\r
87                                  * \param host                  A reference to the host where to create the process.\r
88                                  * \param name                  The name of the process to create.\r
89                                  * \param argc                  The number of the arguments of the process to create.\r
90                                  * \param argv                  The list of arguments of the process to create.\r
91                                  *\r
92                                  * \exception                   If the constructor failed, it throws one of the exceptions described\r
93                                  *                                              below:\r
94                                  *\r
95                                  *                                              [NullPointerException]          if the name of the host is NULL or\r
96                                  *                                                                                                      if the name of the process is NULL.\r
97                                  *                                              [InvalidArgumentException]  if the value of the parameter argv is\r
98                                  *                                                                                                      negative.\r
99                                  *                                              [LogicException]                        if the parameter argv is NULL and the \r
100                                  *                                                                                                      parameter argc is different than zero\r
101                                  *                                                                                                      if the parameter argv is not NULL and \r
102                                  *                                                                                                      the parameter argc is zero.\r
103                                  */\r
104                                 Process(const Host& rHost, const char* name, int argc, char** argv)\r
105                                 throw(NullPointerException, InvalidArgumentException, LogicException);\r
106                                 \r
107                                 /*! brief Constructs a proces from the name of a host and the name of the process.\r
108                                  * This constuctor takes also the list of the arguments of the process.\r
109                                  *\r
110                                  * \param hostName              The name of the host where to create the process.\r
111                                  * \param name                  The name of the process to create.\r
112                                  * \param argc                  The number of the arguments of the process to create.\r
113                                  * \param argv                  The list of arguments of the process to create.\r
114                                  *\r
115                                  * \exception                   If the constructor failed, it throws one of the exceptions described\r
116                                  *                                              below:\r
117                                  *                                              \r
118                                  *                                              [NullPointerException]          if the name of the process or if the name\r
119                                  *                                                                                                      of the host is NULL.\r
120                                  *                                              [InvalidArgumentException]  if the value of the parameter argv is\r
121                                  *                                                                                                      negative.\r
122                                  *                                              [LogicException]                        if the parameter argv is NULL and the \r
123                                  *                                                                                                      parameter argc is different than zero\r
124                                  *                                                                                                      if the parameter argv is not NULL and \r
125                                  *                                                                                                      the parameter argc is zero.\r
126                                  *                                              [HostNotFoundException]         if the specified host is no found.\r
127                                  */\r
128                                 Process(const char* hostName, const char* name, int argc, char** argv)\r
129                                 throw(NullPointerException, HostNotFoundException);\r
130                         \r
131                                 /*! \brief Process::killAll() - kill all the running processes of the simulation.\r
132                                  *\r
133                                  * \param resetPID              Should we reset the PID numbers. A negative number means no reset\r
134                          *                                              and a positive number will be used to set the PID of the next newly\r
135                          *                                              created process.\r
136                          *\r
137                          * \return                              The static method returns the PID of the next created process.\r
138                          */                     \r
139                                 static int killAll(int resetPID);\r
140                         \r
141                                 /*! \brief Process::suspend() - Suspend an MSG process.\r
142                                  * \r
143                                  * \excetpion                   If this method failed, it throws one the exception described below:\r
144                                  *\r
145                                  *                                              [MsgException]  if an internal exception occurs during the operation.\r
146                                  */\r
147                                 void suspend(void)\r
148                                 throw(MsgException);\r
149                                 \r
150                                 \r
151                         \r
152                                 /*! \brief Process::resume() - Resume the MSG process.\r
153                                  *\r
154                                  * \exception                   If this method failed, it throws the exception described below:\r
155                                  *\r
156                                  *                                              [MsgException] if an internal exception occurs during the operation.\r
157                                  */\r
158                                 void resume(void) \r
159                                 throw(MsgException);\r
160                         \r
161                                 /*! \brief Process::isSuspend() - Tests if a process is suspended.\r
162                                  *\r
163                                  * \return                              This method returns 1 is the process is suspended.\r
164                                  *                                              Otherwise the method returns 0.\r
165                                  */\r
166                                 int isSuspended(void);\r
167                         \r
168                                 /*! \brief Process::getHost() - Retrieves the host of a process object.\r
169                                  *\r
170                                  * \return                              The method returns a reference to the\r
171                                  *                                              host of the process.\r
172                                  *\r
173                                  */\r
174                                 Host& getHost(void); \r
175                         \r
176                                 /*! \brief Process::fromPID() - Retrieves a process from its PID.\r
177                                  *\r
178                                  * \param PID                   The PID of the process to retrieve.\r
179                                  *\r
180                                  * \return                              If successful the method returns a reference to\r
181                                  *                                              to process. Otherwise, the method throws one of\r
182                                  *                                              the exceptions described below:\r
183                                  *\r
184                                  * \exception                   [ProcessNotFoundException]      if the process is not found (no process with this PID).\r
185                                  *\r
186                                  *                                              [InvalidArgumentException]      if the parameter PID is less than 1.\r
187                                  *\r
188                                  *                                              [MsgException]                          if a native error occurs during the operation.\r
189                                  */\r
190                                 static Process& fromPID(int PID)\r
191                                 throw(ProcessNotFoundException, InvalidArgumentException, MsgException); \r
192                         \r
193                                 /*! \brief Process::getPID() - Gets the PID of a process object.\r
194                                  *\r
195                                  * \return                              This method returns the PID of a process object.\r
196                                  */\r
197                                 int getPID(void);\r
198                                 \r
199                                 /*! \brief Process::getPPID() - Gets the parent PID of a process object.\r
200                                  *\r
201                                  * \return                              This method returns the parent PID of a process object.\r
202                                  */\r
203                                 int getPPID(void);\r
204                                 \r
205                                 /*! \brief Process::getName() - Gets the name of a process object.\r
206                                  *\r
207                                  * \return                              This method returns the name of a process object.\r
208                                  */\r
209                                 const char* getName(void) const;\r
210                         \r
211                                 /*! \brief Process::currentProcess() - Retrieves the current process.\r
212                                  *\r
213                                  * \return                              This method returns a reference to the current process. Otherwise\r
214                                  *                                              the method throws the excepction described below:\r
215                                  *\r
216                                  * \exception                   [MsgException]  if an internal exception occurs.\r
217                                  */\r
218                                 static Process& currentProcess(void)\r
219                                 throw (MsgException);\r
220                         \r
221                                 /*! \brief Process::currentProcessPID() - Retrieves the PID of the current process.\r
222                                  *\r
223                                  * \return                              This method returns the PID of the current process.\r
224                                  */\r
225                                 static int currentProcessPID(void);\r
226                                 \r
227                                 /*! \brief Process::currentProcessPPID() - Retrieves the parent PID of the current process.\r
228                                  *\r
229                                  * \return                              This method returns the parent PID of the current process.\r
230                                  */\r
231                                 static int currentProcessPPID(void);\r
232                         \r
233                                 /*! \brief Process::migrate() - Migrate a process object to an another host.\r
234                                  *\r
235                                  * \param rHost                 A reference to the host to migrate the process to.\r
236                                  *\r
237                                  * \return                              If successful the method migrate the process to the specified\r
238                                  *                                              host. Otherwise the method throws the exception described\r
239                                  *                                              below:\r
240                                  *\r
241                                  * \exception                   [MsgException]  if an internal exception occurs.\r
242                                  */\r
243                                 void migrate(const Host& rHost)\r
244                                 throw(MsgException);\r
245                         \r
246                                 /*! \brief Process::sleep() - Makes the current process sleep until time seconds have elapsed. \r
247                                  *\r
248                                  * \param seconds                       The number of seconds to sleep.\r
249                                  *\r
250                                  * \execption                           If this method failed, it throws one of the exceptions described\r
251                                  *                                                      below: \r
252                                  *\r
253                                  *                                                      [InvalidArgumentException]      if the parameter seconds is\r
254                                  *                                                      less or equals to zero.\r
255                                  *\r
256                                  *                                                      [MsgException] if an internal exception occurs.\r
257                                  */\r
258                                 static void sleep(double seconds)\r
259                                 throw(InvalidArgumentException, MsgException);\r
260                         \r
261                                 /*! \brief Process::putTask() - This method puts a task on a given channel of a given host.\r
262                                  *\r
263                                  * \exception                   If this method failed, it throws one of the exceptions described\r
264                                  *                                              below:\r
265                                  *\r
266                                  *                                              [InvalidArgumentException] if the channel number is negative.\r
267                                  *\r
268                                  *                                              [MsgException]                          if an internal exception occurs.\r
269                                  */\r
270                                 void putTask(const Host& rHost, int channel, const Task& rTask)\r
271                                 throw(InvalidArgumentException, MsgException);\r
272                         \r
273                                 /*! \brief Process::putTask() - This method puts a task on a given channel of a given host (waiting at most given time).\r
274                                  *\r
275                                  * \exception                   If this method failed, it throws one of the exceptions described below:\r
276                                  *\r
277                                  *                                              [MsgException]                          if an internal error occurs.\r
278                                  *\r
279                                  *                                              [InvalidArgumentException]      if the value of the channel specified as\r
280                                  *                                                                                                      parameter is negative or if the timeout value\r
281                                  *                                                                                                      is less than zero and différent of -1.\r
282                                  *\r
283                                  * \remark                              Set the timeout with -1.0 to disable it.\r
284                                  */\r
285                                 void putTask(const Host& rHost, int channel, const Task& rTask, double timeout) \r
286                                 throw(InvalidArgumentException, MsgException);\r
287                         \r
288                                 /*! \brief Process::getTask() - Retrieves a task from a channel number (waiting at most given time).\r
289                                  *\r
290                                  * \param channel               The number of the channel where to get the task.\r
291                                  *\r
292                                  * \return                              If successful the method returns a reference to \r
293                                  *                                              the getted task. Otherwise the method throws one\r
294                                  *                                              of the exceptions described below:\r
295                                  *\r
296                                  * \exception                   [InvalidArgumentException]      if the channel number is negative.\r
297                                  *\r
298                                  *                                              [MsgException]                          if an internal exception occurs.\r
299                                  */\r
300                                 Task& getTask(int channel) \r
301                                 throw(InvalidArgumentException, MsgException);\r
302                         \r
303                                 /*! \brief Process::taskGet() - Retrieves a task from a channel number (waiting at most given time).\r
304                                  *\r
305                                  * \param channel               The number of the channel where to get the task.\r
306                                  * \param timeout               The timeout value.\r
307                                  *\r
308                                  * \return                              If successful the method returns a reference to \r
309                                  *                                              the getted task. Otherwise the method throws one\r
310                                  *                                              of the exceptions described below:\r
311                                  *\r
312                                  * \exception                   [InvalidArgumentException]      if the channel number is negative\r
313                                  *                                                                                                      or if the timeout value is less than\r
314                                  *                                                                                                      zero and different of -1.0.\r
315                                  *                                              [MsgException]                          if an internal exception occurs.\r
316                                  */\r
317                                 Task& getTask(int channel, double timeout) \r
318                                 throw(InvalidArgumentException, MsgException);\r
319                         \r
320                                 /*! \brief Process::taskGet() - Retrieves a task from a channel number and a host.\r
321                                  *\r
322                                  * \param channel               The number of the channel where to get the task.\r
323                                  * \param host                  The host of the channel to get the task.\r
324                                  *\r
325                                  * \return                              If successful the method returns a reference to \r
326                                  *                                              the getted task. Otherwise the method throws one\r
327                                  *                                              of the exceptions described below.\r
328                                  *\r
329                                  * \exception                   [InvalidArgumentException]      if the channel number is negative.\r
330                                  *                                              [MsgException]                          if an internal exception occurs.\r
331                                  */\r
332                                 Task& getTask(int channel, const Host& rHost) \r
333                                 throw(InvalidArgumentException, MsgException);\r
334                         \r
335                                 /*! \brief Process::taskGet() - Retrieves a task from a channel number and a host (waiting at most given time).\r
336                                  *\r
337                                  * \param channel               The number of the channel where to get the task.\r
338                                  * \param timeout               The timeout value.\r
339                                  * \param rHost                 The host owning the channel.\r
340                                  *\r
341                                  * \return                              If successful the method returns a reference to \r
342                                  *                                              the getted task. Otherwise the method throws one\r
343                                  *                                              of the exceptions described below:\r
344                                  *\r
345                                  * \exception                   [InvalidArgumentException]      if the channel number is negative or\r
346                                  *                                                                                                      if the timeout value is negative and different\r
347                                  *                                                                                                      of -1.0.\r
348                                  *                                              [MsgException]                          if an internal exception occurs.\r
349                                  *\r
350                                  * \remark                              Set the timeout with -1.0 to disable it.\r
351                                  */\r
352                                 Task& getTask(int channel, double timeout, const Host& rHost)\r
353                                 throw(InvalidArgumentException, MsgException);\r
354                         \r
355                                 /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias\r
356                                  * (waiting at most given time).\r
357                                  *\r
358                                  * \param alias                         The alias of the mailbox where to send the task.\r
359                                  * \param rTask                         A reference to the task object to send.\r
360                                  * \param timeout                       The timeout value.\r
361                                  *\r
362                                  * \exception                           If this method failed, it throws one of the exceptions described below:\r
363                                  *\r
364                                  *                                                      [NullPointerException]          if the alias specified as parameter is NULL.\r
365                                  *      \r
366                                  *                                                      [InvalidArgumentException]      if the timeout value is negative and different than\r
367                                  *                                                                                                              -1.0\r
368                                  *                                                      [MsgException]                          if an internal exception occurs.\r
369                                  *\r
370                                  * \remark                                      Set the timeout with -1.0 to disable it.\r
371                                  */\r
372                                 void sendTask(const char* alias, const Task& rTask, double timeout) \r
373                                 throw(NullPointerException, InvalidArgumentException, MsgException);\r
374                         \r
375                                 /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias.\r
376                                  *\r
377                                  * \param alias                         The alias of the mailbox where to send the task.\r
378                                  * \param rTask                         A reference to the task object to send.\r
379                                  *\r
380                                  * \exception                           If this method failed, it throws one of the exceptions described below:\r
381                                  *\r
382                                  *                                                      [NullPointerException]          if the alias parameter is NULL.\r
383                                  *\r
384                                  *                                                      [MsgException]                          if an internal exception occurs.\r
385                                  *\r
386                                  */\r
387                                 void sendTask(const char* alias, const Task& rTask) \r
388                                 throw(NullPointerException, MsgException);\r
389                         \r
390                                 /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the default alias.\r
391                                  *\r
392                                  * \param rTask                         A reference to the task object to send.\r
393                                  *\r
394                                  * \exception                           If this method failed, it throws one of the exceptions described below:\r
395                                  *                                                      \r
396                                  *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
397                                  *\r
398                                  *                                                      [MsgException]                          if an internal exception occurs.\r
399                                  *\r
400                                  */\r
401                                 void sendTask(const Task& rTask) \r
402                                 throw(BadAllocException, MsgException);\r
403                         \r
404                                 /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the default alias\r
405                                  * (waiting at most given time).\r
406                                  *\r
407                                  * \param rTask                         A reference to the task object to send.\r
408                                  * \param timeout                       The timeout value.\r
409                                  *\r
410                                  * \exception                           If this method failed, it throws one of the exceptions described below:\r
411                                  *\r
412                                  *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
413                                  *\r
414                                  *                                                      [InvalidArgumentException]      if the timeout value is negative and different than -1.0.\r
415                                  *\r
416                                  *                                                      [MsgException]                          if an internal exception occurs.\r
417                                  *\r
418                                  * \remark                                      set the timeout value with -1.0 to disable it.\r
419                                  */\r
420                                 void sendTask(const Task& rTask, double timeout) \r
421                                 throw(BadAllocException, InvalidArgumentException, MsgException);\r
422                         \r
423                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as\r
424                                  * parameter.\r
425                                  *\r
426                                  * \param alias                         The alias of the mailbox where to retrieve the task.\r
427                                  *\r
428                                  * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
429                                  *                                                      throws one of the exceptions described below:\r
430                                  *\r
431                                  * \exception                           [NullPointerException]  if the parameter alias is NULL.\r
432                                  *\r
433                                  *                                                      [MsgException]                  if an internal exception occurs.\r
434                                  */\r
435                                 Task& receiveTask(const char* alias) \r
436                                 throw(NullPointerException, MsgException);\r
437                         \r
438                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the default alias.\r
439                                  *\r
440                                  * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
441                                  *                                                      throws one of the exceptions described below:\r
442                                  *\r
443                                  * \exception                           [BadAllocException]             if there is not enough memory to build the alias.                       \r
444                                  *                                                      [MsgException]                  if an internal exception occurs.\r
445                                  */\r
446                                 Task& receiveTask(void) \r
447                                 throw(BadAllocException, MsgException);\r
448                         \r
449                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as\r
450                                  * parameter(waiting at most given time).\r
451                                  *\r
452                                  * \param alias                         The alias of the mailbox where to retrieve the task.\r
453                                  * \param timeout                       The timeout value.\r
454                                  *\r
455                                  * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
456                                  *                                                      throws one of the exceptions described below.\r
457                                  *\r
458                                  * \exception                           [InvalidArgumentException]      if the timeout value is negative or different of -1.0.\r
459                                  *\r
460                                  *                                                      [NullPointerException]          if the parameter alias is NULL.\r
461                                  *\r
462                                  *                                                      [MsgException]                          if an internal exception occurs.\r
463                                  */\r
464                                 Task& receiveTask(const char* alias, double timeout) \r
465                                 throw(NullPointerException, InvalidArgumentException, MsgException);\r
466                         \r
467                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the default alias\r
468                                  * (waiting at most given time).\r
469                                  *\r
470                                  * \param timeout                       The timeout value.\r
471                                  *\r
472                                  * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
473                                  *                                                      throws one of the exceptions described below:\r
474                                  *\r
475                                  * \exception                           [InvalidArgumentException]      if the timeout value is negative or different than -1.0.\r
476                                  *\r
477                                  *                                                      [BadAllocException]                     if there is not enough memory to build the alias.\r
478                                  *                      \r
479                                  *                                                      [MsgException]                          if an internal exception occurs.\r
480                                  */\r
481                                 Task& receiveTask(double timeout) \r
482                                 throw(InvalidArgumentException, BadAllocException, MsgException);\r
483                         \r
484                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as\r
485                                  * parameter located on a given host (waiting at most given time).\r
486                                  *\r
487                                  * \param alias                         The alias of the mailbox where to retrieve the task.\r
488                                  * \param timeout                       The timeout value.\r
489                                  * \param rHost                         A reference to the host object owning the mailbox.\r
490                                  *\r
491                                  * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
492                                  *                                                      throws one of the exceptions described below:\r
493                                  *\r
494                                  * \exception                           [InvalidArgumentException]      if the timeout value is negative or different of -1.0.\r
495                                  *\r
496                                  *                                                      [NullPointerException]          if the parameter alias is NULL.\r
497                                  *\r
498                                  *                                                      [MsgException]                          if an internal exception occurs.\r
499                                  */\r
500                                 Task& receiveTask(const char* alias, double timeout, const Host& rHost) \r
501                                 throw(NullPointerException, InvalidArgumentException, MsgException);\r
502                         \r
503                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by default alias\r
504                                  *  and located on a given host (waiting at most given time).\r
505                                  *\r
506                                  * \param timeout                       The timeout value.\r
507                                  * \param rHost                         A reference to the host object owning the mailbox.\r
508                                  *\r
509                                  * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
510                                  *                                                      throws one of the exceptions described below:\r
511                                  *\r
512                                  * \exception                           [InvalidArgumentException]      if the timeout value is negative and different than -1.0.\r
513                                  *\r
514                                  *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
515                                  *\r
516                                  *                                                      [MsgException]                          if an internal exception occurs.\r
517                                  */\r
518                                 Task& receiveTask(double timeout, const Host& rHost) \r
519                                 throw(BadAllocException, InvalidArgumentException, MsgException);\r
520                         \r
521                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias\r
522                                  *  specified as parameter and located on a given host.\r
523                                  *\r
524                                  * \param alias                 The alias using to identify the mailbox from which to get the task.\r
525                                  * \param rHost                 A reference to the host object owning the mailbox.\r
526                                  *\r
527                                  * \return                              If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
528                                  *                                              throws one of the exceptions described below:\r
529                                  *\r
530                                  * \exception                   [NullPointerException]                  if the parameter alias is NULL.\r
531                                  *\r
532                                  *                                              [MsgException]                                  if an internal exception occurs.\r
533                                  */\r
534                                 Task& receiveTask(const char* alias, const Host& rHost) \r
535                                 throw(NullPointerException, MsgException);\r
536                         \r
537                                 /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by default alias\r
538                                  *  and located on a given host.\r
539                                  *\r
540                                  * \param rHost                 A reference to the host object owning the mailbox.\r
541                                  *\r
542                                  * \return                              If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
543                                  *                                              throws one of the exceptions described below:\r
544                                  *\r
545                                  * \exception                   [BadAllocException]                             if there is not enough memory to build the alias.\r
546                                  *\r
547                                  *                                              [MsgException]                                  if an internal exception occurs.\r
548                                  */\r
549                                 Task& receiveTask(const Host& rHost) \r
550                                 throw(BadAllocException, MsgException);\r
551                         \r
552                                 \r
553                         private:\r
554                         \r
555                                 /* Process::create() - Creates a process on a given host.\r
556                                  *\r
557                                  * param rHost                  A reference to a host object where to create the process.\r
558                                  * param name                   The name of the process to create.\r
559                                  * param argc                   The number of argument to pass to the main function of the process.\r
560                                  * param argv                   The list of the arguments of the main function of the process.\r
561                                  *\r
562                                  * exception                    If this method failed, it throws one of the exceptions described below:\r
563                                  *\r
564                                  *                                              [HostNotFoundException] if the host specified as parameter doesn't exist.\r
565                                  */\r
566                                 void create(const Host& rHost, const char* name, int argc, char** argv) \r
567                                 throw(HostNotFoundException);\r
568                                 \r
569                                 /* Process::fromNativeProcess() - Retrieves the process wrapper associated with a native process.\r
570                                  *\r
571                                  * \param nativeProcess The native process to get the wrapper.\r
572                                  *\r
573                                  * \return                              The wrapper associated with the native process specified as parameter.\r
574                                  */\r
575                                 static Process* fromNativeProcess(m_process_t nativeProcess);\r
576                         \r
577                         \r
578                         public:\r
579                         \r
580                                 /* Process::run() - used to set the field code of the context of the process.\r
581                                  */ \r
582                                 static int run(int argc, char** argv);\r
583                                 \r
584                                 /*! \brief Process::main() - This virtual pure function is the main function of the process.\r
585                                  * You must override this function for each new class of process that you create.\r
586                                  *\r
587                                  * \param argc                  The number of parameters of the main function.\r
588                                  * \param argv                  The list of the parameter of the main function.\r
589                                  *\r
590                                  * \return                              The exit code of the main function.\r
591                                  */\r
592                                 virtual int main(int argc, char** argv);\r
593                                 \r
594                         private:\r
595                                 \r
596                                 // Attributes.\r
597                                 \r
598                                 m_process_t nativeProcess;      // pointer to the native msg process.\r
599                         \r
600                 };\r
601         \r
602         } //namepace Msg\r
603 \r
604 } // namespace SimGrid\r
605 \r
606 #endif // !MSG_PROCESS_HPP