*/ \r
\r
#include <Application.hpp>\r
+\r
+\r
+#include <NullPointerException.hpp>\r
+#include <FileNotFoundException.hpp>\r
+#include <LogicException.hpp>\r
+#include <MsgException.hpp>\r
#include <ApplicationHandler.hpp>\r
\r
#include <sys/types.h>\r
#include <sys/stat.h>\r
+#include <stdlib.h>\r
+\r
+#include <surf/surfxml_parse.h>\r
\r
#ifndef S_ISREG\r
#define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)\r
this->deployed = false;\r
}\r
\r
- Application(const Application& rApplication)\r
+ Application::Application(const Application& rApplication)\r
{\r
\r
this->file = rApplication.getFile();\r
\r
struct stat statBuf = {0};\r
\r
- if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
+ if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
throw FileNotFoundException(file);\r
\r
this->file = file;\r
// NOTHING TODO\r
}\r
\r
- Application::deploy(const char* file)\r
+ void Application::deploy(const char* file)\r
throw(NullPointerException, FileNotFoundException, LogicException, MsgException)\r
{\r
// check logic\r
\r
struct stat statBuf = {0};\r
\r
- if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
+ if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
throw FileNotFoundException(file);\r
\r
surf_parse_reset_parser();\r
surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);\r
\r
// set the process arg handler\r
- surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onArg);\r
+ surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);\r
\r
// set the properties handler\r
surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
\r
// set the end of the xml process element handler\r
- surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::OnEndProcess);\r
+ surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);\r
\r
surf_parse_open(file);\r
\r
this->deployed = true;\r
}\r
\r
- Application::deploy(void)\r
+ void Application::deploy(void)\r
throw(LogicException, MsgException)\r
{\r
// check logic\r
\r
surf_parse_reset_parser();\r
surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);\r
- surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onArg);\r
+ surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);\r
surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
- surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::OnEndProcess);\r
+ surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);\r
\r
surf_parse_open(file);\r
\r
this->deployed = true; \r
}\r
\r
- bool Application::isDeployed(void)\r
+ bool Application::isDeployed(void) const\r
{\r
return this->deployed;\r
}\r
\r
struct stat statBuf = {0};\r
\r
- if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
+ if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
throw FileNotFoundException("file (file not found)");\r
\r
this->file = file;\r
#error Application.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
-#include <NullPointerException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-#include <LogicException.hpp>\r
-#include <MsgException.hpp>\r
+#include <Config.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class NullPointerException;\r
+ class FileNotFoundException;\r
+ class LogicException;\r
+ class MsgException;\r
+\r
// Application wrapper class declaration.\r
- class Application\r
+ class SIMGRIDX_EXPORT Application\r
{\r
public:\r
\r
*/\r
\r
void deploy(void)\r
- throw(LogicExeption, MsgException);\r
+ throw(LogicException, MsgException);\r
\r
/*! \brief Application::deploy() - Deploy the appliction.\r
*\r
\r
// the xml file which describes the application of the simulation.\r
const char* file;\r
+\r
};\r
\r
} // namespace Msg\r
\r
/* ApplicationHandler member functions implementation.\r
*/ \r
- \r
+\r
#include <ApplicationHandler.hpp>\r
\r
+#include <Object.hpp>\r
+#include <ClassNotFoundException.hpp>\r
+#include <HostNotFoundException.hpp>\r
+#include <Host.hpp>\r
+#include <Process.hpp>\r
+\r
+#include <stdlib.h>\r
+\r
+#include <surf/surfxml_parse.h>\r
+#include <xbt/sysdep.h>\r
+\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- ApplicationHandler::ProcessFactory::processFactory = NULL;\r
+ ApplicationHandler::ProcessFactory* ApplicationHandler::processFactory = NULL;\r
\r
// Desable the default constructor, the copy constructor , the assignement operator\r
// and the destructor of this class. Assume that this class is static.\r
{\r
// release the handler at the end of the parsing.\r
if(processFactory)\r
- delete processFactroy;\r
+ delete processFactory;\r
}\r
\r
void ApplicationHandler::onBeginProcess(void)\r
\r
ApplicationHandler::ProcessFactory::ProcessFactory() \r
{\r
- this->args = xbt_dynar_new(sizeof(char*),ProcessFactory::freeCstr);\r
+ this->args = xbt_dynar_new(sizeof(char*),ApplicationHandler::ProcessFactory::freeCstr);\r
this->properties = NULL; // TODO instanciate the dictionary\r
this->hostName = NULL;\r
this->function = NULL;\r
throw (ClassNotFoundException, HostNotFoundException)\r
{\r
Host host;\r
+ Class* c;\r
Process* process;\r
\r
// try to dynamicaly create an instance fo the process from its name (which is specified by the element function\r
// in the xml application file.\r
// if this static method fails, it throws an exception of the class ClassNotFoundException\r
- process = (Process*)Class::fromName(this->function);\r
+ c = Class::fromName(this->function);\r
+ process = reinterpret_cast<Process*>(c->createObject());\r
\r
// try to retrieve the host of the process from its name\r
// if this method fails, it throws an exception of the class HostNotFoundException\r
\r
char** argv = (char**)calloc(argc, sizeof(char*));\r
\r
- for(int i = 0; i < argc; i++)\r
+ for(int i = argc -1; i >= 0; i--)\r
xbt_dynar_pop(this->args, &(argv[i]));\r
\r
// finaly create the process (for more detail on the process creation see Process::create()\r
this->properties = new Properties();*/\r
}\r
\r
- void ApplicationHandler::ProcessFactory::setProcessIdentity(const string& hostName, const string& function) \r
+ void ApplicationHandler::ProcessFactory::setProcessIdentity(const char* hostName, const char* function) \r
{\r
this->hostName = hostName;\r
this->function = function;\r
// callback function used by the dynamic array to cleanup all of its elements.\r
void ApplicationHandler::ProcessFactory::freeCstr(void* cstr)\r
{\r
- free(*(void**)str);\r
+ free(*(void**)cstr);\r
}\r
\r
void ApplicationHandler::ProcessFactory::registerProcessArg(const char* arg) \r
{\r
- char* cstr = strdup(arg);\r
+ char* cstr = _strdup(arg);\r
xbt_dynar_push(this->args, &cstr);\r
}\r
\r
// TODO implement this function; \r
}\r
\r
- const const char* ApplicationHandler::ProcessFactory::getHostName(void)\r
+ const char* ApplicationHandler::ProcessFactory::getHostName(void)\r
{\r
return this->hostName;\r
}\r
#error ApplicationHandler.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
+#include <xbt/dict.h>\r
+#include <xbt/dynar.h>\r
\r
-#include <ClassNotFoundException.hpp>\r
-#include <HostNotFoundException.hpp>\r
+#include <Config.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+\r
+ class ClassNotFoundException;\r
+ class HostNotFoundException;\r
+ class Process;\r
+\r
// Declaration of the class ApplicationHandler (Singleton).\r
- class ApplicationHandler\r
+ class SIMGRIDX_EXPORT ApplicationHandler\r
{\r
- private :\r
- \r
- // Desable the default constructor, the copy constructor , the assignement operator\r
- // and the destructor of this class. Assume that this class is static.\r
- \r
- // Default constructor.\r
- ApplicationHandler();\r
- \r
- // Copy constructor.\r
- ApplicationHandler(const ApplicationHandler& rApplicationHandler);\r
- \r
- // Destructor\r
- virtual ~ApplicationHandler();\r
- \r
- // Assignement operator.\r
- const ApplicationHandler& operator = (const ApplicationHandler& rApplicationHandler);\r
- \r
+ friend Process;\r
+\r
+ public:\r
+\r
class ProcessFactory \r
{\r
public:\r
\r
public :\r
\r
- // Default constructor.\r
- ProcessFactory(); \r
- \r
- // Copy constructor.\r
- ProcessFactory(const ProcessFactory& rProcessFactory);\r
- \r
- // Destructor.\r
- virtual ~ProcessFactory();\r
- \r
- // Set the identity of the current process.\r
- void setProcessIdentity(const char* hostName, const char* function);\r
- \r
- // Register an argument of the current process.\r
- void registerProcessArg(const char* arg); \r
- \r
- // Set the property of the current process.\r
- void setProperty(const char* id, const char* value);\r
- \r
- // Return the host name of the current process.\r
- const const char* getHostName(void);\r
- \r
- // Create the current process.\r
- void createProcess(void)\r
- throw (ClassNotFoundException, HostNotFoundException); \r
+ // Default constructor.\r
+ ProcessFactory(); \r
+ \r
+ // Copy constructor.\r
+ ProcessFactory(const ProcessFactory& rProcessFactory);\r
+ \r
+ // Destructor.\r
+ virtual ~ProcessFactory(){}\r
+ \r
+ // Set the identity of the current process.\r
+ void setProcessIdentity(const char* hostName, const char* function);\r
+ \r
+ // Register an argument of the current process.\r
+ void registerProcessArg(const char* arg); \r
+ \r
+ // Set the property of the current process.\r
+ void setProperty(const char* id, const char* value);\r
+ \r
+ // Return the host name of the current process.\r
+ const char* getHostName(void);\r
+ \r
+ // Create the current process.\r
+ void createProcess(void)\r
+ throw (ClassNotFoundException, HostNotFoundException); \r
+\r
+ static void freeCstr(void* cstr);\r
\r
};\r
+\r
+ private :\r
+ \r
+ // Desable the default constructor, the copy constructor , the assignement operator\r
+ // and the destructor of this class. Assume that this class is static.\r
+ \r
+ // Default constructor.\r
+ ApplicationHandler();\r
+ \r
+ // Copy constructor.\r
+ ApplicationHandler(const ApplicationHandler& rApplicationHandler);\r
+ \r
+ // Destructor\r
+ virtual ~ApplicationHandler();\r
+ \r
+ // Assignement operator.\r
+ const ApplicationHandler& operator = (const ApplicationHandler& rApplicationHandler);\r
\r
// the process factory used by the application handler.\r
static ProcessFactory* processFactory;\r
-#include "BadAllocException.hpp"\r
+#include <BadAllocException.hpp>\r
\r
#include <string.h>\r
#include <stdlib.h>\r
#include <stdio.h>\r
\r
-using namespace std;\r
-\r
namespace SimGrid\r
{\r
namespace Msg\r
*\r
*/ \r
\r
-#ifndef MSG_MSGEXCEPTION_HPP\r
-#define MSG_MSGEXCEPTION_HPP\r
+#ifndef MSG_BADALLOCEXCEPTION_HPP\r
+#define MSG_BADALLOCEXCEPTION_HPP\r
\r
-#include "Exception.hpp"\r
+#include <Exception.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- class BadAllocException : public Exception\r
+ class SIMGRIDX_EXPORT BadAllocException : public Exception\r
{\r
public:\r
\r
}// namespace SimGrid\r
\r
\r
-#endif // !MSG_MSGEXCEPTION_HPP\r
+#endif // !MSG_BADALLOCEXCEPTION_HPP\r
\r
#include <Environment.hpp>\r
\r
+#include <NullPointerException.hpp>\r
+#include <FileNotFoundException.hpp>\r
+#include <InvalidArgumentException.hpp>\r
+#include <LogicException.hpp>\r
+#include <MsgException.hpp>\r
+\r
+#include <stdlib.h>\r
+\r
#include <sys/types.h>\r
#include <sys/stat.h>\r
\r
+#include <msg/msg.h>\r
+\r
#ifndef S_ISREG\r
#define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)\r
#endif\r
this->loaded = false;\r
}\r
\r
- Environment::Environment(const Environment& rEnvironment);\r
+ Environment::Environment(const Environment& rEnvironment)\r
{\r
this->file = rEnvironment.getFile();\r
this->loaded = rEnvironment.isLoaded();\r
}\r
\r
Environment::Environment(const char* file)\r
- throw(NullPointerException, InvalidArgumentException);\r
+ throw(NullPointerException, InvalidArgumentException)\r
{\r
// check parameters\r
\r
\r
struct stat statBuf = {0};\r
\r
- if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
- throw InvalidParameterException("file (file not found)");\r
+ if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
+ throw InvalidArgumentException("file (file not found)");\r
\r
this->file = file;\r
this->loaded = false;\r
\r
struct stat statBuf = {0};\r
\r
- if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
+ if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
throw FileNotFoundException(file);\r
\r
MSG_create_environment(file);\r
\r
struct stat statBuf = {0};\r
\r
- if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
+ if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
throw FileNotFoundException("file (file not found)");\r
\r
this->file = file;\r
#error Environment.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
-#include <NullPointerException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-#include <LogicException.hpp>\r
-#include <MsgException.hpp>\r
-\r
+#include <Config.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class NullPointerException;\r
+ class FileNotFoundException;\r
+ class InvalidArgumentException;\r
+ class LogicException;\r
+ class MsgException;\r
+\r
// Environment class wrapper declaration\r
- class Environment\r
+ class SIMGRIDX_EXPORT Environment\r
{\r
public:\r
\r
const char* file;\r
\r
// flag : is true the environment of the simulation is loaded.\r
- bool loaded.\r
+ bool loaded;\r
};\r
\r
} // namespace Msg\r
-#include "Exception.hpp"\r
+#include <Exception.hpp>\r
\r
namespace SimGrid\r
{\r
#ifndef MSG_EXCEPTION_HPP\r
#define MSG_EXCEPTION_HPP\r
\r
+#include <Config.hpp>\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- class Exception\r
+ class SIMGRIDX_EXPORT Exception\r
{\r
public:\r
\r
#include <stdlib.h>\r
#include <stdio.h>\r
\r
-using namespace std;\r
\r
namespace SimGrid\r
{\r
#ifndef MSG_FILENOTFOUND_HPP\r
#define MSG_FILENOTFOUND_HPP\r
\r
-#include <Exception.hp>\r
+#include <Exception.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- class FileNotFoundException : public Exception\r
+ class SIMGRIDX_EXPORT FileNotFoundException : public Exception\r
{\r
public:\r
\r
*/ \r
#include <Host.hpp>\r
\r
+#include <InvalidArgumentException.hpp>\r
+#include <BadAllocException.hpp>\r
+#include <HostNotFoundException.hpp>\r
+#include <MsgException.hpp>\r
+\r
+#include <Task.hpp>\r
+#include <Process.hpp>\r
+\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+\r
+#include <msg/msg.h>\r
+#include <msg/private.h>\r
+\r
+#include <xbt/fifo.h>\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
\r
\r
Host& Host::getByName(const char* hostName)\r
- throw(HostNotFoundException, InvalidParameterException, BadAllocException)\r
+ throw(HostNotFoundException, InvalidArgumentException, BadAllocException)\r
{\r
// check the parameters\r
if(!hostName)\r
- throw InvalidParmeterException("hostName");\r
+ throw InvalidArgumentException("hostName");\r
\r
m_host_t nativeHost = NULL; // native host.\r
Host* host = NULL; // wrapper host.\r
{ // native host not associated yet with its wrapper\r
\r
// instanciate a new wrapper \r
- if(!(host = new Host())\r
+ if(!(host = new Host()))\r
throw BadAllocException(hostName);\r
\r
host->nativeHost = nativeHost; \r
}\r
\r
void Host::all(Host*** hosts, int* len) \r
- throw(InvalidParameterException, BadAllocException) \r
+ throw(InvalidArgumentException, BadAllocException) \r
{\r
- /* check the parameters */\r
+ // check the parameters\r
if(!hosts)\r
- throw InvalidParameterException("hosts");\r
+ throw InvalidArgumentException("hosts");\r
\r
if(len < 0)\r
- throw InvalidParameterException("len parameter must be positive");\r
+ throw InvalidArgumentException("len parameter must be positive");\r
\r
int count = xbt_fifo_size(msg_global->host);\r
\r
if(*len < count)\r
- throw InvalidParameterException("len parameter must be more than the number of installed host\n (use Host::getNumber() to get the number of hosts)");\r
+ throw InvalidArgumentException("len parameter must be more than the number of installed host\n (use Host::getNumber() to get the number of hosts)");\r
\r
int index;\r
m_host_t nativeHost;\r
\r
if(!host) \r
{\r
- if(!(host = new Host())\r
+ if(!(host = new Host()))\r
{\r
// release all allocated memory.\r
for(int i = 0; i < index; i++)\r
\r
double Host::getSpeed(void) const\r
{\r
- return MSG_get_host_speed(nativeHost->simdata->smx_host);\r
+ return MSG_get_host_speed(nativeHost);\r
}\r
\r
bool Host::hasData(void) const\r
return (NULL != this->data);\r
}\r
\r
- bool Host::isAvailable(void) const\r
+ int Host::isAvailable(void) const\r
{\r
- return (bool)SIMIX_host_get_state(nativeHost->simdata->smx_host);\r
+ return SIMIX_host_get_state(nativeHost->simdata->smx_host);\r
}\r
\r
void Host::put(int channel, const Task& rTask) \r
- throw(MsgException, InvalidParameterException)\r
+ throw(MsgException, InvalidArgumentException)\r
{\r
// checks the parameters\r
if(channel < 0)\r
- throw InvalidParameterException("channel (must be more or equal to zero)");\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
+ // 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(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
- throw(MsgException, InvalidParameterException) \r
+ throw(MsgException, InvalidArgumentException) \r
{\r
// checks the parameters\r
if(channel < 0)\r
- throw InvalidParameterException("channel (must be more or equal to zero)");\r
+ throw InvalidArgumentException("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
+ 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
}\r
\r
void Host::putBounded(int channel, const Task& rTask, double maxRate) \r
- throw(MsgException, InvalidParameterException)\r
+ throw(MsgException, InvalidArgumentException)\r
{\r
// checks the parameters\r
if(channel < 0)\r
- throw InvalidParameterException("channel (must be more or equal to zero)");\r
+ throw InvalidArgumentException("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
+ 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
throw MsgException("MSG_task_put_bounded() failed");\r
}\r
\r
void Host::send(const Task& rTask) \r
- throw(NativeException) \r
+ throw(MsgException) \r
{ \r
MSG_error_t rv;\r
\r
- char* alias = (char*)calloc(strlen(this->getName() + strlen(Process::currentProcess().getName()) + 2);\r
+ char* alias = (char*)calloc(strlen(this->getName())+ strlen(Process::currentProcess().getName()) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
} \r
\r
void Host::send(const char* alias, const Task& rTask) \r
- throw(InvalidParameterException, MsgException) \r
+ throw(InvalidArgumentException, MsgException) \r
{\r
// check the parameters\r
if(!alias)\r
- throw InvalidParmeterException("alias (must not be NULL)");\r
+ throw InvalidArgumentException("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
+ throw(InvalidArgumentException, 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
+ throw InvalidArgumentException("timeout (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
+ char* alias = (char*)calloc(strlen(this->getName()) + strlen(Process::currentProcess().getName()) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
}\r
\r
void Host::send(const char* alias, const Task& rTask, double timeout) \r
- throw(InvalidParameterException, MsgException) \r
+ throw(InvalidArgumentException, MsgException) \r
{\r
// check the parameter\r
\r
if(!alias)\r
- throw InvalidParmeterException("alias (must not be NULL)");\r
+ throw InvalidArgumentException("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
+ 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
throw MsgException("MSG_task_send_with_timeout() failed");\r
\r
\r
void Host::sendBounded(const Task& rTask, double maxRate) \r
- throw(InvalidParameterException, BadAllocException, MsgException) \r
+ throw(InvalidArgumentException, 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
+ throw InvalidArgumentException("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
+ char* alias = (char*)calloc(strlen(this->getName()) + strlen(Process::currentProcess().getName()) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
} \r
\r
void Host::sendBounded(const char* alias, const Task& rTask, double maxRate) \r
- throw(InvalidParameterException, MsgException) \r
+ throw(InvalidArgumentException, MsgException) \r
{\r
// check the parameters\r
if(!alias)\r
- throw InvalidParameterException("alias (must not be NULL)");\r
+ throw InvalidArgumentException("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
+ 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
throw MsgException("MSG_task_send_bounded() failed");\r
\r
- } \r
+ }\r
} // namspace Msg\r
} // namespace SimGrid
\ No newline at end of file
#error Host.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
-#include <InvalidArgumentException.hpp>\r
-#include <BadAllocException.hpp>\r
-#include <HostNotFoundException.hpp>\r
-#include <MsgException.hpp>\r
+#include <msg/datatypes.h>\r
+\r
+#include <Config.hpp>\r
+\r
\r
// namespace SimGrid::Msg\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class InvalidArgumentException;\r
+ class BadAllocException;\r
+ class HostNotFoundException;\r
+ class MsgException;\r
+\r
+ class Task;\r
+ class Process;\r
+\r
// Declaration of the class SimGrid::Msg::Host.\r
- class Host // final class.\r
+ class SIMGRIDX_EXPORT Host // final class.\r
{\r
+ friend Process;\r
+ friend Task;\r
+\r
// Desable the default constructor.\r
// The best way to get an host instance is to use the static method Host::getByName().\r
\r
- private :\r
+ public :\r
\r
// Default constructor (desabled).\r
Host();\r
*\r
* \exception [HostNotFoundException] if no host with the specified name\r
* was found.\r
- * [InvalidParameterException] if the hostName parameter is invalid (NULL).\r
+ * [InvalidArgumentException] if the hostName parameter is invalid (NULL).\r
* [BadAllocException] if there is not enough memory to allocate the host.\r
*/ \r
static Host& getByName(const char* hostName)\r
- throw(HostNotFoundException, InvalidParameterException, BadAllocException);\r
+ throw(HostNotFoundException, InvalidArgumentException, BadAllocException);\r
\r
/*! \brief Host::getNumber() - returns the number of the installed hosts.\r
*\r
* \see Process::currentProcess().\r
*/\r
static Host& currentHost(void)\r
- throw(InvalidParameterException, BadAllocException);\r
+ throw(InvalidArgumentException, BadAllocException);\r
\r
/*! \brief Host::all() - This static method retrieves all of the hosts of the installed platform.\r
*\r
* the parameter len is set with the number of hosts of the platform.\r
* Otherwise the method throw one of the exception described below.\r
*\r
- * \exception [InvalidParameterException] if the parameter hosts is invalid or\r
+ * \exception [InvalidArgumentException] if the parameter hosts is invalid or\r
* if the parameter len is negative or\r
* less than the number of hosts installed\r
* on the current platform.\r
/*! \brief Host::isAvailable - tests if an host is availabled.\r
* \r
* \return Is the host is availabled the method returns\r
- * true. Otherwise the method returns false.\r
+ * 1. Otherwise the method returns 0.\r
*/ \r
- bool isAvailble(void) const;\r
+ int isAvailable(void) const;\r
\r
/* ! \brief Host::put() - put a task on the given channel of a host .\r
*\r
* the method throws one of the exceptions described below.\r
*\r
* \exception [MsgException] if an internal error occurs.\r
- * [InvalidParameterException] if the value of the channel specified as\r
+ * [InvalidArgumentException] if the value of the channel specified as\r
* parameter is negative.\r
*/\r
void put(int channel, const Task& rTask)\r
- throw(MsgException, InvalidParameterException);\r
+ throw(MsgException, InvalidArgumentException);\r
+\r
+ void Host::put(int channel, Task* task) \r
+ throw(MsgException, InvalidArgumentException);\r
\r
/* ! \brief Host::put() - put a task on the given channel of a host object (waiting at most timeout seconds).\r
*\r
* the method throws one of the exceptions described below.\r
*\r
* \exception [MsgException] if an internal error occurs.\r
- * [InvalidParameterException] if the value of the channel specified as\r
+ * [InvalidArgumentException] if the value of the channel specified as\r
* parameter is negative or if the timeout value\r
* is less than zero and différent of -1.\r
*\r
* \remark To specify no timeout set the timeout value with -1.0.\r
*/\r
- void put(int channel, Task task, double timeout) \r
- throw(MsgException, InvalidParameterException);\r
+ void put(int channel, const Task& rTask, double timeout) \r
+ throw(MsgException, InvalidArgumentException);\r
\r
/* ! \brief Host::putBounded() - put a task on the given channel of a host object (capping the emission rate to maxrate).\r
*\r
* the method throws one of the exceptions described below.\r
*\r
* \exception [MsgException] if an internal error occurs.\r
- * [InvalidParameterException] if the value of the channel specified as\r
+ * [InvalidArgumentException] if the value of the channel specified as\r
* parameter is negative or if the maxRate parameter value\r
* is less than zero and différent of -1.0.\r
*\r
* \remark To specify no rate set the maxRate parameter value with -1.0.\r
*/\r
void putBounded(int channel, const Task& rTask, double maxRate) \r
- throw(MsgException, InvalidParameterException);\r
+ throw(MsgException, InvalidArgumentException);\r
\r
/* ! brief Host::send() - sends the given task to mailbox identified by the default alias.\r
*\r
* \return If successful the task is sended to the default mailbox. Otherwise the\r
* method throws one of the exceptions described below.\r
*\r
- * \exception [InvalidParameterException] if alias parameter is invalid (NULL).\r
+ * \exception [InvalidArgumentException] if alias parameter is invalid (NULL).\r
* [BadAllocException] if there is not enough memory to allocate\r
* the default alias variable.\r
* [MsgException] if an internal error occurs.\r
*/\r
void send(const char* alias, const Task& rTask) \r
- throw(InvalidParameterException, BadAllocException, MsgException);\r
+ throw(InvalidArgumentException, BadAllocException, MsgException);\r
\r
/* ! brief Host::send() - sends the given task to mailbox identified by the default alias\r
* (waiting at most timeout seconds).\r
*\r
* \exception [BadAllocException] if there is not enough memory to allocate\r
* the default alias variable.\r
- * [InvalidParameterException] if the timeout value is negative and different of\r
+ * [InvalidArgumentException] if the timeout value is negative and different of\r
* -1.0. \r
* [MsgException] if an internal error occurs.\r
*\r
*\r
*/\r
void send(const Task& rTask, double timeout) \r
- throw(NativeException);\r
+ throw(MsgException);\r
\r
/* ! brief Host::send() - sends the given task to mailbox identified by the parameter alias\r
* (waiting at most timeout seconds).\r
* \return If successful the task is sended to the default mailbox. Otherwise the\r
* method throws one of the exceptions described below.\r
*\r
- * \exception [InvalidParameterException] if the timeout value is negative and different of\r
+ * \exception [InvalidArgumentException] if the timeout value is negative and different of\r
* -1.0 or if the alias parameter is invalid (NULL). \r
* [MsgException] if an internal error occurs.\r
*\r
*\r
*/\r
void send(const char* alias, const Task& rTask, double timeout) \r
- throw(InvalidParameterException, MsgException);\r
+ throw(InvalidArgumentException, MsgException);\r
\r
/* ! brief Host::sendBounded() - sends the given task to mailbox associated to the default alias\r
* (capping the emission rate to maxRate).\r
* \return If successful the task is sended to the default mailbox. Otherwise the\r
* method throws one of the exceptions described below.\r
*\r
- * \exception [InvalidParameterException] if the maximum rate value is negative and different of\r
+ * \exception [InvalidArgumentException] if the maximum rate value is negative and different of\r
* -1.0. \r
* [MsgException] if an internal error occurs.\r
* [BadAllocException] if there is not enough memory to allocate\r
*\r
*/\r
void sendBounded(const Task& rTask, double maxRate) \r
- throw(InvalidParameterException, BadAllocException, MsgException);\r
+ throw(InvalidArgumentException, BadAllocException, MsgException);\r
\r
/* ! brief Host::sendBounded() - sends the given task to mailbox identified by the parameter alias\r
* (capping the emission rate to maxRate).\r
* \return If successful the task is sended to the default mailbox. Otherwise the\r
* method throws one of the exceptions described below.\r
*\r
- * \exception [InvalidParameterException] if the maximum rate value is negative and different of\r
+ * \exception [InvalidArgumentException] if the maximum rate value is negative and different of\r
* -1.0 or if the alias parameter is invalid (NULL). \r
* [MsgException] if an internal error occurs.\r
*\r
*\r
*/\r
void sendBounded(const char* alias, const Task& rTask, double maxRate) \r
- throw(InvalidParameterException, MsgException);\r
+ throw(InvalidArgumentException, MsgException);\r
\r
protected:\r
// Attributes.\r
-#include "HostNotFoundException.hpp"\r
+#include <HostNotFoundException.hpp>\r
\r
#include <string.h>\r
#include <stdlib.h>\r
#include <stdio.h>\r
\r
-using namespace std;\r
-\r
namespace SimGrid\r
{\r
namespace Msg\r
#ifndef MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
#define MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
\r
-#include "Exception.hpp"\r
+#include <Exception.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- class HostNotFoundException : public Exception\r
+ class SIMGRIDX_EXPORT HostNotFoundException : public Exception\r
{\r
public:\r
\r
-#include "InvalidArgumentException.hpp"\r
+#include <InvalidArgumentException.hpp>\r
\r
#include <string.h>\r
#include <stdlib.h>\r
#include <stdio.h>\r
\r
-using namespace std;\r
-\r
namespace SimGrid\r
{\r
namespace Msg\r
#ifndef MSG_INVALIDARGUMENTEXCEPTION_HPP\r
#define MSG_INVALIDARGUMENTEXCEPTION_HPP\r
\r
-#include "Exception.hpp"\r
+#include <Exception.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- class InvalidArgumentException : public Exception\r
+ class SIMGRIDX_EXPORT InvalidArgumentException : public Exception\r
{\r
public:\r
\r
-#include "LogicException.hpp"\r
+#include <LogicException.hpp>\r
\r
#include <string.h>\r
#include <stdlib.h>\r
#include <stdio.h>\r
\r
-using namespace std;\r
-\r
namespace SimGrid\r
{\r
namespace Msg\r
#ifndef MSG_LOGICEXCEPTION_HPP\r
#define MSG_LOGICEXCEPTION_HPP\r
\r
-#include "Exception.hpp"\r
+#include <Exception.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- class LogicException : public Exception\r
+ class SIMGRIDX_EXPORT LogicException : public Exception\r
{\r
public:\r
\r
\r
/* Msg functions implementation.\r
*/ \r
+\r
+#include <MsgException.hpp>\r
#include <Msg.hpp>\r
\r
+#include <msg/msg.h>\r
+#include <stdio.h>\r
+\r
+// XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(SimGridX);\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
\r
void info(const char* s)\r
{\r
- INFO1("%s",s);\r
+ //INFO1("%s",s);\r
+ printf("[SimGridX/info] %s\n", s);\r
+ }\r
+\r
+ double getClock(void)\r
+ {\r
+ return MSG_get_clock();\r
}\r
\r
} // namespace Msg\r
#error Msg.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
-#include <MsgException.hpp>\r
+#include <Config.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class MsgException;\r
\r
/*! \brief init() - Initialize MSG (This function must be called at the begining of each simulation).\r
*\r
* \param argv A list of arguments.\r
* \param argc The number of arguments of the list.\r
*/\r
- static void init(int argc, char** argv);\r
+ SIMGRIDX_EXPORT void init(int argc, char** argv);\r
\r
- /* \brief finalize() - Finalize MSG (This function must be called at the end of each simulation).\r
+ /*! \brief finalize() - Finalize MSG (This function must be called at the end of each simulation).\r
*\r
* \exception If this function fails, it throws a exception describing the cause of the failure.\r
*/\r
- static void finalize(void)\r
+ SIMGRIDX_EXPORT void finalize(void)\r
throw (MsgException);\r
\r
/*! \brief info() - Display information (using xbt log format).\r
*\r
* \param s The information to display.\r
*/\r
- static void info(const char* s);\r
- \r
- \r
- \r
+ SIMGRIDX_EXPORT void info(const char* s);\r
+\r
+ /*! \brief getClock() - Retrieve the simulation time\r
+ *\r
+ * \return The current simulation time.\r
+ */\r
+ SIMGRIDX_EXPORT double getClock(void);\r
\r
} // namespace Msg\r
} // namespace SimGrid\r
-#include "MsgException.hpp"\r
+#include <MsgException.hpp>\r
\r
#include <string.h>\r
#include <stdlib.h>\r
#include <stdio.h>\r
\r
-using namespace std;\r
-\r
namespace SimGrid\r
{\r
namespace Msg\r
#ifndef MSG_MSGEXCEPTION_HPP\r
#define MSG_MSGEXCEPTION_HPP\r
\r
-#include "Exception.hpp"\r
+#include <Exception.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
\r
- class MsgException : public Exception\r
+ class SIMGRIDX_EXPORT MsgException : public Exception\r
{\r
public:\r
\r
-#include <object.hpp>\r
+#include <Object.hpp>\r
#include <string.h>\r
\r
\r
DeclaringClasses* DeclaringClass::declaringClasses = NULL;\r
\r
\r
-namespace msg\r
+namespace SimGrid\r
{\r
- // Generate static object constructor for class registration\r
- void DeclareClass(Class* c)\r
- {\r
- MSG_DELCARING_CLASSES.lock();\r
- MSG_DELCARING_CLASSES.addHead(c);\r
- MSG_DELCARING_CLASSES.unlock();\r
- }\r
-} \r
+ namespace Msg\r
+ {\r
+\r
+ // Generate static object constructor for class registration\r
+ void DeclareClass(Class* c)\r
+ {\r
+ MSG_DELCARING_CLASSES.lock();\r
+ MSG_DELCARING_CLASSES.addHead(c);\r
+ MSG_DELCARING_CLASSES.unlock();\r
+ }\r
+ } // namespace Msg\r
+} // namespace SimGrid\r
\r
//////////////////////////////////////////////////////////////////////////////\r
// Implémentation des fonctions membre de la classe Class\r
for(cur = MSG_DELCARING_CLASSES.getHead(); cur; cur = cur->next)\r
{\r
if(!strcmp(name,cur->name))\r
- break;\r
+ return cur;\r
+\r
}\r
\r
MSG_DELCARING_CLASSES.unlock();\r
throw ClassNotFoundException(name);\r
}\r
\r
+\r
Object* Class::createObject(const char* name)\r
{\r
Class* c = fromName(name);\r
- \r
- if(NULL == c)\r
- return NULL;\r
- \r
return c->createObject();\r
}\r
\r
\r
return success;\r
}\r
+\r
+bool Object::isInstanceOf(const char* className)\r
+{\r
+ Class* c = Class::fromName(className);\r
+\r
+ return this->getClass()->isDerivedFrom(c);\r
+}\r
\r
\r
#include <Process.hpp>\r
\r
+#include <MsgException.hpp>\r
+#include <NullPointerException.hpp>\r
+#include <HostNotFoundException.hpp>\r
+#include <ProcessNotFoundException.hpp>\r
+#include <InvalidArgumentException.hpp>\r
+#include <BadAllocException.hpp>\r
+#include <LogicException.hpp>\r
+\r
+\r
+#include <ApplicationHandler.hpp>\r
+#include <Host.hpp>\r
+#include <Task.hpp>\r
+\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+\r
+#include <msg/msg.h>\r
+#include <msg/private.h>\r
+#include <msg/mailbox.h>\r
+\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
- Process* Process::currentProcess = NULL;\r
- \r
+\r
+ MSG_IMPLEMENT_DYNAMIC(Process, Object);\r
+\r
// Default constructor.\r
Process::Process()\r
{\r
if(!name)\r
throw NullPointerException("name");\r
\r
- if(!hostName)\r
- throw NullPointerException("hostName");\r
- \r
if(argc < 0)\r
- throw InvalidArgument("argc (must be positive)");\r
+ throw InvalidArgumentException("argc (must be positive)");\r
\r
if(!argc && argv)\r
throw LogicException("argv is not NULL but argc is zero");\r
create(rHost, name, argc, argv); \r
}\r
\r
- Process::Process(const char* hostname, const char* name, int argc, char** argv)\r
+ Process::Process(const char* hostName, const char* name, int argc, char** argv)\r
throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException)\r
{\r
// check the parameters\r
throw NullPointerException("hostName");\r
\r
if(argc < 0)\r
- throw InvalidArgument("argc (must be positive)");\r
+ throw InvalidArgumentException("argc (must be positive)");\r
\r
if(!argc && argv)\r
throw LogicException("argv is not NULL but argc is zero");\r
if(argc && !argv)\r
throw LogicException("argv is NULL but argc is not zero");\r
\r
- Host host = Host::getByName(hostname);\r
+ Host host = Host::getByName(hostName);\r
\r
create(host, name, argc, argv); \r
}\r
throw MsgException("MSG_process_resume() failed");\r
}\r
\r
- bool Process::isSuspended(void)\r
+ int Process::isSuspended(void)\r
{\r
- return (bool)MSG_process_is_suspended(nativeProcess);\r
+ return MSG_process_is_suspended(nativeProcess);\r
} \r
\r
Host& Process::getHost(void) \r
void Process::migrate(const Host& rHost)\r
throw(MsgException)\r
{\r
- if(MSG_OK != MSG_process_change_host(nativeProcess, rHost.nativeHost))\r
+ if(MSG_OK != MSG_process_change_host(rHost.nativeHost))\r
throw MsgException("MSG_process_change_host()");\r
\r
}\r
\r
void Process::sleep(double seconds)\r
- throw(throw(InvalidArgumentException, MsgException))\r
+ throw(InvalidArgumentException, MsgException)\r
{\r
// check the parameters.\r
if(seconds <= 0)\r
void Process::sendTask(const Task& rTask) \r
throw(BadAllocException, MsgException)\r
{\r
- char* alias = (char*)calloc(strlen(Host::currentHost().getName() + strlen(nativeProcess->name) + 2);\r
+ char* alias = (char*)calloc( strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
if(timeout < 0 && timeout !=-1.0)\r
throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
\r
- char* alias = (char*)calloc(strlen(Host::currentHost().getName() + strlen(nativeProcess->name) + 2);\r
+ char* alias = (char*)calloc(strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2 , sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
throw(BadAllocException, MsgException)\r
{\r
\r
- char* alias = (char*)calloc(strlen(Host::currentHost().getName() + strlen(nativeProcess->name) + 2);\r
+ char* alias = (char*)calloc(strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias"); \r
throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
\r
\r
- char* alias = (char*)calloc(strlen(Host::currentHost().getName() + strlen(nativeProcess->name) + 2);\r
+ char* alias = (char*)calloc(strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
if(timeout < 0 && timeout !=-1.0)\r
throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
\r
- char* alias = (char*)calloc(strlen(Host::currentHost().getName() + strlen(nativeProcess->name) + 2);\r
+ char* alias = (char*)calloc(strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
Task& Process::receiveTask(const Host& rHost) \r
throw(BadAllocException, MsgException)\r
{\r
- char* alias = (char*)calloc(strlen(Host::currentHost().getName() + strlen(nativeProcess->name) + 2);\r
+ char* alias = (char*)calloc(strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
\r
if(!alias)\r
throw BadAllocException("alias");\r
return (*((Task*)nativeTask->data));\r
}\r
\r
- void Process::create(const Host& rHost, const char* name, int argc, char** argv)\r
+ /*void Process::create(const Host& rHost, const char* name, int argc, char** argv)\r
throw(HostNotFoundException)\r
{\r
smx_process_t nativeCurrentProcess = NULL;\r
throw HostNotFoundException(rHost.getName());\r
\r
// realloc the list of the argument to add the pointer to this process instance at the end\r
- argv = (char**)realloc(argc + 1, sizeo(char*));\r
+ argv = (char**)realloc(argc + 1, sizeof(char*));\r
\r
// add the pointer to this instance at the end of the list of the arguments of the process\r
// so the static method Process::run() (passed as argument of the MSG function xbt_context_new())\r
// create the context of the process.\r
simdata->context = xbt_context_new(name, Process::run, NULL, NULL, simix_global->cleanup_process_function, nativeProcess, simdata->argc, simdata->argv);\r
\r
- /* Process structure */\r
+ // Process structure \r
this->nativeProcess->name = xbt_strdup(name);\r
this->nativeProcess->simdata = simdata;\r
\r
\r
xbt_swag_insert(this->nativeProcess, nativeHost->simdata->process_list);\r
\r
- /* fix current_process, about which xbt_context_start mocks around */\r
+ // fix current_process, about which xbt_context_start mocks around \r
nativeCurrentProcess = simix_global->current_process;\r
xbt_context_start(this->nativeProcess->simdata->context);\r
simix_global->current_process = nativeCurrentProcess;\r
xbt_swag_insert(this->nativeProcess, simix_global->process_list);\r
DEBUG2("Inserting %s(%s) in the to_run list", this->nativeProcess->name, nativeHost->name);\r
xbt_swag_insert(this->nativeProcess, simix_global->process_to_run);\r
+ }*/\r
+\r
+ void Process::create(const Host& rHost, const char* name, int argc, char** argv)\r
+ throw(InvalidArgumentException)\r
+ {\r
+ char alias[MAX_ALIAS_NAME + 1] = {0};\r
+ msg_mailbox_t mailbox;\r
+ \r
+ \r
+ // try to retrieve the host where to createt the process from its name\r
+ m_host_t nativeHost = rHost.nativeHost;\r
+ \r
+ if(!nativeHost)\r
+ throw InvalidArgumentException("rHost"); \r
+ \r
+ /* allocate the data of the simulation */\r
+ this->nativeProcess = xbt_new0(s_m_process_t,1);\r
+ this->nativeProcess->simdata = xbt_new0(s_simdata_process_t,1);\r
+ this->nativeProcess->name = _strdup(name);\r
+ this->nativeProcess->simdata->m_host = nativeHost;\r
+ this->nativeProcess->simdata->PID = msg_global->PID++;\r
+ \r
+ // realloc the list of the argument to add the pointer to this process instance at the end\r
+ if(argc)\r
+ argv = (char**)realloc(argv , (argc + 1) * sizeof(char*));\r
+ else\r
+ argv = (char**)calloc(1 ,sizeof(char*));\r
+ \r
+ // add the pointer to this instance at the end of the list of the arguments of the process\r
+ // so the static method Process::run() (passed as argument of the MSG function xbt_context_new())\r
+ // can retrieve the concerned process object by the run\r
+ // so Process::run() can call the method main() of the good process\r
+ // for more detail see Process::run() method\r
+ argv[argc] = (char*)this;\r
+\r
+ this->nativeProcess->simdata->argc = argc;\r
+ this->nativeProcess->simdata->argv = argv;\r
+ \r
+ this->nativeProcess->simdata->s_process = SIMIX_process_create(\r
+ this->nativeProcess->name,\r
+ Process::run, \r
+ (void*)this->nativeProcess,\r
+ nativeHost->name, \r
+ argc,\r
+ argv, \r
+ NULL);\r
+ \r
+ if (SIMIX_process_self()) \r
+ {/* someone created me */\r
+ this->nativeProcess->simdata->PPID = MSG_process_get_PID((m_process_t)SIMIX_process_self()->data);\r
+ } \r
+ else \r
+ {\r
+ this->nativeProcess->simdata->PPID = -1;\r
+ }\r
+ \r
+ this->nativeProcess->simdata->last_errno = MSG_OK;\r
+ \r
+ /* add the process to the list of the processes of the simulation */\r
+ xbt_fifo_unshift(msg_global->process_list, this->nativeProcess);\r
+ \r
+ sprintf(alias,"%s:%s",(this->nativeProcess->simdata->m_host->simdata->smx_host)->name,this->nativeProcess->name);\r
+ \r
+ mailbox = MSG_mailbox_new(alias);\r
+ \r
+ MSG_mailbox_set_hostname(mailbox, this->nativeProcess->simdata->m_host->simdata->smx_host->name);\r
+\r
+ \r
}\r
\r
- Process& Process::fromNativeProcess(m_process_t nativeProcess)\r
+ Process* Process::fromNativeProcess(m_process_t nativeProcess)\r
{\r
- return (*((Process*)(nativeProcess->simdata->arg[nativeProcess->argc])));\r
+ return ((Process*)(nativeProcess->simdata->argv[nativeProcess->simdata->argc]));\r
}\r
\r
int Process::run(int argc, char** argv)\r
// for mor detail see Process::create() method\r
return ((Process*)argv[argc])->main(argc, argv);\r
}\r
+\r
+ int Process::main(int argc, char** argv)\r
+ {\r
+ throw LogicException("Process::main() not implemented");\r
+ }\r
\r
} // namespace Msg\r
\r
#error Process.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
+#include <msg/datatypes.h>\r
+\r
+#include <ApplicationHandler.hpp>\r
+#include <Object.hpp>\r
\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class NullPointerException;\r
+ class HostNotFoundException;\r
+ class ProcessNotFoundException;\r
+ class InvalidArgumentException;\r
+ class BadAllocException;\r
+ class LogicException;\r
+ class MsgException;\r
+\r
+ class ApplicationHandler;\r
+ class Host;\r
+ class Task;\r
+\r
// SimGrid::Msg::Process class declaration.\r
- class Process\r
+ class SIMGRIDX_EXPORT Process : public Object\r
{\r
- friend ApplicationHandler;\r
\r
- private;\r
+ friend ApplicationHandler::ProcessFactory;\r
\r
+ MSG_DECLARE_DYNAMIC(Process);\r
+\r
+ public:\r
// Disable the default constructor.\r
Process();\r
\r
- public:\r
\r
/*! \brief Constructs a process from the name of the host and its name.\r
*\r
\r
/*! \brief Process::isSuspend() - Tests if a process is suspended.\r
*\r
- * \return This method returns true is the process is suspended.\r
- * Otherwise the method returns false.\r
+ * \return This method returns 1 is the process is suspended.\r
+ * Otherwise the method returns 0.\r
*/\r
- bool isSuspended(void);\r
+ int isSuspended(void);\r
\r
/*! \brief Process::getHost() - Retrieves the host of a process object.\r
*\r
* \remark Set the timeout with -1.0 to disable it.\r
*/\r
Task& getTask(int channel, double timeout, const Host& rHost)\r
- throw(InvalidArgumentException MsgException);\r
+ throw(InvalidArgumentException, MsgException);\r
\r
/*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias\r
* (waiting at most given time).\r
*\r
* [MsgException] if an internal exception occurs.\r
*/\r
- Task& Process::receiveTask(double timeout, const Host& rHost) \r
+ Task& receiveTask(double timeout, const Host& rHost) \r
throw(BadAllocException, InvalidArgumentException, MsgException);\r
\r
/*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias\r
*\r
* \return The wrapper associated with the native process specified as parameter.\r
*/\r
- static Process& fromNativeProcess(m_process_t nativeProcess);\r
+ static Process* fromNativeProcess(m_process_t nativeProcess);\r
\r
\r
public:\r
*\r
* \return The exit code of the main function.\r
*/\r
- virtual int main(int argc, char** argv) = 0;\r
+ virtual int main(int argc, char** argv);\r
\r
private:\r
\r
\r
} //namepace Msg\r
\r
-} namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
+#endif // !MSG_PROCESS_HPP
\ No newline at end of file
\r
#include <Simulation.hpp>\r
\r
+#include <Application.hpp>\r
+#include <Environment.hpp>\r
+\r
+#include <MsgException.hpp>\r
+#include <FileNotFoundException.hpp>\r
+\r
+#include <Msg.hpp>\r
+\r
+#include <msg/msg.h> \r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
- \r
- \r
int Simulation::execute(int argc, char** argv)\r
{\r
if(argc < 3) \r
try\r
{\r
app.deploy(argv[2]);\r
+ }\r
catch(FileNotFoundException e)\r
{\r
info(e.toString());\r
//try to run the simulation the given application on the given environment\r
try\r
{\r
- this->run();\r
+ run();\r
}\r
catch(MsgException e)\r
{\r
}\r
catch(MsgException e)\r
{\r
- info(e.toString())\r
+ info(e.toString());\r
return 1;\r
}\r
\r
#error Sumulation.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
+#include <Config.hpp>\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class MsgException;\r
+ class FileNotFoundException;\r
+\r
// Simulation class declaration.\r
- class Simulation\r
+ class SIMGRIDX_EXPORT Simulation\r
{\r
public :\r
\r
- Simulation();\r
+ Simulation(){};\r
\r
Simulation(const Simulation& rSimulation);\r
\r
- virtual ~Simulation();\r
+ virtual ~Simulation(){};\r
\r
// Operations.\r
\r
#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
+#include <Process.hpp>\r
+#include <Host.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
\r
Task::Task(const Task& rTask)\r
{\r
+ this->nativeTask = rTask.nativeTask;\r
}\r
\r
\r
Task::~Task()\r
- throw(NativeException)\r
+ throw(MsgException)\r
{\r
if(NULL != nativeTask)\r
if(MSG_OK != MSG_task_destroy(nativeTask))\r
Task::Task(const char* name, double computeDuration, double messageSize)\r
throw(InvalidArgumentException, NullPointerException)\r
{\r
- \r
+\r
if(computeDuration < 0) \r
throw InvalidArgumentException("computeDuration");\r
\r
Task::Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)\r
throw(NullPointerException, InvalidArgumentException)\r
{\r
- \r
// check the parameters\r
\r
if(!name) \r
\r
\r
\r
- task->data = (void*)this;\r
+ this->nativeTask->data = (void*)this;\r
\r
}\r
\r
\r
Process& Task::getSender(void) const\r
{\r
- m_proccess_t nativeProcess = MSG_task_get_sender(nativeTask);\r
+ m_process_t nativeProcess = MSG_task_get_sender(nativeTask);\r
\r
return (*((Process*)(nativeProcess->data)));\r
}\r
MSG_task_set_priority(nativeTask, priority);\r
}\r
\r
- Task& Task::get(int channel) \r
+ /*Task& Task::get(int channel) \r
throw(InvalidArgumentException, MsgException)\r
{\r
// check the parameters\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
+ {\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
return (*((Task*)(nativeTask->data)));\r
}\r
\r
- bool static Task::probe(int channel)\r
+ int Task::probe(int channel)\r
throw(InvalidArgumentException)\r
{\r
// check the parameters\r
if(channel < 0)\r
throw InvalidArgumentException("channel (must not be negative)");\r
\r
- return (bool)MSG_task_Iprobe(channel);\r
+ return MSG_task_Iprobe(channel);\r
}\r
\r
int Task::probe(int channel, const Host& rHost)\r
if(channel < 0)\r
throw InvalidArgumentException("channel (must not be negative)");\r
\r
- return MSG_task_probe_from_host(chan_id,rHost.nativeHost);\r
+ return MSG_task_probe_from_host(channel,rHost.nativeHost);\r
}\r
\r
void Task::execute(void) \r
void Task::send(void) \r
throw(BadAllocException, MsgException)\r
{ \r
- char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);\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", Process::currentProcess().getName(),Host::currentHost().getName());\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
+ free(alias);\r
\r
if(MSG_OK != rv)\r
throw MsgException("MSG_task_send_with_timeout() failed");\r
}\r
\r
void Task::send(double timeout) \r
- throw(BadAllocationException, InvalidArgumentException, MsgException)\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);\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", Process::currentProcess().getName(),Host::currentHost().getName());\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
+ free(alias);\r
\r
if(MSG_OK != rv)\r
throw MsgException("MSG_task_send_with_timeout() failed");\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);\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", Process::currentProcess().getName(),Host::currentHost().getName());\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
throw MsgException("MSG_task_send_bounded() failed");\r
}\r
\r
- Task& Task::receive(void) \r
- throw(throw(BadAllocException, MsgException))\r
+ /*Task& Task::receive(void) \r
+ throw(BadAllocException, MsgException)\r
{\r
- char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);\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", Process::currentProcess().getName(),Host::currentHost().getName());\r
+ sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
\r
m_task_t nativeTask = NULL;\r
\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
+ {\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
+ /*Task& Task::receive(const char* alias) \r
throw(NullPointerException, MsgException)\r
{\r
// check the parameters\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
if(!alias)\r
throw NullPointerException("alias");\r
\r
- if(timeout < 0 && alias != -1.0)\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
if(!alias)\r
throw NullPointerException("alias");\r
\r
- if(timeout < 0 && alias != -1.0)\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
return (*((Task*)nativeTask->data));\r
}\r
\r
- bool Task::listen(void) \r
+ int Task::listen(void) \r
throw(BadAllocException)\r
{\r
- char* alias = (char*)calloc(strlen(Process::currentProcess().getName() + strlen(Host::currentHost().getName()) + 2);\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", Process::currentProcess().getName(),Host::currentHost().getName());\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 (bool)rv;\r
+ return rv;\r
} \r
\r
- bool Task::listen(const char* alias) \r
+ int Task::listen(const char* alias) \r
throw(NullPointerException)\r
{\r
// check the parameters\r
if(!alias)\r
throw NullPointerException("alias");\r
\r
- return (bool)MSG_task_listen(alias);\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);\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", Process::currentProcess().getName(),Host::currentHost().getName());\r
+ sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
\r
int rv = MSG_task_listen_from(alias);\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);\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", Process::currentProcess().getName(),Host::currentHost().getName());\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
\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
\r
// Compilation C++ recquise\r
#ifndef __cplusplus\r
- #error Process.hpp requires C++ compilation (use a .cxx suffix)\r
+ #error Task.hpp requires C++ compilation (use a .cxx suffix)\r
#endif\r
\r
+#include <msg/datatypes.h>\r
+\r
+#include <Config.hpp>\r
+\r
+#include <Object.hpp>\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
{\r
+ class MsgException;\r
+ class InvalidArgumentException;\r
+ class NullPointerException;\r
+ class MsgException;\r
+ class BadAllocException;\r
+\r
+ class Process;\r
+ class Host;\r
+\r
// SimGrid::Msg::Task wrapper class declaration.\r
- class Task\r
+ class SIMGRIDX_EXPORT Task : public Object\r
{\r
+ MSG_DECLARE_DYNAMIC(Task);\r
+\r
+ friend Process;\r
+ friend Host;\r
+\r
protected:\r
// Default constructor.\r
Task();\r
+\r
+ class Ref\r
+ {\r
+ public:\r
+ Ref(Task* task)\r
+ {\r
+ count = 1;\r
+ this->task = task;\r
+ }\r
+\r
+ virtual ~Ref(){}\r
+\r
+ void operator++(void){\r
+ count++;\r
+ \r
+ }\r
+\r
+ void operator--(void){\r
+ if(--count <= 0)\r
+ delete p;\r
+ }\r
+\r
+ private:\r
+ int count;\r
+ Task* task;\r
+\r
+ };\r
\r
public:\r
/*! \brief Copy constructor.\r
* \r
* [MsgException] if an internal excpetion occurs.\r
*/\r
- static Task& get(int channel) \r
- throw(InvalidArgumentException, MsgException); \r
- \r
+ /*static Task& get(int channel) \r
+ throw(InvalidArgumentException, MsgException);*/\r
+\r
+ static Task* get(int channel) \r
+ throw(InvalidArgumentException, MsgException);\r
+\r
/*! \brief Task::get() - Gets a task from the given channel number of the given host. \r
*\r
* \param channel The channel number.\r
*\r
* \param channel The channel number.\r
*\r
- * \return If there is a waiting task on the channel the method returns true. Otherwise\r
- * the method returns false.\r
+ * \return If there is a waiting task on the channel the method returns 1. Otherwise\r
+ * the method returns 0.\r
*\r
* \exception If this method fails, it throws the exception described below:\r
*\r
* [InvalidArgumentException] if the parameter channel is negative.\r
*/\r
- static bool probe(int channel)\r
+ static int probe(int channel)\r
throw(InvalidArgumentException);\r
\r
/*! \brief Task::probe() - Counts tasks waiting on the given channel of local host and sent by given host.\r
* [MsgException] if an internal exception occurs.\r
*/\r
void send(double timeout) \r
- throw(BadAllocationException, InvalidArgumentException, MsgException);\r
+ throw(BadAllocException, InvalidArgumentException, MsgException);\r
\r
/*! \brief Task::send() - Send the task on the mailbox identified by a given alias\r
* (waiting at most given time).\r
*\r
* [MsgException] if an internal exception occurs.\r
*/\r
- static Task& receive(void) \r
+ /*static Task& receive(void) \r
+ throw(BadAllocException, MsgException);*/\r
+\r
+ static Task* receive(void) \r
throw(BadAllocException, MsgException);\r
\r
/*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located\r
*\r
* [MsgException] if an internal exception occurs.\r
*/\r
- static Task& receive(const char* alias) \r
+ /*static Task& receive(const char* alias) \r
+ throw(NullPointerException, MsgException);*/\r
+ static Task* receive(const char* alias) \r
throw(NullPointerException, MsgException);\r
\r
/*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located\r
*\r
* [BadAllocException] if there is not enough memory to build the default alias.\r
*/\r
- static bool listen(void) \r
+ static int listen(void) \r
throw(BadAllocException);\r
\r
/*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox \r
*\r
* \param alias The alias of the mailbox.\r
*\r
- * \return If there is a waiting task on the mailbox the method returns true.\r
- * Otherwise the method returns false.\r
+ * \return If there is a waiting task on the mailbox the method returns 1.\r
+ * Otherwise the method returns 0.\r
*\r
* \exception If this method fails, it throws one of the exceptions described below:\r
*\r
* [NullPointerException] if the parameter alias is NULL.\r
*/\r
- static bool listen(const char* alias) \r
+ static int listen(const char* alias) \r
throw(NullPointerException);\r
\r
/*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox \r
* [BadAllocException] if there is not enough memory to build the default\r
* alias.\r
*/\r
- static bool listenFromHost(const char* alias, const Host& rHost) \r
- throw(NullPointerException, NativeException);\r
+ static int listenFromHost(const char* alias, const Host& rHost) \r
+ throw(NullPointerException, MsgException);\r
+\r
+ virtual const Task& operator= (const Task& rTask);\r
\r
- private:\r
+ protected:\r
\r
// Attributes.\r
\r
- m_task_t nativeTask; // the native MSG task.\r
+ m_task_t nativeTask; // the native MSG task.\r
+\r
+ Ref* ref;\r
};\r
\r
} // namespace Msg \r
} // namespace SimGrid\r
\r
+typedef Task* TaskPtr;\r
+\r
#endif // §MSG_TASK_HPP
\ No newline at end of file