Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
last change of cpp wrappers for msg
[simgrid.git] / src / cxx / Task.cxx
index 93e1c68..3c3dcca 100644 (file)
-/*\r
- * Task.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
- /* Task member functions implementation.\r
-  */  \r
-\r
-#include <Process.hpp>\r
-#include <Host.hpp>\r
-\r
-#include <Task.hpp>\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-#include <msg/msg.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-\r
-               MSG_IMPLEMENT_DYNAMIC(Task, Object);\r
-       \r
-               Task::Task()\r
-               {\r
-                       nativeTask = NULL;\r
-               }\r
-               \r
-               \r
-               Task::Task(const Task& rTask)\r
-               {\r
-                       this->nativeTask = rTask.nativeTask;\r
-               }\r
-               \r
-               \r
-               Task::~Task()\r
-               throw(MsgException)\r
-               {\r
-                       if(NULL != nativeTask)\r
-                               if(MSG_OK != MSG_task_destroy(nativeTask))\r
-                                       throw MsgException("MSG_task_destroy() failed");\r
-               }\r
-               \r
-               \r
-               Task::Task(const char* name, double computeDuration, double messageSize)\r
-               throw(InvalidArgumentException, NullPointerException)\r
-               {\r
-\r
-                       if(computeDuration < 0) \r
-                               throw InvalidArgumentException("computeDuration");\r
-                       \r
-                       if(messageSize < 0) \r
-                               throw InvalidArgumentException("messageSize");\r
-                       \r
-                       if(!name) \r
-                               throw NullPointerException("name");\r
-                       \r
-                       // create the task\r
-                       nativeTask = MSG_task_create(name, computeDuration, messageSize, NULL);\r
-                       \r
-                       nativeTask->data = (void*)this;\r
-               }\r
-               \r
-               Task::Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)\r
-               throw(NullPointerException, InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!name) \r
-                               throw NullPointerException("name");\r
-                       \r
-                       if(!hosts) \r
-                               throw NullPointerException("hosts");\r
-                       \r
-                       if(!computeDurations) \r
-                               throw NullPointerException("computeDurations");\r
-                               \r
-                       if(!messageSizes) \r
-                               throw NullPointerException("messageSizes");\r
-                               \r
-                       if(!hostCount)\r
-                               throw InvalidArgumentException("hostCount (must not be zero)");\r
-                               \r
-                       \r
-                       m_host_t* nativeHosts;\r
-                       double* durations;\r
-                       double* sizes;\r
-                       \r
-                       \r
-                       nativeHosts = xbt_new0(m_host_t, hostCount);\r
-                       durations = xbt_new0(double,hostCount);\r
-                       sizes = xbt_new0(double, hostCount * hostCount);\r
-                       \r
-                       \r
-                       for(int index = 0; index < hostCount; index++) \r
-                       {\r
-                               \r
-                               nativeHosts[index] = hosts[index].nativeHost;\r
-                               durations[index] = computeDurations[index];\r
-                       }\r
-                       \r
-                       for(int index = 0; index < hostCount*hostCount; index++) \r
-                               sizes[index] = messageSizes[index];\r
-                       \r
-                       \r
-                       nativeTask = MSG_parallel_task_create(name, hostCount, nativeHosts, durations, sizes,NULL);\r
-                       \r
-                       \r
-                       \r
-                       this->nativeTask->data = (void*)this;\r
-                       \r
-               }\r
-               \r
-               const char* Task::getName(void) const\r
-               {\r
-                       return nativeTask->name;\r
-               }\r
-               \r
-               Process& Task::getSender(void) const\r
-               {\r
-                       m_process_t nativeProcess = MSG_task_get_sender(nativeTask);\r
-                       \r
-                       return (*((Process*)(nativeProcess->data)));\r
-               }\r
-               \r
-               Host& Task::getSource(void) const \r
-               {\r
-                       m_host_t nativeHost = MSG_task_get_source(nativeTask);\r
-                       \r
-                       return (*((Host*)(nativeHost->data)));  \r
-               }\r
-               \r
-               double Task::getComputeDuration(void) const\r
-               {\r
-                       return MSG_task_get_compute_duration(nativeTask);\r
-               }\r
-               \r
-               double Task::getRemainingDuration(void) const\r
-               {\r
-                       return MSG_task_get_remaining_computation(nativeTask);\r
-               }\r
-               \r
-               void Task::setPriority(double priority)\r
-               throw(InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(priority < 0.0)\r
-                               throw InvalidArgumentException("priority");\r
-                               \r
-                       MSG_task_set_priority(nativeTask, priority);\r
-               }\r
-\r
-               Task* Task::get(int channel) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, NULL)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return ((Task*)(nativeTask->data));\r
-               }\r
-               \r
-               Task* Task::get(int channel, const Host& rHost) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       \r
-                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Task::get(int channel, double timeout, const Host& rHost) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                       \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and different thant -1.0)");      \r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       \r
-                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , timeout, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               int Task::probe(int channel)\r
-               throw(InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       return MSG_task_Iprobe(channel);\r
-               }\r
-               \r
-               int Task::probe(int channel, const Host& rHost)\r
-               throw(InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       return MSG_task_probe_from_host(channel,rHost.nativeHost);\r
-               }\r
-               \r
-               void Task::execute(void) \r
-               throw(MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_task_execute(nativeTask))\r
-                               throw MsgException("MSG_task_execute() failed");\r
-               }\r
-               \r
-               void Task::cancel(void) \r
-               throw(MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_task_cancel(nativeTask))\r
-                               throw MsgException("MSG_task_cancel() failed");\r
-               }\r
-               \r
-               void Task::send(void) \r
-               throw(BadAllocException, MsgException)\r
-               {       \r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                               \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, -1.0);\r
-               \r
-                       free(alias);\r
-               \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Task::send(const char* alias) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-               \r
-                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, -1.0))\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Task::send(double timeout) \r
-               throw(BadAllocException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(timeout < 0  && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");\r
-                                               \r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-               \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, timeout);\r
-               \r
-                       free(alias);\r
-               \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }       \r
-               \r
-               void Task::send(const char* alias, double timeout) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       if(timeout < 0  && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");\r
-                                               \r
-                               \r
-                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, timeout))\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Task::sendBounded(double maxRate) \r
-               throw(BadAllocException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(maxRate < 0 && maxRate != -1.0)\r
-                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");\r
-                                       \r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                       \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                       \r
-                       MSG_error_t rv = MSG_task_send_bounded(nativeTask, alias, maxRate);\r
-                       \r
-                       free(alias);    \r
-                       \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_bounded() failed");\r
-                               \r
-               }\r
-               \r
-               void Task::sendBounded(const char* alias, double maxRate) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(maxRate < 0 && maxRate != -1.0)\r
-                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");\r
-                                                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(MSG_OK != MSG_task_send_bounded(nativeTask, alias, maxRate))\r
-                               throw MsgException("MSG_task_send_bounded() failed");\r
-               }\r
-\r
-               Task* Task::receive(void) \r
-               throw(BadAllocException, MsgException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL);  \r
-               \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK != rv) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-\r
-               Task* Task::receive(const char* alias) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Task::receive(const char* alias, double timeout) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, NULL)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Task::receive(const char* alias, const Host& rHost) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }       \r
-               \r
-               Task* Task::receive(const char* alias, double timeout, const Host& rHost) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               int Task::listen(void) \r
-               throw(BadAllocException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                               \r
-                       int rv = MSG_task_listen(alias);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       return rv;\r
-               }       \r
-               \r
-               int Task::listen(const char* alias) \r
-               throw(NullPointerException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       return MSG_task_listen(alias);\r
-               }\r
-               \r
-               int Task::listenFrom(void) \r
-               throw(BadAllocException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                       \r
-                       int rv = MSG_task_listen_from(alias);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       return rv;\r
-               }       \r
-               \r
-               int Task::listenFrom(const char* alias) \r
-               throw(NullPointerException)\r
-               {\r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       return MSG_task_listen_from(alias);\r
-                       \r
-               }\r
-               \r
-               int Task::listenFromHost(const Host& rHost) \r
-               throw(BadAllocException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                       \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                       \r
-                       int rv = MSG_task_listen_from_host(alias, rHost.nativeHost);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       return rv;\r
-               }\r
-                       \r
-               int Task::listenFromHost(const char* alias, const Host& rHost) \r
-               throw(NullPointerException)\r
-               {\r
-                       // check the parameters\r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       return MSG_task_listen_from_host(alias, rHost.nativeHost);\r
-               }       \r
-\r
-               const Task& Task::operator = (const Task& rTask)\r
-               {\r
-                       this->nativeTask = rTask.nativeTask;\r
-                       return *this;\r
-               }\r
-       } // namespace Msg                                                                                                                                                                                              \r
-} // namespace SimGrid\r
-\r
+/*
+ * Task.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. 
+ *
+ */
+ /* Task member functions implementation.
+  */  
+
+#include <Process.hpp>
+#include <Host.hpp>
+
+#include <Task.hpp>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <msg/msg.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+
+               MSG_IMPLEMENT_DYNAMIC(Task, Object)
+       
+               Task::Task()
+               {
+                       nativeTask = NULL;
+               }
+               
+               
+               Task::Task(const Task& rTask)
+               {
+                       this->nativeTask = rTask.nativeTask;
+               }
+               
+               
+               Task::~Task()
+               throw(MsgException)
+               {
+                       if(NULL != nativeTask)
+                               if(MSG_OK != MSG_task_destroy(nativeTask))
+                                       throw MsgException("MSG_task_destroy() failed");
+               }
+               
+               
+               Task::Task(const char* name, double computeDuration, double messageSize)
+               throw(InvalidArgumentException, NullPointerException)
+               {
+
+                       if(computeDuration < 0) 
+                               throw InvalidArgumentException("computeDuration");
+                       
+                       if(messageSize < 0) 
+                               throw InvalidArgumentException("messageSize");
+                       
+                       if(!name) 
+                               throw NullPointerException("name");
+                       
+                       // create the task
+                       nativeTask = MSG_task_create(name, computeDuration, messageSize, NULL);
+                       
+                       nativeTask->data = (void*)this;
+               }
+               
+               Task::Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)
+               throw(NullPointerException, InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(!name) 
+                               throw NullPointerException("name");
+                       
+                       if(!hosts) 
+                               throw NullPointerException("hosts");
+                       
+                       if(!computeDurations) 
+                               throw NullPointerException("computeDurations");
+                               
+                       if(!messageSizes) 
+                               throw NullPointerException("messageSizes");
+                               
+                       if(!hostCount)
+                               throw InvalidArgumentException("hostCount (must not be zero)");
+                               
+                       
+                       m_host_t* nativeHosts;
+                       double* durations;
+                       double* sizes;
+                       
+                       
+                       nativeHosts = xbt_new0(m_host_t, hostCount);
+                       durations = xbt_new0(double,hostCount);
+                       sizes = xbt_new0(double, hostCount * hostCount);
+                       
+                       
+                       for(int index = 0; index < hostCount; index++) 
+                       {
+                               
+                               nativeHosts[index] = hosts[index].nativeHost;
+                               durations[index] = computeDurations[index];
+                       }
+                       
+                       for(int index = 0; index < hostCount*hostCount; index++) 
+                               sizes[index] = messageSizes[index];
+                       
+                       
+                       nativeTask = MSG_parallel_task_create(name, hostCount, nativeHosts, durations, sizes,NULL);
+                       
+                       
+                       
+                       this->nativeTask->data = (void*)this;
+                       
+               }
+               
+               const char* Task::getName(void) const
+               {
+                       return nativeTask->name;
+               }
+               
+               Process& Task::getSender(void) const
+               {
+                       m_process_t nativeProcess = MSG_task_get_sender(nativeTask);
+                       
+                       return (*((Process*)(nativeProcess->data)));
+               }
+               
+               Host& Task::getSource(void) const 
+               {
+                       m_host_t nativeHost = MSG_task_get_source(nativeTask);
+                       
+                       return (*((Host*)(nativeHost->data)));  
+               }
+               
+               double Task::getComputeDuration(void) const
+               {
+                       return MSG_task_get_compute_duration(nativeTask);
+               }
+               
+               double Task::getRemainingDuration(void) const
+               {
+                       return MSG_task_get_remaining_computation(nativeTask);
+               }
+               
+               void Task::setPriority(double priority)
+               throw(InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(priority < 0.0)
+                               throw InvalidArgumentException("priority");
+                               
+                       MSG_task_set_priority(nativeTask, priority);
+               }
+
+               Task* Task::get(int channel) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, NULL)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return ((Task*)(nativeTask->data));
+               }
+               
+               Task* Task::get(int channel, const Host& rHost) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       
+                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Task::get(int channel, double timeout, const Host& rHost) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                       
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and different thant -1.0)");      
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       
+                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , timeout, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               int Task::probe(int channel)
+               throw(InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       return MSG_task_Iprobe(channel);
+               }
+               
+               int Task::probe(int channel, const Host& rHost)
+               throw(InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       return MSG_task_probe_from_host(channel,rHost.nativeHost);
+               }
+               
+               void Task::execute(void) 
+               throw(MsgException)
+               {
+                       if(MSG_OK != MSG_task_execute(nativeTask))
+                               throw MsgException("MSG_task_execute() failed");
+               }
+               
+               void Task::cancel(void) 
+               throw(MsgException)
+               {
+                       if(MSG_OK != MSG_task_cancel(nativeTask))
+                               throw MsgException("MSG_task_cancel() failed");
+               }
+               
+               void Task::send(void) 
+               throw(BadAllocException, MsgException)
+               {       
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                               
+                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, -1.0);
+               
+                       free(alias);
+               
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Task::send(const char* alias) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+               
+                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, -1.0))
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Task::send(double timeout) 
+               throw(BadAllocException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(timeout < 0  && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");
+                                               
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+               
+                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, timeout);
+               
+                       free(alias);
+               
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }       
+               
+               void Task::send(const char* alias, double timeout) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       if(timeout < 0  && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");
+                                               
+                               
+                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, timeout))
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Task::sendBounded(double maxRate) 
+               throw(BadAllocException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(maxRate < 0 && maxRate != -1.0)
+                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");
+                                       
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                       
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                       
+                       MSG_error_t rv = MSG_task_send_bounded(nativeTask, alias, maxRate);
+                       
+                       free(alias);    
+                       
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_bounded() failed");
+                               
+               }
+               
+               void Task::sendBounded(const char* alias, double maxRate) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(maxRate < 0 && maxRate != -1.0)
+                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");
+                                                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(MSG_OK != MSG_task_send_bounded(nativeTask, alias, maxRate))
+                               throw MsgException("MSG_task_send_bounded() failed");
+               }
+
+               Task* Task::receive(void) 
+               throw(BadAllocException, MsgException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL);  
+               
+                       free(alias);
+                       
+                       if(MSG_OK != rv) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+
+               Task* Task::receive(const char* alias) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Task::receive(const char* alias, double timeout) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, NULL)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Task::receive(const char* alias, const Host& rHost) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }       
+               
+               Task* Task::receive(const char* alias, double timeout, const Host& rHost) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               int Task::listen(void) 
+               throw(BadAllocException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                               
+                       int rv = MSG_task_listen(alias);
+                       
+                       free(alias);
+                       
+                       return rv;
+               }       
+               
+               int Task::listen(const char* alias) 
+               throw(NullPointerException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       return MSG_task_listen(alias);
+               }
+               
+               int Task::listenFrom(void) 
+               throw(BadAllocException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                       
+                       int rv = MSG_task_listen_from(alias);
+                       
+                       free(alias);
+                       
+                       return rv;
+               }       
+               
+               int Task::listenFrom(const char* alias) 
+               throw(NullPointerException)
+               {
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       return MSG_task_listen_from(alias);
+                       
+               }
+               
+               int Task::listenFromHost(const Host& rHost) 
+               throw(BadAllocException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                       
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                       
+                       int rv = MSG_task_listen_from_host(alias, rHost.nativeHost);
+                       
+                       free(alias);
+                       
+                       return rv;
+               }
+                       
+               int Task::listenFromHost(const char* alias, const Host& rHost) 
+               throw(NullPointerException)
+               {
+                       // check the parameters
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       return MSG_task_listen_from_host(alias, rHost.nativeHost);
+               }       
+
+               const Task& Task::operator = (const Task& rTask)
+               {
+                       this->nativeTask = rTask.nativeTask;
+                       return *this;
+               }
+       } // namespace Msg                                                                                                                                                                                              
+} // namespace SimGrid
+