Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
not needed now
[simgrid.git] / src / cxx / Task.cxx
index b0c2ccb..93e1c68 100644 (file)
@@ -1,14 +1,23 @@
-#include <Task.hpp>\r
-\r
-#include <MsgException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <NullPointerException.hpp>\r
-#include <MsgException.hpp>\r
-#include <BadAllocException.hpp>\r
+/*\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
@@ -150,22 +159,6 @@ namespace SimGrid
                                \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) \r
                throw(InvalidArgumentException, MsgException)\r
@@ -183,7 +176,7 @@ namespace SimGrid
                        return ((Task*)(nativeTask->data));\r
                }\r
                \r
-               Task& Task::get(int channel, const Host& rHost) \r
+               Task* Task::get(int channel, const Host& rHost) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -197,10 +190,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Task::get(int channel, double timeout, const Host& rHost) \r
+               Task* Task::get(int channel, double timeout, const Host& rHost) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -217,7 +210,7 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                int Task::probe(int channel)\r
@@ -363,28 +356,6 @@ namespace SimGrid
                        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(void) \r
                throw(BadAllocException, MsgException)\r
@@ -405,24 +376,8 @@ namespace SimGrid
                        if(MSG_OK != rv) \r
                                throw MsgException("MSG_task_receive_ext() failed");\r
                \r
-                       return ((Task*)nativeTask->data);\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) \r
                throw(NullPointerException, MsgException)\r
@@ -437,10 +392,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Task::receive(const char* alias, double timeout) \r
+               Task* Task::receive(const char* alias, double timeout) \r
                throw(NullPointerException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -456,10 +411,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Task::receive(const char* alias, const Host& rHost) \r
+               Task* Task::receive(const char* alias, const Host& rHost) \r
                throw(NullPointerException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -472,10 +427,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }       \r
                \r
-               Task& Task::receive(const char* alias, double timeout, const Host& rHost) \r
+               Task* Task::receive(const char* alias, double timeout, const Host& rHost) \r
                throw(NullPointerException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -492,7 +447,7 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                int Task::listen(void) \r