Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some code refactoring
[simgrid.git] / src / cxx / Host.cxx
index db4722b..18997ea 100644 (file)
  */\r
  \r
  /* Host class member functions implementation.\r
-  */  \r
-#include <Host.hpp>\r
-\r
-#include <InvalidArgumentException.hpp>\r
-#include <BadAllocException.hpp>\r
-#include <HostNotFoundException.hpp>\r
-#include <MsgException.hpp>\r
+  */ \r
 \r
 #include <Task.hpp>\r
 #include <Process.hpp>\r
 \r
+#include <Host.hpp>\r
+\r
 #include <stdlib.h>\r
 #include <stdio.h>\r
 \r
@@ -53,11 +49,11 @@ namespace SimGrid
                \r
                \r
                Host& Host::getByName(const char* hostName)\r
-               throw(HostNotFoundException, InvalidArgumentException, BadAllocException)\r
+               throw(HostNotFoundException, NullPointerException, BadAllocException)\r
                {\r
                        // check the parameters\r
                        if(!hostName)\r
-                               throw InvalidArgumentException("hostName");\r
+                               throw NullPointerException("hostName");\r
                                \r
                        m_host_t nativeHost = NULL;     // native host.\r
                        Host* host = NULL;                      // wrapper host.\r
@@ -193,17 +189,6 @@ namespace SimGrid
                        return SIMIX_host_get_state(nativeHost->simdata->smx_host);\r
                }\r
                \r
-               void Host::put(int channel, const Task& rTask) \r
-               throw(MsgException, InvalidArgumentException)\r
-               {\r
-                       // checks the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must be more or equal to zero)");\r
-                               \r
-                       if(MSG_OK != MSG_task_put_with_timeout(rTask.nativeTask, nativeHost, channel , -1.0))\r
-                               throw MsgException("MSG_task_put_with_timeout() failed");\r
-               } \r
-\r
                void Host::put(int channel, Task* task) \r
                throw(MsgException, InvalidArgumentException)\r
                {\r
@@ -214,8 +199,8 @@ namespace SimGrid
                        if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, nativeHost, channel , -1.0))\r
                                throw MsgException("MSG_task_put_with_timeout() failed");\r
                } \r
-               \r
-               void Host::put(int channel, const Task& rTask, double timeout) \r
+\r
+               void Host::put(int channel, Task* task, double timeout) \r
                throw(MsgException, InvalidArgumentException) \r
                {\r
                        // checks the parameters\r
@@ -226,11 +211,11 @@ namespace SimGrid
                                throw InvalidArgumentException("timeout (must be more or equal to zero or equal to -1.0)");     \r
                                \r
                                \r
-                   if(MSG_OK != MSG_task_put_with_timeout(rTask.nativeTask, nativeHost, channel , timeout))\r
+                   if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, nativeHost, channel , timeout))\r
                                throw MsgException("MSG_task_put_with_timeout() failed");\r
                }\r
                \r
-               void Host::putBounded(int channel, const Task& rTask, double maxRate) \r
+               void Host::putBounded(int channel, Task* task, double maxRate) \r
                throw(MsgException, InvalidArgumentException)\r
                {\r
                    // checks the parameters\r
@@ -240,12 +225,12 @@ namespace SimGrid
                        if(maxRate < 0.0 && maxRate != -1.0)\r
                                throw InvalidArgumentException("maxRate (must be more or equal to zero or equal to -1.0)");     \r
                    \r
-                       if(MSG_OK != MSG_task_put_bounded(rTask.nativeTask, nativeHost, channel, maxRate))\r
+                       if(MSG_OK != MSG_task_put_bounded(task->nativeTask, nativeHost, channel, maxRate))\r
                                throw MsgException("MSG_task_put_bounded() failed");\r
                }\r
                \r
