+ const char* Host::getName(void) const\r
+ {\r
+ return nativeHost->name;\r
+ }\r
+ \r
+ void Host::setData(void* data)\r
+ {\r
+ this->data = data;\r
+ }\r
+ \r
+ void* Host::getData(void) const\r
+ {\r
+ return this->data;\r
+ }\r
+ \r
+ int Host::getRunningTaskNumber(void) const\r
+ {\r
+ return MSG_get_host_msgload(nativeHost); \r
+ }\r
+ \r
+ double Host::getSpeed(void) const\r
+ {\r
+ return MSG_get_host_speed(nativeHost->simdata->smx_host);\r
+ }\r
+ \r
+ bool Host::hasData(void) const\r
+ {\r
+ return (NULL != this->data);\r
+ }\r
+ \r
+ bool Host::isAvailable(void) const\r
+ {\r
+ return (bool)SIMIX_host_get_state(nativeHost->simdata->smx_host);\r
+ }\r
+ \r
+ void Host::put(int channel, const Task& rTask) \r
+ throw(MsgException, InvalidParameterException)\r
+ {\r
+ // checks the parameters\r
+ if(channel < 0)\r
+ throw InvalidParameterException("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, const Task& rTask, double timeout) \r
+ throw(MsgException, InvalidParameterException) \r
+ {\r
+ // checks the parameters\r
+ if(channel < 0)\r
+ throw InvalidParameterException("channel (must be more or equal to zero)");\r
+ \r
+ if(timeout < 0.0 && timeout != -1.0)\r
+ throw InvalidParameterException("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
+ throw MsgException("MSG_task_put_with_timeout() failed");\r
+ }\r
+ \r
+ void Host::putBounded(int channel, const Task& rTask, double maxRate) \r
+ throw(MsgException, InvalidParameterException)\r
+ {\r
+ // checks the parameters\r
+ if(channel < 0)\r
+ throw InvalidParameterException("channel (must be more or equal to zero)");\r
+ \r
+ if(maxRate < 0.0 && maxRate != -1.0)\r
+ throw InvalidParameterException("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
+ throw MsgException("MSG_task_put_bounded() failed");\r
+ }\r
+ \r
+ void Host::send(const Task& rTask) \r
+ throw(NativeException) \r
+ { \r
+ MSG_error_t rv;\r
+ \r
+ char* alias = (char*)calloc(strlen(this->getName() + strlen(Process::currentProcess().getName()) + 2);\r
+ \r
+ if(!alias)\r
+ throw BadAllocException("alias");\r
+ \r
+ sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
+ \r
+ rv = MSG_task_send_with_timeout(rTask.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 Host::send(const char* alias, const Task& rTask) \r
+ throw(InvalidParameterException, MsgException) \r
+ {\r
+ // check the parameters\r
+ if(!alias)\r
+ throw InvalidParmeterException("alias (must not be NULL)");\r
+ \r
+ if(MSG_OK != MSG_task_send_with_timeout(rTask.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
+ throw(InvalidParameterException, BadAllocException, MsgException) \r
+ {\r
+ // check the parameters\r
+ if(timeout < 0 && timeout != -1.0)\r
+ throw InvalidParameterException("timeout (must be positive or equal to zero or equal to -1.0)");\r
+ MSG_error_t rv;\r
+ \r
+ char* alias = (char*)calloc(strlen(this->getName() + strlen(Process::currentProcess().getName()) + 2);\r
+ \r
+ if(!alias)\r
+ throw BadAllocException("alias");\r
+ \r
+ sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
+ \r
+ \r
+ rv = MSG_task_send_with_timeout(rTask.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 Host::send(const char* alias, const Task& rTask, double timeout) \r
+ throw(InvalidParameterException, MsgException) \r
+ {\r
+ // check the parameter\r
+ \r
+ if(!alias)\r
+ throw InvalidParmeterException("alias (must not be NULL)");\r
+ \r
+ if(timeout < 0 && timeout != -1.0)\r
+ throw InvalidParameterException("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
+ throw MsgException("MSG_task_send_with_timeout() failed");\r
+ }\r
+ \r
+ \r
+ void Host::sendBounded(const Task& rTask, double maxRate) \r
+ throw(InvalidParameterException, BadAllocException, MsgException) \r
+ {\r
+ if(maxRate < 0 && maxRate != -1.0)\r
+ throw InvalidParameterException("maxRate (must be positive or equal to zero or equal to -1.0)");\r
+ \r
+ MSG_error_t rv;\r
+ \r
+ char* alias = (char*)calloc(strlen(this->getName() + strlen(Process::currentProcess().getName()) + 2);\r
+ \r
+ if(!alias)\r
+ throw BadAllocException("alias");\r
+ \r
+ sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
+ \r
+ rv = MSG_task_send_bounded(rTask.nativeTask, alias, maxRate);\r
+ \r
+ free(alias);\r
+ \r
+ if(MSG_OK != rv)\r
+ throw MsgException("MSG_task_send_bounded() failed");\r
+ } \r
+ \r
+ void Host::sendBounded(const char* alias, const Task& rTask, double maxRate) \r
+ throw(InvalidParameterException, MsgException) \r
+ {\r
+ // check the parameters\r
+ if(!alias)\r
+ throw InvalidParameterException("alias (must not be NULL)");\r
+ \r
+ if(maxRate < 0 && maxRate != -1)\r
+ throw InvalidParameterException("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
+ throw MsgException("MSG_task_send_bounded() failed");\r
+ \r
+ } \r
+ } // namspace Msg\r