-#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
\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
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
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
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
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
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
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
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
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
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