-               void Host::send(const Task& rTask) \r
-               throw(MsgException)  \r
+               void Host::send(Task* task) \r
+               throw(MsgException, BadAllocException)  \r
                {       \r
                        MSG_error_t rv;\r
                        \r
@@ -256,7 +241,7 @@ namespace SimGrid
                                \r
                        sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
                                \r
-                       rv = MSG_task_send_with_timeout(rTask.nativeTask, alias, -1.0);\r
+                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, -1.0);\r
                        \r
                        free(alias);\r
                        \r
@@ -264,18 +249,18 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_with_timeout() failed");\r
                } \r
                \r
-               void Host::send(const char* alias, const Task& rTask) \r
+               void Host::send(const char* alias, Task* task) \r
                throw(InvalidArgumentException, MsgException) \r
                {\r
                        // check the parameters\r
                        if(!alias)\r
                                throw InvalidArgumentException("alias (must not be NULL)");\r
                        \r
-                       if(MSG_OK != MSG_task_send_with_timeout(rTask.nativeTask, alias, -1.0))\r
+                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias, -1.0))\r
                                throw MsgException("MSG_task_send_with_timeout() failed");\r
                }\r
                \r
-               void Host::send(const Task& rTask, double timeout) \r
+               void Host::send(Task* task, double timeout) \r
                throw(InvalidArgumentException, BadAllocException, MsgException) \r
                {\r
                        // check the parameters\r
@@ -292,7 +277,7 @@ namespace SimGrid
                        sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
                                \r
                                \r
-                       rv = MSG_task_send_with_timeout(rTask.nativeTask, alias, timeout);\r
+                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, timeout);\r
                        \r
                        free(alias);\r
                        \r
@@ -300,7 +285,7 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_with_timeout() failed");\r
                }\r
                \r
-               void Host::send(const char* alias, const Task& rTask, double timeout) \r
+               void Host::send(const char* alias, Task* task, double timeout) \r
                throw(InvalidArgumentException, MsgException) \r
                {\r
                        // check the parameter\r
@@ -311,12 +296,12 @@ namespace SimGrid
                        if(timeout < 0 && timeout != -1.0)\r
                                throw InvalidArgumentException("timeout (must be positive or equal to zero or equal to -1.0)");\r
                                        \r
-                       if(MSG_OK != MSG_task_send_with_timeout(rTask.nativeTask, alias, timeout))\r
+                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias, timeout))\r
                                throw MsgException("MSG_task_send_with_timeout() failed");\r
                }\r
                \r
                \r
-               void Host::sendBounded(const Task& rTask, double maxRate) \r
+               void Host::sendBounded(Task* task, double maxRate) \r
                throw(InvalidArgumentException, BadAllocException, MsgException) \r
                {\r
                        if(maxRate < 0 && maxRate != -1.0)\r
@@ -331,7 +316,7 @@ namespace SimGrid
                                \r
                        sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
                                \r
-                       rv = MSG_task_send_bounded(rTask.nativeTask, alias, maxRate);\r
+                       rv = MSG_task_send_bounded(task->nativeTask, alias, maxRate);\r
                        \r
                        free(alias);\r
                        \r
@@ -339,7 +324,7 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_bounded() failed");\r
                }  \r
                \r
-               void Host::sendBounded(const char* alias, const Task& rTask, double maxRate) \r
+               void Host::sendBounded(const char* alias, Task* task, double maxRate) \r
                throw(InvalidArgumentException, MsgException) \r
                {\r
                        // check the parameters\r
@@ -349,9 +334,10 @@ namespace SimGrid
                        if(maxRate < 0 && maxRate != -1)\r
                                throw InvalidArgumentException("maxRate (must be positive or equal to zero or equal to -1.0)");\r
                        \r
-                       if(MSG_OK != MSG_task_send_bounded(rTask.nativeTask, alias, maxRate))\r
+                       if(MSG_OK != MSG_task_send_bounded(task->nativeTask, alias, maxRate))\r
                                throw MsgException("MSG_task_send_bounded() failed");\r
                        \r
                }\r
        } // namspace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r